From b1243510793cd135f1464dcfeec0b7e88999d1a0 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Sat, 4 Jun 2005 03:32:18 +0000 Subject: [PATCH] r7261: Pass by reference is done in js via MPR_TYPE_OBJECT. Update argument parsing and example for resolveName(). (This used to be commit 1a4a54931733ebfa743401a184fe460c044427b4) --- source4/scripting/ejs/smbcalls.c | 9 +++++++-- testprogs/ejs/resolveName.js | 11 ++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/source4/scripting/ejs/smbcalls.c b/source4/scripting/ejs/smbcalls.c index 5d4c61b04b2..93496bd9c93 100644 --- a/source4/scripting/ejs/smbcalls.c +++ b/source4/scripting/ejs/smbcalls.c @@ -271,6 +271,11 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) goto done; } + if (argv[0]->type != MPR_TYPE_OBJECT) { + ejsSetErrorMsg(eid, "resolvename invalid arguments"); + goto done; + } + if (argv[1]->type != MPR_TYPE_STRING) { ejsSetErrorMsg(eid, "resolveName invalid arguments"); goto done; @@ -291,8 +296,8 @@ static int ejs_resolve_name(MprVarHandle eid, int argc, struct MprVar **argv) nt_status = resolve_name(&name, tmp_ctx, &reply_addr); if (NT_STATUS_IS_OK(nt_status)) { - mprDestroyAllVars(argv[0]); - *argv[0] = mprCreateStringVar(reply_addr, True); + mprSetPropertyValue(argv[0], "value", + mprCreateStringVar(reply_addr, 1)); } ejsSetReturnValue(eid, mprNTSTATUS(nt_status)); diff --git a/testprogs/ejs/resolveName.js b/testprogs/ejs/resolveName.js index c2d06b5c743..1619b69d69f 100644 --- a/testprogs/ejs/resolveName.js +++ b/testprogs/ejs/resolveName.js @@ -2,11 +2,12 @@ Demonstrate use of resolveName() js function */ -var result; -res = resolveName(result, "frogurt"); +var result = new Object(); -if (!res.is_ok) { - println(res.errstr); +res = resolveName(result, ARGV[0]); + +if (res.is_ok) { + println(result.value); } else { - println(result); + println(res.errstr); }