Added introspecition/classification of types
This commit is contained in:
@@ -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);
|
||||||
|
@@ -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;
|
||||||
};
|
};
|
||||||
|
7
unittests/classification.chai
Normal file
7
unittests/classification.chai
Normal 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());
|
6
unittests/classification.txt
Normal file
6
unittests/classification.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
true
|
||||||
|
false
|
||||||
|
true
|
||||||
|
false
|
||||||
|
false
|
||||||
|
true
|
Reference in New Issue
Block a user