Nasal String wrapper and allow adding methods to string objects.

- Add nasal::String for wrapping Nasal string data and accessing
   string methods (which eg. could be exposed to Nasal)
 - Allow adding functions from C/C++ which are callable on
   Nasal strings.
This commit is contained in:
Thomas Geymayer
2013-01-23 01:09:57 +01:00
parent 53b9fd2110
commit e7f9486aa1
9 changed files with 334 additions and 3 deletions

View File

@@ -320,3 +320,27 @@ static int fromnum(double val, unsigned char* s)
*ptr = 0;
return ptr - s;
}
//------------------------------------------------------------------------------
static naRef string_methods;
static int init = 0; // As we can't use naNil() for static initialization we
// need a separate variable for saving whether we have
// already initialized.
//------------------------------------------------------------------------------
naRef naInit_string(naContext c)
{
string_methods = naNewHash(c);
init = 1;
return string_methods;
}
//------------------------------------------------------------------------------
naRef getStringMethods(naContext c)
{
if( !init )
return naNil();
return string_methods;
}