Topic Author
Posts: 11
Joined: 15 Apr 2019, 00:43

Exposing NoesisGui C++ API to scripting language

25 Jul 2019, 23:21

Hello all,
I recently learned about existence of Noesis and I really like what I see so far. I've been through MANY GUI libraries and this one seems to give all the functionality I need. There is just one problem - my project relies heavily on scripting (Angelscript) and Noesis C++ API relies heavily on reflection and templating. I'd like to be able to create a script-side class that would describe some data structure that I could then bind as a data source to XAML. Or create a converter etc. I'm not sure where to begin or even if this is possible. Has anyone tried to implement a scripting bindings where main language is C++ and somehow glued these two worlds together? I have full reflection in my scripting language and I can even use meta data annotations for my props so I could easily turn them into Noesis-enabled properties etc. - the problem is that Noesis expects me to register C++ classes through templated interfaces and it doesn't play with runtime-based scripting.

I'm thinking of some way to wrap it into a single "ScriptComponent" class that would somehow work as a bag containing script instance that has some props, and then expose these props through something that is known to Noesis. But all I see is heavily macroed/templated stuff. Is there some way into the API that would allow me to provide such functionality in a more passive way - where Noesis queries props rather than expecting me to set them through C++ reflection system, which I'm not sure I can mimic and tie to my script classes :/

Any input welcome!

User avatar
Site Admin
Posts: 240
Joined: 09 Feb 2012, 12:40

Re: Exposing NoesisGui C++ API to scripting language

26 Jul 2019, 12:41

Hi noizex,

We currently do something similar to what you want in our UE4 integration to allow data binding to data from Blueprints (Unreal's visual scripting language). You can take a look at the code in our GitHub repository. Most of the parts relevant to you are here ... eClass.cpp

What we do is that we use Unreal's reflection information to create Noesis reflection info that allows data binding and then have a wrapper around Unreal's objects. The relevant classes are:

- NoesisTypeClass stores the reflection info of an Unreal Blueprint class.
- TypePropertyNoesisObjectWrapper stores information about a property in the class. This is where most of the interesting stuff happens.
- NoesisObjectWrapper is, as its name implies, a wrapper around an Unreal object.

When Noesis tries to get or set a property in an object, it asks for its TypeClass, then looks for the property, and calls Get/SetComponent passing in the pointer to the object. In our case, the property is a TypePropertyNoesisObjectWrapper, which contains the relevant Unreal reflection info to retrieve the property, and the object passed is a NoesisObjectWrapper, which contains the pointer to the Unreal object. With those two things we can get or set the property in the script object.

I'm not familiar with Angelscript, but as long as it provides reflection information you should be able to do something similar.

The code I've pointed you to is a bit messy, as it's grown to support other features, so don't hesitate to ask if you need more information.
Topic Author
Posts: 11
Joined: 15 Apr 2019, 00:43

Re: Exposing NoesisGui C++ API to scripting language

26 Jul 2019, 22:20

Thanks a lot! I will have a look - I started to dig into Noesis classes and try to understand how I could work around the static nature of templates while retaining dynamic reflection from script engine. It looks like the Unreal code should push me forward real quick, as it seems to follow similar principles. I will let you know once I get any questions or maybe some progress, in case it's useful to someone with similar use case.

Who is online

Users browsing this forum: Bing [Bot] and 3 guests