cppbind: some new methods and safer type check.

This commit is contained in:
Thomas Geymayer
2014-05-29 16:29:02 +02:00
parent a8e96997cb
commit dfdd1c6d5e
2 changed files with 16 additions and 22 deletions

View File

@@ -38,30 +38,24 @@ namespace nasal
args(args)
{}
bool isNumeric(size_t index) const
{
return (index < argc && naIsNum(args[index]));
#define SG_CTX_CHECK_ARG(name, check)\
bool is##name(size_t index) const\
{\
return (index < argc && naIs##check(args[index]));\
}
bool isString(size_t index) const
{
return (index < argc && naIsString(args[index]));
}
SG_CTX_CHECK_ARG(Code, Code)
SG_CTX_CHECK_ARG(CCode, CCode)
SG_CTX_CHECK_ARG(Func, Func)
SG_CTX_CHECK_ARG(Ghost, Ghost)
SG_CTX_CHECK_ARG(Hash, Hash)
SG_CTX_CHECK_ARG(Nil, Nil)
SG_CTX_CHECK_ARG(Numeric, Num)
SG_CTX_CHECK_ARG(Scalar, Scalar)
SG_CTX_CHECK_ARG(String, String)
SG_CTX_CHECK_ARG(Vector, Vector)
bool isHash(size_t index) const
{
return (index < argc && naIsHash(args[index]));
}
bool isVector(size_t index) const
{
return (index < argc && naIsVector(args[index]));
}
bool isGhost(size_t index) const
{
return (index < argc && naIsGhost(args[index]));
}
#undef SG_CTX_CHECK_ARG
void popFront(size_t num = 1)
{

View File

@@ -183,7 +183,7 @@ namespace nasal
_key(key)
{
assert(hash);
assert(!naIsNil(key));
assert(naIsScalar(key));
}
std::string getKey() const