#ifndef CAMELLYA_STATE_H #define CAMELLYA_STATE_H #include "value.h" #include #include namespace camellya { // Main state class - similar to lua_State class CamellyaImpl; class Camellya { public: Camellya(); ~Camellya(); // Execute script from string bool do_string(const std::string &script); // Execute script from file bool do_file(const std::string &filename); // Register native function void register_function(const std::string &name, NativeFunction func); // Register built-in class for any type (including user native types) void register_builtin_class(const std::string &type_name, std::shared_ptr klass); // Get global variable ValuePtr get_global(const std::string &name); // Set global variable void set_global(const std::string &name, ValuePtr value); // Stack operations (Lua-like API) void push_number(double value); void push_string(const std::string &value); void push_bool(bool value); void push_nil(); void push_value(ValuePtr value); double to_number(int index); std::string to_string(int index); bool to_bool(int index); ValuePtr to_value(int index); int get_top() const; void set_top(int index); void pop(int n = 1); // Error handling const std::string &get_error() const; private: std::unique_ptr d; ValuePtr get_stack_value(int index); }; } // namespace camellya #endif // CAMELLYA_STATE_H