/*
    Rangarajan Krishnamoorthy, August 7, 2021
    Testing C++/Ring Interface
*/

extern "C" {
#include "ring.h"
}

class RingEnv {
public:
    RingEnv() {
        p_state = ring_state_init();
    }
    ~RingEnv() {
        ring_state_delete(p_state);
    }
    void execCode(const char* code) {
        ring_state_runcode(p_state, code);
    }
    // Implement other wrappers...
    // ......
private:
    RingState* p_state;
};

int main()
{
    // Create a Ring environment
    RingEnv ring1;
    ring1.execCode("see 'Hello world from Ring language' + nl");
    // Set a variable in this environment
    ring1.execCode("x1 = 100 see 'x1 (ring1) = ' + x1 + nl");

    // Create another Ring environment
    RingEnv ring2;
    // Set a variable with same name in this (different) environment
    ring2.execCode("x1 = 200 see 'x1 (ring2) = ' + x1 + nl");

    // Is the first variable affected? No.
    ring1.execCode("see 'x1 (ring1) = ' + x1 + nl");
}



