Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implicit assignment operator missing #163

Open
arnetheduck opened this issue Feb 1, 2025 · 4 comments
Open

Implicit assignment operator missing #163

arnetheduck opened this issue Feb 1, 2025 · 4 comments
Labels

Comments

@arnetheduck
Copy link
Contributor

Types like QModelIndex have an implicit assignment operator that ideally should be exposed, just like the explicit ones.

@mappu
Copy link
Owner

mappu commented Feb 2, 2025

There is definitionData->copyAssign field in the clang AST.

The same place also has fields for moveAssign / copyCtor / defaultCtor / etc. Probably the implicit constructor and copy constructor might also be useful to add bindings for.

@mappu mappu added the wishlist label Feb 2, 2025
@rcalixte
Copy link
Contributor

rcalixte commented Feb 2, 2025

If it helps, I ended up calling these QCopy, QMove, etc. to avoid namespace collisions. It's not too bad to implement since the AST calls them out as trivial. If this doesn't have an owner by the time I release the other libraries, I wouldn't mind getting it taken care of after getting Clang 19 sorted. (Clang 19 is probably the top thing on my list to get sorted after the releases but after that, everything else is fair game where I can lend a hand.)

Edit: I'm glad I took another look at this. I might have prematurely optimized for the namespace collisions. I think if the AST parsing for these members only occurs for RecordDecl types, there might not be any collisions and the simpler method names can be used instead.

Another edit: I've refactored this a bit more. The copy and move implementations are appended to existing Ctors so they will be available as additional New methods. The other two constructors are appended as OperatorAssign and MoveAssign in line with the existing library code. Just another example of where I've possibly made a mess of things. 😔

Last edit I hope: This is possibly a breaking change for all affected Ctors and there are many duplicate implementations.

@arnetheduck
Copy link
Contributor Author

OperatorAssign

The important thing to maintain here is consistency between implicit and explicit versions of this function in particular.

Regarding copy constructors, they are useful for implementing meta-object "copy" support which in turn is needed for cross-thread signal emission. While useful, they can also in most cases be "emulated" with a default constructor call + assignment, moving them off the critical implementation path.

@rcalixte
Copy link
Contributor

rcalixte commented Feb 5, 2025

The important thing to maintain here is consistency between implicit and explicit versions of this function in particular.

Yeah, apologies for the unhinged rambling. I let myself get carried away. I ended up adding Copy and Move as Ctors where they ends up duplicating a lot of other existing Ctors but ended up also being initialized in a number of places so I'm lazily leaving it that way. For the other two implementations that I applied, I ended up with CopyAssign and MoveAssign. The Move variants also implement std::move as you would expect. I've documented the invocations in the code for the target languages. I haven't changed this in a few days so I think it will stay this way. 😅

Sorry again for the previous incoherence.

arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
Play around with `sink`/`=destroy`/etc to provide basic memory
management facilites relieving the user from having to free resources
explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transwer" ownership but this is not yet captured
correctly by the flag (ie when a function returns a value rather than a
reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Feb 27, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to arnetheduck/nim-miqt-poc that referenced this issue Mar 1, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Mar 4, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Mar 5, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Mar 5, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Mar 5, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Mar 6, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Mar 12, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Apr 2, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Apr 8, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Apr 9, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Apr 9, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
arnetheduck added a commit to seaqt/seaqt-gen that referenced this issue Apr 9, 2025
This update plays around with `sink`/`=destroy`/etc to provide basic
memory management facilites relieving the user from having to free
resources explicitly, specially when using value types like `QVariant`.

To simplify this draft, all qt types are turned into move-only types
with an ownership flag that is set for instances we create - this basic
approach works ok for value types that are created with a simple
constructor but will need more work to capture QObject parent/child
relationships.

Once mappu/miqt#163 has been fixed and all
move/copy operators are available, copy support can be added for value
types.

There are also gaps in the ownership conventions, ie non-constructor
functions sometimes "transfer" ownership but this is not yet captured
correctly by the flag nor is there an interface for API outside of the
flag being public for now (ie when a function returns a value rather
than a reference on the C++ side)

At the same time, the inheritance model changes to use `method`-style
dynamic dispatch and `ref` for pointer stability which makes it
significantly easier to use.

* add ownership flag to wrapper classes - when owned, the destructor
will free the underlying c++ instance
* rework inheritance approach - when deriving from qt classes, derive
from special `Virtual`-prefixed class which uses `ref` to maintain
pointer stability and therefore can register itself with the C++ class
* first steps towards tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants