/* * Context.cpp * * Created on: Dec 30, 2012 * Author: att */ #include "Context.h" Context::Context(std::string name) { // TODO Auto-generated constructor stub this->index = 0; this->name = name; } Context::~Context() { // TODO Auto-generated destructor stub } bool Context::contains_function(std::string name) { return contains_sfunction(name) || contains_nfunction(name); } bool Context::contains_sfunction(std::string name) { return this->registered_sfunctions.count(name) == 1; } bool Context::contains_nfunction(std::string name) { return this->registered_functions.count(name); } void Context::register_function(std::string name, PointerToNativeFunction f) { registered_functions[name] = f; } void Context::register_function(std::string name, SenchaFunction * f) { registered_sfunctions[name] = f; } void Context::add(std::string name, SenchaObject object) { object_store[name] = object; } SenchaObject Context::get(std::string name) { if(object_store.count(name) != 0) return object_store[name]; else return SenchaObject(); } std::string Context::debug() { std::string debug_note = ""; for( auto iter = this->object_store.begin(); iter != this->object_store.end(); iter++) { debug_note += "Context: " + (*iter).second.repr() + ": " + (*iter).first + " " + "\n"; } return debug_note; }