Code Monkey home page Code Monkey logo

Comments (4)

borisbat avatar borisbat commented on July 16, 2024

if i understood the question correctly, easiest would be to use macros on top of ast, instead of rtti.

from dascript.

AlvaroBarua avatar AlvaroBarua commented on July 16, 2024

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:

image

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:

image

PS: Sorry for uploading images, but for some reason code sections are broken for me.

from dascript.

borisbat avatar borisbat commented on July 16, 2024

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.

borisbat avatar borisbat commented on July 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.