Repository navigation
[memory-ownership] Honour ownership attributes when taking and releasing memory #114
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -29,20 +29,24 @@ class CPPInstance { | |||||||||
| public: | ||||||||||
| enum EFlags { | ||||||||||
| kDefault = 0x0000, | ||||||||||
| kNoWrapConv = 0x0001, // use type as-is (eg. no smart ptr wrap) | ||||||||||
| kIsOwner = 0x0002, // Python instance owns C++ object/memory | ||||||||||
| kIsExtended = 0x0004, // has extended data | ||||||||||
| kIsValue = 0x0008, // was created from a by-value return | ||||||||||
| kIsReference = 0x0010, // represents one indirection | ||||||||||
| kIsArray = 0x0020, // represents an array of objects | ||||||||||
| kIsSmartPtr = 0x0040, // is or embeds a smart pointer | ||||||||||
| kIsPtrPtr = 0x0080, // represents two indirections | ||||||||||
| kIsRValue = 0x0100, // can be used as an r-value | ||||||||||
| kIsLValue = 0x0200, // can be used as an l-value | ||||||||||
| kNoMemReg = 0x0400, // do not register with memory regulator | ||||||||||
| kIsRegulated = 0x0800, // is registered with memory regulator | ||||||||||
| kIsActual = 0x1000, // has been downcasted to actual type | ||||||||||
| kHasLifeLine = 0x2000, // has a life line set | ||||||||||
| kNoWrapConv = 0x0001, // use type as-is (eg. no smart ptr wrap) | ||||||||||
| kIsOwner = 0x0002, // Python instance owns C++ object/memory | ||||||||||
| kIsExtended = 0x0004, // has extended data | ||||||||||
| kIsValue = 0x0008, // was created from a by-value return | ||||||||||
| kIsReference = 0x0010, // represents one indirection | ||||||||||
| kIsArray = 0x0020, // represents an array of objects | ||||||||||
| kIsSmartPtr = 0x0040, // is or embeds a smart pointer | ||||||||||
| kIsPtrPtr = 0x0080, // represents two indirections | ||||||||||
| kIsRValue = 0x0100, // can be used as an r-value | ||||||||||
| kIsLValue = 0x0200, // can be used as an l-value | ||||||||||
| kNoMemReg = 0x0400, // do not register with memory regulator | ||||||||||
| kIsRegulated = 0x0800, // is registered with memory regulator | ||||||||||
| kIsActual = 0x1000, // has been downcasted to actual type | ||||||||||
| kHasLifeLine = 0x2000, // has a life line set | ||||||||||
| kIsArrayAlloc = 0x4000, // represents a heap allocated array of objects | ||||||||||
| kIsNoConstruct = | ||||||||||
| 0x8000, // represents constructor is not called in the allocation | ||||||||||
|
Comment on lines
+47
to
+48
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's not have this in a negative way. It becomes difficult to read.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since before allocation details the assumption was constructor was run for each instance, and we are adding a kIsNoConstruct to reflect the opposite possibility. If I have added kIsConstruct I would have to revert each instance creation mechanism and probably more things. Also git diff is still large for flags because of clang-format
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, this is a good argument. |
||||||||||
| kIsMalloc = 0x10000, // is allocated with malloc | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| public: // public, as the python C-API works with C structs | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to
__is_construct__.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But we can at least do it here, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep