Merge branch 'master' into 2011-09-09-CxScript

Conflicts:
	include/chaiscript/language/chaiscript_eval.hpp
This commit is contained in:
Jason Turner 2012-01-30 09:10:43 -07:00
commit b615d2a423
3 changed files with 19 additions and 16 deletions

View File

@ -43,20 +43,6 @@ namespace chaiscript
namespace detail
{
struct Dynamic_Object_Attribute
{
static Boxed_Value func(const std::string &t_type_name, const std::string &t_attr_name,
Dynamic_Object &t_do)
{
if (t_do.get_type_name() != t_type_name)
{
throw exception::bad_boxed_cast("Dynamic object type mismatch");
}
return t_do.get_attr(t_attr_name);
}
};
/**
* A Proxy_Function implementation designed for calling a function
* that is automatically guarded based on the first param based on the

View File

@ -1182,8 +1182,16 @@ namespace chaiscript
virtual ~Attr_Decl_AST_Node() {}
virtual Boxed_Value eval_internal(chaiscript::detail::Dispatch_Engine &t_ss){
try {
t_ss.add(fun(std::function<Boxed_Value (dispatch::Dynamic_Object &)>(std::bind(&dispatch::detail::Dynamic_Object_Attribute::func, this->children[0]->text,
this->children[1]->text, std::placeholders::_1))), this->children[1]->text);
t_ss.add(Proxy_Function
(new dispatch::detail::Dynamic_Object_Function(
this->children[0]->text,
fun(std::function<Boxed_Value (dispatch::Dynamic_Object &)>(std::bind(&dispatch::Dynamic_Object::get_attr,
std::placeholders::_1,
this->children[1]->text
)))
)
), this->children[1]->text);
}
catch (const exception::reserved_word_error &) {

View File

@ -0,0 +1,9 @@
attr bob::z
def bob::bob() { this.z = 10 }
attr bob2::z
def bob2::bob2() { this.z = 12 }
var b = bob();
var b2 = bob2();