-
Notifications
You must be signed in to change notification settings - Fork 21
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
Added passing arguments to constrcutors when allocating with Trick Memory Manager. #1790
Draft
M-Herr
wants to merge
22
commits into
nasa:master
Choose a base branch
from
M-Herr:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…on. Added FunctionVisitor class to ICG to handle parsing constructors with arguments.
… unecessary to write it out from ICG. Created trick_types.hh to hold includes for the non-specialized TrickTypeToString<T> and the specialzied TrickTypeToString<T> created by ICG.
generate alloc functions in the swig interface files for classes. These alloc functions wrap the tmm_alloc_args call so swig doesn't have to think about variadic templates.
… json (for now) file that has important constructor info. Less regex, less room for error.
…g static alloc functions for the swig interface files. These get called by overwriting the __init__ functions.
…constructor additions
Hopefully fixed bug that was preventing default behavior in python classes in the input file
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goals
New Things
From a users perspective:
Foo* foo = tmm_alloc_args<Foo>()
The allocation functions takes the template parameters
<typename T, typename ...Args>
where Args is a parameter pack. We can use this to wrap any constructor call, as long as we can a string representation of the typeT
to pass to the trick memory manager.The struct
TrickTypeToString
let's us get a string representation of the type through template specialization. ICG will generate specializations for all types it knows about (except anything in Trick, std, or er7 namespaces).I've added FunctionVisitor and FunctionDescription classes (modeled after FieldVisitor and FieldDescription). The visitor handles pulling some information out of
clang::Decl::CXXConstructor
and the description holds it. This info is used by ICG to generate two files:trick_type_to_string_ext.hh
andconstructors.json
. As mentioned above, the TrickTypeToString structures are used to convert types to strings. The constructor information in constructors.json is used by convert_swig to generated addition functions in swig interface files.If the constructor takes arguments, it'll have an array of type/name pairs.
convert_swig has been updated with a new function
process_constructor_json
that uses the json data written by ICG to add some functionality. Functions are added to the class using swigs %extend functionality. Onealloc
function is generated for every constructor overload that exists.This is an example of the %extend functionality from test/SIM_tmm_alloc_args.
SWIG will make those functions available in python for us, at this point a user can allocate using tmm_alloc_args from python.
var = trick.AllocTestWithArguments.alloc(1, 5.0)
To make it even more seamless I've modified the one of the
__init__
overrides inswig_class_typedef.i
to call alloc using python's unpacking operator(*). So now you can allocate usingtrick.AllocTestWithArguments(1, 5.0)
.I've also added flags to ICG and convert swig so that all of the above features have to be explicitly enabled via:
This is still a work in progress, but if anyone spots any issues please let me know.