Added introspecition/classification of types

This commit is contained in:
Jason Turner
2009-11-21 06:39:35 +00:00
parent 15ffbd200a
commit a0c6366479
4 changed files with 22 additions and 0 deletions

View File

@@ -530,6 +530,9 @@ namespace chaiscript
m->add(fun(&Boxed_Value::is_undef), "is_undef"); m->add(fun(&Boxed_Value::is_undef), "is_undef");
m->add(fun(&Boxed_Value::is_null), "is_null"); m->add(fun(&Boxed_Value::is_null), "is_null");
m->add(fun(&Boxed_Value::is_const), "is_const");
m->add(fun(&Boxed_Value::is_ref), "is_reference");
m->add(fun(&Boxed_Value::is_pointer), "is_pointer");
basic_constructors<bool>("bool", m); basic_constructors<bool>("bool", m);
operators::assign<bool>(m); operators::assign<bool>(m);

View File

@@ -335,6 +335,12 @@ namespace chaiscript
return m_data->m_is_ref; return m_data->m_is_ref;
} }
bool is_pointer() const
{
return !is_ref();
}
private: private:
boost::shared_ptr<Data> m_data; boost::shared_ptr<Data> m_data;
}; };

View File

@@ -0,0 +1,7 @@
print(1.is_const());
print(1.is_reference());
print(1.is_pointer());
print(1.is_null());
print(1.is_undef());
var i;
print(i.is_undef());

View File

@@ -0,0 +1,6 @@
true
false
true
false
false
true