1
0
Fork 0

Expose String::ends_with to Nasal

This commit is contained in:
Thomas Geymayer 2013-07-15 22:26:51 +02:00
parent ba088d9f1e
commit 63f19db028

View file

@ -59,6 +59,18 @@ static naRef f_starts_with(naContext c, naRef me, int argc, naRef* args)
return naNum( str.starts_with(rhs) );
}
/**
* Check whether string ends with other string
*/
static naRef f_ends_with(naContext c, naRef me, int argc, naRef* args)
{
nasal::CallContext ctx(c, argc, args);
nasal::String str = nasal::from_nasal<nasal::String>(c, me),
rhs = ctx.requireArg<nasal::String>(0);
return naNum( str.ends_with(rhs) );
}
/**
* Helper to convert size_t position/npos to Nasal conventions (-1 == npos)
*/
@ -125,6 +137,7 @@ naRef initNasalString(naRef globals, naRef string, naContext c, naRef gcSave)
string_module.set("compare", f_compare);
string_module.set("starts_with", f_starts_with);
string_module.set("ends_with", f_ends_with);
string_module.set("find", f_find);
string_module.set("find_first_of", f_find_first_of);
string_module.set("find_first_not_of", f_find_first_not_of);