/*
 * 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
}


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;


}
