Code Monkey home page Code Monkey logo

Comments (5)

GoaLitiuM avatar GoaLitiuM commented on June 29, 2024

The following compiles just fine, are you missing API_STRUCT() from the Attribute struct?

API_CLASS() class GAME_API Item : public Script
{
API_AUTO_SERIALIZATION();
DECLARE_SCRIPTING_TYPE(Item);

    API_STRUCT() struct GAME_API Attribute
    {
        DECLARE_SCRIPTING_TYPE_MINIMAL(Attribute);
    };

    // [Script]
    void OnEnable() override;
    void OnDisable() override;
    void OnUpdate() override;
};

API_STRUCT() struct GAME_API RuntimeItem
{
    DECLARE_SCRIPTING_TYPE_MINIMAL(RuntimeItem);
    API_FIELD() Array<Item::Attribute> Attributes;
};

from flaxengine.

cNori avatar cNori commented on June 29, 2024

The following compiles just fine, are you missing API_STRUCT() from the Attribute struct?

API_CLASS() class GAME_API Item : public Script
{
API_AUTO_SERIALIZATION();
DECLARE_SCRIPTING_TYPE(Item);

    API_STRUCT() struct GAME_API Attribute
    {
        DECLARE_SCRIPTING_TYPE_MINIMAL(Attribute);
    };

    // [Script]
    void OnEnable() override;
    void OnDisable() override;
    void OnUpdate() override;
};

API_STRUCT() struct GAME_API RuntimeItem
{
    DECLARE_SCRIPTING_TYPE_MINIMAL(RuntimeItem);
    API_FIELD() Array<Item::Attribute> Attributes;
};

I have it in the source but i striped from ishue for redability

[Edit] DECLARE_SCRIPTING_TYPE_MINIMAL is incorect for struct btw

Compiler on c# is yeling abaut this
Item.AttributeMarshaller.Item.AttributeInternal
It needs to be like this
Item.AttributeMarshaller.AttributeInternal

from flaxengine.

mtszkarbowiak avatar mtszkarbowiak commented on June 29, 2024

I think, for structs you should use DECLARE_SCRIPTING_TYPE_STRUCTURE.

from flaxengine.

cNori avatar cNori commented on June 29, 2024

found the place for a patch
BindingsGenerator.CSharp.cs:~1640
this will fix it

                        string originalElementType = originalType[0..^2];

                        if (internalType)
                        {
                            // Marshal blittable array elements back to original non-blittable elements
                            string originalElementTypeMarshaller = originalElementType + "Marshaller";
                            //[Nori_SC note]
                            //Find all characters after last . as a example if the c++ type is Class.Struct it will generate a invalid c# code
                            //with will look like this <Class>.<Struct>Marshaller.<Class>.<Struct>Internal
                            //valid code looks like this <Class>.<Struct>Marshaller.<Struct>Internal

                            var startindex = originalElementType.LastIndexOf('.') + 1;

                            string internalElementType = $"{originalElementTypeMarshaller}.{originalElementType[startindex..]}Internal";

from flaxengine.

GoaLitiuM avatar GoaLitiuM commented on June 29, 2024

The final code that reproduces the issue:

API_CLASS() class GAME_API Item : public Script
{
API_AUTO_SERIALIZATION();
DECLARE_SCRIPTING_TYPE(Item);

    API_STRUCT() struct GAME_API Attribute
    {
        DECLARE_SCRIPTING_TYPE_MINIMAL(Attribute);
        API_FIELD() String foo;
    };

    // [Script]
    void OnEnable() override;
    void OnDisable() override;
    void OnUpdate() override;
};

API_STRUCT() struct GAME_API RuntimeItem
{
    DECLARE_SCRIPTING_TYPE_MINIMAL(RuntimeItem);
    API_FIELD() Array<Item::Attribute> Attributes;
};

from flaxengine.

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.