nim-lang / RFCs

A repository for your Nim proposals.
135 stars 26 forks source link

add ability to generate cpp classes, #421

Open tbutton2005 opened 5 years ago

tbutton2005 commented 5 years ago

add ability to generate cpp classes, like this:

class MyApp : public Urho3D::Application
{
public:
    MyApp(Context* context) :
        Application(context)
    {
    }
    virtual void Setup()
    {
        // Called before engine initialization. engineParameters_ member variable can be modified here
    }
    virtual void Start()
    {
        // Called after engine initialization. Setup application & subscribe to events here
        Urho3D::Object::SubscribeToEvent(Urho3D::E_KEYDOWN, URHO3D_HANDLER(MyApp, HandleKeyDown));
    }
    virtual void Stop()
    {
        // Perform optional cleanup after main loop has terminated
    }
    void HandleKeyDown(StringHash eventType, VariantMap& eventData)
    {
        using namespace KeyDown;
        // Check for pressing ESC. Note the engine_ member variable for convenience access to the Engine object
        int key = eventData[P_KEY].GetInt();
        if (key == KEY_ESCAPE)
            engine_->Exit();
    }
};
mratsim commented 5 years ago

This should be in the RFCs repo https://github.com/nim-lang/RFCs. Can you recreate it there?

Varriount commented 2 years ago

Isn't this already done via the CPP backend?