1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00

r8238: - fixed handling of NULL pointers from ejs

- added automatic creation of all constants in IDL as ejs variables
This commit is contained in:
Andrew Tridgell 2005-07-08 10:29:18 +00:00 committed by Gerald (Jerry) Carter
parent 5be26e7491
commit 9398b02e4b
4 changed files with 49 additions and 0 deletions

View File

@ -103,6 +103,9 @@ sub fn_prefix($)
sub EjsPullScalar($$$$$)
{
my ($e, $l, $var, $name, $env) = @_;
return if (util::has_property($e, "value"));
$var = get_pointer_to($var);
# have to handle strings specially :(
if ($e->{TYPE} eq "string") {
@ -116,9 +119,13 @@ sub EjsPullScalar($$$$$)
sub EjsPullPointer($$$$$)
{
my ($e, $l, $var, $name, $env) = @_;
pidl "\tif (ejs_pull_null(ejs, v, $name)) {\n";
pidl "\t$var = NULL;\n";
pidl "\t} else {\n";
pidl "\tEJS_ALLOC(ejs, $var);\n";
$var = get_value_of($var);
EjsPullElement($e, Ndr::GetNextLevel($e, $l), $var, $name, $env);
pidl "}\n";
}
###########################
@ -335,8 +342,12 @@ sub EjsPushString($$$$$)
sub EjsPushPointer($$$$$)
{
my ($e, $l, $var, $name, $env) = @_;
pidl "\tif (NULL == $var) {\n";
pidl "\tNDR_CHECK(ejs_push_null(ejs, v, $name));\n";
pidl "\t} else {\n";
$var = get_value_of($var);
EjsPushElement($e, Ndr::GetNextLevel($e, $l), $var, $name, $env);
pidl "}\n";
}
###########################
@ -540,6 +551,14 @@ sub EjsFunction($)
pidl "}\n\n";
}
###################
# handle a constant
sub EjsConst($)
{
my $const = shift;
$constants{$const->{NAME}} = $const->{VALUE};
}
#####################################################################
# parse the interface definitions
sub EjsInterface($)
@ -565,6 +584,10 @@ sub EjsInterface($)
push (@fns, $d->{NAME});
}
foreach my $d (@{$interface->{CONSTS}}) {
EjsConst($d);
}
pidl "void setup_ejs_$name(void)\n";
pidl "{\n";
foreach (@fns) {

View File

@ -406,3 +406,20 @@ NTSTATUS ejs_push_GUID(struct ejs_rpc *ejs,
NT_STATUS_HAVE_NO_MEMORY(guid);
return mprSetVar(v, name, mprCreateStringVar(guid, True));
}
NTSTATUS ejs_push_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
{
return mprSetVar(v, name, mprCreatePtrVar(NULL, name));
}
BOOL ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name)
{
v = mprGetVar(v, name);
if (v == NULL) {
return True;
}
if (v->type == MPR_TYPE_PTR && v->ptr == NULL) {
return True;
}
return False;
}

View File

@ -87,6 +87,8 @@ NTSTATUS ejs_pull_dom_sid(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, struct dom_sid *r);
NTSTATUS ejs_push_dom_sid(struct ejs_rpc *ejs,
struct MprVar *v, const char *name, const struct dom_sid *r);
NTSTATUS ejs_push_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name);
BOOL ejs_pull_null(struct ejs_rpc *ejs, struct MprVar *v, const char *name);
#define EJS_ALLOC_SIZE(ejs, s, size) do { \
(s) = talloc_size(ejs, size); \

View File

@ -172,10 +172,14 @@ void smb_setup_ejs_rpc(void)
void setup_ejs_rpcecho(void);
void setup_ejs_samr(void);
void setup_ejs_misc(void);
void setup_ejs_security(void);
ejsDefineCFunction(-1, "rpc_connect", ejs_rpc_connect, NULL, MPR_VAR_SCRIPT_HANDLE);
setup_ejs_rpcecho();
setup_ejs_samr();
setup_ejs_misc();
setup_ejs_security();
}
/*
@ -188,9 +192,12 @@ void smb_setup_ejs_rpc_constants(int eid)
void setup_ejs_constants_rpcecho(int);
void setup_ejs_constants_samr(int);
void setup_ejs_constants_misc(int);
void setup_ejs_constants_security(int);
setup_ejs_constants_rpcecho(eid);
setup_ejs_constants_samr(eid);
setup_ejs_constants_misc(eid);
setup_ejs_constants_security(eid);
v = mprCreatePtrVar(NULL, "NULL");
mprSetProperty(ejsGetGlobalObject(eid), "NULL", &v);