(Solved) Internal enums in AngelScript

In c++ I have class

class URHO3D_API CameraControllerFlowNode : public FlowNode
{
    URHO3D_OBJECT(CameraControllerFlowNode, FlowNode);

public:
    CameraControllerFlowNode(Context* context);
    void Update(float timeStep);

    enum InputPort
    {
        IN_CAMERA_NODE = 0,
        IN_MOUSE_SENSITIVITY = 1
    };
    ...
};

What better way to export it enum to angelScript? Do I have to use constants instead?

class URHO3D_API CameraControllerFlowNode : public FlowNode
{
    URHO3D_OBJECT(CameraControllerFlowNode, FlowNode);

public:
    CameraControllerFlowNode(Context* context);
    void Update(float timeStep);

    static const int IN_CAMERA_NODE = 0;
    static const int IN_MOUSE_SENSITIVITY = 1;
    ...
};

It’s possible AS doesn’t support enums inside classes yet, though the author has already talked about it long ago. Most trouble-free option would probably be to just define an enum outside the class, and expose normally.

There may be a lot of different types of flounodes (hunderts), so in global namespace it will be a lot of excess

Is also impossible to register consts in class for AS?

engine->RegisterObjectProperty("CameraControllerFlowNode", "const int IN_CAMERA_NODE", offsetof(CameraControllerFlowNode, IN_CAMERA_NODE));

gives me error :frowning:

Offsetof is for normal instance variables within the object’s memory block, consts aren’t part of that.

Mey be is easy way for register some readonly property which just return some digit (I mean without make functions like Return0(), Return1())

I’d suggest using one of dictionary types.

Ok, I found a solution

github.com/urho3d/Urho3D/issues/1730

Hi!
Sorry for stupid question - could you please
tell what changed as the result, i.e. what
can be done now what was not possible to do?

RegisterCustomFlowNode<CameraControllerFlowNode>(engine, "CameraControllerFlowNode"); engine->SetDefaultNamespace("CameraControllerFlowNode"); engine->RegisterEnum("InputPort"); engine->RegisterEnumValue("InputPort", "IN_CAMERA_NODE", CameraControllerFlowNode::IN_CAMERA_NODE); engine->RegisterEnumValue("InputPort", "IN_MOUSE_SENSITIVITY", CameraControllerFlowNode::IN_MOUSE_SENSITIVITY); engine->SetDefaultNamespace("");

allows write CameraControllerFlowNode::IN_CAMERA_NODE and CameraControllerFlowNode::IN_MOUSE_SENSITIVITY in AngelScript (enum moved from global name space to class namespace)

Is it possible to register such values directly in AngelScript or not?

Yes, angelcode.com/angelscript/sd … d2a861af18

But for register simple consts (not enums) I not found way (it required pointer)
angelcode.com/angelscript/sd … 4812013169