From 63f19db0285a2df916d17d98b4fc664239e5d1de Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Mon, 15 Jul 2013 22:26:51 +0200 Subject: [PATCH] Expose String::ends_with to Nasal --- src/Scripting/NasalString.cxx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Scripting/NasalString.cxx b/src/Scripting/NasalString.cxx index df29b862b..c3aaf609e 100644 --- a/src/Scripting/NasalString.cxx +++ b/src/Scripting/NasalString.cxx @@ -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(c, me), + rhs = ctx.requireArg(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); -- 2.39.5