Comments (4)
if i understood the question correctly, easiest would be to use macros on top of ast, instead of rtti.
from dascript.
So there is no straight forward way of doing so?
What I'm doing at the moment is going through all structures in the module and doing reflection on the ones that satisfy a specific condition, the part that complicates thing for me is here:
If you could point me into some example code or provide some more insight, it would be really helpful.
To provide some extra context, this is how I am setting up the quat class:
PS: Sorry for uploading images, but for some reason code sections are broken for me.
from dascript.
Ok. So assuming that your init expression has no side effects, and your custom type is bound as by reference value (structure, etc).
The quickest shortcut would be something like this
fieldInfo.defaultValue = * cast<YourValueType *>::to(node->eval(mContext));
the issue here, though, is u may need to setup abiCMRES on the context - to where the result would be copied, depending on how the node is simulated and what not.
There is fairly straightforward way of doing it at compilation time with daScript. I'm going to provide example shortly.
from dascript.
https://github.com/GaijinEntertainment/daScript/blob/master/examples/test/misc/dump_fields.das
example of the annotation, which iterates through fields, and reports names and prints initialization ast, as well as the example on how to use it
https://github.com/GaijinEntertainment/daScript/blob/master/examples/test/misc/dump_fields_example.das
I'm going to assume that you'd like to do something more than just printing.
https://github.com/GaijinEntertainment/daScript/blob/master/examples/test/misc/gen_fields.das
gen_fields is a little_bit more involved example. "dump" annotation generates some sort of 'registration' at script initialization time. "dump2" performs similar functionality in a tad more limited fashion, but at compilation time - and produces no initialization artifacts.
you can always add "options log" and check, what kind of code has been generated.
from dascript.
Related Issues (20)
- try to AOT HOT 3
- Compilation error when exporting c++ class with ManagedStructureAnnotation HOT 1
- How to debug in an embedded environment using VSCode ? HOT 1
- cmake error ~~ help~~
- Which should I use “addExtern” or “addInterop”? HOT 1
- Unexpected execution when embedded module, Executed without being called~~ HOT 1
- No Garbage collection ? HOT 3
- where is libclang HOT 2
- 30304: function not found HOT 5
- How to correctly require the parent module or somewhere ? HOT 2
- How to export a array<c++ struct> to das ? HOT 3
- How to generate .wasm HOT 2
- How to list exported symbols from modules HOT 2
- How to compile simple program in AOT mode? HOT 6
- Are there any JIT mode optimizations flags? HOT 10
- Optimizing related_post_gen benchmark HOT 12
- null pointer passed as argument HOT 1
- It is recommended that compiled binaries be released for download.
- Compilation error using static linking HOT 1
- Is it possible to define a single module across multiple files? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dascript.