X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FScripting%2FNasalString.cxx;h=fe937a0aa0a96bc680352a381b8dc1785d3e449b;hb=9c63b7713307eb4db9f6df7959fe83977f561c42;hp=331c75ffb6ab53a7b1d1fc6ae69c306148f159a7;hpb=5c42071fbbd73bb7dc4bcf03e028d923017ea6b7;p=flightgear.git diff --git a/src/Scripting/NasalString.cxx b/src/Scripting/NasalString.cxx index 331c75ffb..fe937a0aa 100644 --- a/src/Scripting/NasalString.cxx +++ b/src/Scripting/NasalString.cxx @@ -33,13 +33,12 @@ * compare(s) * compare(pos, len, s) */ -static naRef f_compare(naContext c, naRef me, int argc, naRef* args) +static naRef f_compare(const nasal::CallContext& ctx) { - nasal::CallContext ctx(c, argc, args); - nasal::String str = nasal::from_nasal(c, me), - rhs = ctx.requireArg(argc > 1 ? 2 : 0); - size_t pos = argc > 1 ? ctx.requireArg(1) : 0; - size_t len = argc > 1 ? ctx.requireArg(2) : 0; + nasal::String str = ctx.from_nasal(ctx.me), + rhs = ctx.requireArg(ctx.argc > 1 ? 2 : 0); + size_t pos = ctx.argc > 1 ? ctx.requireArg(1) : 0; + size_t len = ctx.argc > 1 ? ctx.requireArg(2) : 0; if( len == 0 ) len = nasal::String::npos; @@ -50,10 +49,9 @@ static naRef f_compare(naContext c, naRef me, int argc, naRef* args) /** * Check whether string starts with other string */ -static naRef f_starts_with(naContext c, naRef me, int argc, naRef* args) +static naRef f_starts_with(const nasal::CallContext& ctx) { - nasal::CallContext ctx(c, argc, args); - nasal::String str = nasal::from_nasal(c, me), + nasal::String str = ctx.from_nasal(ctx.me), rhs = ctx.requireArg(0); return naNum( str.starts_with(rhs) ); @@ -62,10 +60,9 @@ static naRef f_starts_with(naContext c, naRef me, int argc, naRef* args) /** * Check whether string ends with other string */ -static naRef f_ends_with(naContext c, naRef me, int argc, naRef* args) +static naRef f_ends_with(const nasal::CallContext& ctx) { - nasal::CallContext ctx(c, argc, args); - nasal::String str = nasal::from_nasal(c, me), + nasal::String str = ctx.from_nasal(ctx.me), rhs = ctx.requireArg(0); return naNum( str.ends_with(rhs) ); @@ -87,15 +84,14 @@ naRef pos_to_nasal(size_t pos) * * find(c, pos = 0) */ -static naRef f_find(naContext c, naRef me, int argc, naRef* args) +static naRef f_find(const nasal::CallContext& ctx) { - nasal::CallContext ctx(c, argc, args); - nasal::String str = nasal::from_nasal(c, me), + nasal::String str = ctx.from_nasal(ctx.me), find = ctx.requireArg(0); size_t pos = ctx.getArg(1, 0); if( find.size() != 1 ) - naRuntimeError(c, "string::find: single character expected"); + naRuntimeError(ctx.c, "string::find: single character expected"); return pos_to_nasal( str.find(*find.c_str(), pos) ); } @@ -105,10 +101,9 @@ static naRef f_find(naContext c, naRef me, int argc, naRef* args) * * find_first_of(search, pos = 0) */ -static naRef f_find_first_of(naContext c, naRef me, int argc, naRef* args) +static naRef f_find_first_of(const nasal::CallContext& ctx) { - nasal::CallContext ctx(c, argc, args); - nasal::String str = nasal::from_nasal(c, me), + nasal::String str = ctx.from_nasal(ctx.me), find = ctx.requireArg(0); size_t pos = ctx.getArg(1, 0); @@ -120,10 +115,9 @@ static naRef f_find_first_of(naContext c, naRef me, int argc, naRef* args) * * find_first_not_of(search, pos = 0) */ -static naRef f_find_first_not_of(naContext c, naRef me, int argc, naRef* args) +static naRef f_find_first_not_of(const nasal::CallContext& ctx) { - nasal::CallContext ctx(c, argc, args); - nasal::String str = nasal::from_nasal(c, me), + nasal::String str = ctx.from_nasal(ctx.me), find = ctx.requireArg(0); size_t pos = ctx.getArg(1, 0);