FlaxEngine / FlaxEngine

Flax Engine – multi-platform 3D game engine
https://flaxengine.com
Other
5.54k stars 541 forks source link

Binding generation compile needs some work #2594

Open cNori opened 1 month ago

cNori commented 1 month ago

Issue description:

Classes

there was almost a 3 major engine version and the nested classes are not supported yet, limiting a decision choices for systems with out prefix evry think with the name as a example:

API_CLASS() class EelementData
{
...
};
API_CLASS() class Eelement
{
...
private:
    API_FIELD()  EelementData m_Data;
};

and because only classes are nullabke in c# by default structs cannot be used. because the bindings are not supporting a C# optionals [Data? data = null;]

Structs

with leads to this design because it is foreced on to a user c++ side

API_STRUCT(NoPod) struct MODULE_API Data  :  public INetworkSerializable
{
...
        API_FIELD(internal) bool m_IsDirty; //needed to be exposed othere wise the flax C# Glue layer will remove it when pasing betwine c# and c++ and back
        /// <summary>
        /// Use Getter and Seter insted
        /// </summary>
        API_FIELD(internal) String m_Name;
        void SetName(const String& name);
        const String& GetName() const;
...
};

c# side needs a extra code


pubkic parsial struct Data 
{
        [NoSerialize]
        public string Name
        {
            get => m_Name;
            set
            {
               Name = value;
               m_IsDirty = true;
            }
        }
}