1
0
Fork 0

Nasal: update for simgear changes.

This commit is contained in:
Thomas Geymayer 2014-07-21 00:26:54 +02:00
parent a428d611c3
commit a673f4a5f9
4 changed files with 22 additions and 30 deletions

View file

@ -140,9 +140,8 @@ typedef nasal::Ghost<FileDialogPtr> NasalFileDialog;
/**
* Create new FGFileDialog and get ghost for it.
*/
static naRef f_createFileDialog(naContext c, naRef me, int argc, naRef* args)
static naRef f_createFileDialog(const nasal::CallContext& ctx)
{
nasal::CallContext ctx(c, argc, args);
FGFileDialog::Usage usage = (FGFileDialog::Usage) ctx.requireArg<int>(0);
#if defined(SG_MAC)
@ -153,7 +152,7 @@ static naRef f_createFileDialog(naContext c, naRef me, int argc, naRef* args)
FileDialogPtr fd(new PUIFileDialog(usage));
#endif
return nasal::to_nasal(c, fd);
return ctx.to_nasal(fd);
}
void postinitNasalGUI(naRef globals, naContext c)

View file

@ -139,11 +139,10 @@ static naRef f_createWindow(const nasal::CallContext& ctx)
/**
* Get ghost for existing Canvas.
*/
static naRef f_getCanvas(naContext c, naRef me, int argc, naRef* args)
static naRef f_getCanvas(const nasal::CallContext& ctx)
{
nasal::CallContext ctx(c, argc, args);
SGPropertyNode& props = *ctx.requireArg<SGPropertyNode*>(0);
CanvasMgr& canvas_mgr = requireCanvasMgr(c);
CanvasMgr& canvas_mgr = requireCanvasMgr(ctx.c);
sc::CanvasPtr canvas;
if( canvas_mgr.getPropertyRoot() == props.getParent() )
@ -162,7 +161,7 @@ static naRef f_getCanvas(naContext c, naRef me, int argc, naRef* args)
canvas = canvas_mgr.getCanvas( props.getIntValue("index") );
}
return nasal::to_nasal(c, canvas);
return ctx.to_nasal(canvas);
}
naRef f_canvasCreateGroup(sc::Canvas& canvas, const nasal::CallContext& ctx)

View file

@ -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<nasal::String>(c, me),
rhs = ctx.requireArg<nasal::String>(argc > 1 ? 2 : 0);
size_t pos = argc > 1 ? ctx.requireArg<int>(1) : 0;
size_t len = argc > 1 ? ctx.requireArg<int>(2) : 0;
nasal::String str = ctx.from_nasal<nasal::String>(ctx.me),
rhs = ctx.requireArg<nasal::String>(ctx.argc > 1 ? 2 : 0);
size_t pos = ctx.argc > 1 ? ctx.requireArg<int>(1) : 0;
size_t len = ctx.argc > 1 ? ctx.requireArg<int>(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<nasal::String>(c, me),
nasal::String str = ctx.from_nasal<nasal::String>(ctx.me),
rhs = ctx.requireArg<nasal::String>(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<nasal::String>(c, me),
nasal::String str = ctx.from_nasal<nasal::String>(ctx.me),
rhs = ctx.requireArg<nasal::String>(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<nasal::String>(c, me),
nasal::String str = ctx.from_nasal<nasal::String>(ctx.me),
find = ctx.requireArg<nasal::String>(0);
size_t pos = ctx.getArg<int>(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<nasal::String>(c, me),
nasal::String str = ctx.from_nasal<nasal::String>(ctx.me),
find = ctx.requireArg<nasal::String>(0);
size_t pos = ctx.getArg<int>(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<nasal::String>(c, me),
nasal::String str = ctx.from_nasal<nasal::String>(ctx.me),
find = ctx.requireArg<nasal::String>(0);
size_t pos = ctx.getArg<int>(1, 0);

View file

@ -705,7 +705,7 @@ static naRef f_parsexml(naContext c, naRef me, int argc, naRef* args)
*/
static naRef f_parse_markdown(naContext c, naRef me, int argc, naRef* args)
{
nasal::CallContext ctx(c, argc, args);
nasal::CallContext ctx(c, me, argc, args);
return ctx.to_nasal(
simgear::SimpleMarkdown::parse(ctx.requireArg<std::string>(0))
);