bind native stuff
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%4055
This commit is contained in:
parent
fc5b0f37a0
commit
ec8dec1049
@ -247,5 +247,60 @@ int SP_GetPubVarsNum(sp_context_t *ctx, uint32_t *num)
|
|||||||
{
|
{
|
||||||
*num = ctx->plugin->info.pubvars_num;
|
*num = ctx->plugin->info.pubvars_num;
|
||||||
|
|
||||||
|
return SP_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SP_BindNatives(sp_context_t *ctx, sp_nativeinfo_t *natives, unsigned int num, int overwrite)
|
||||||
|
{
|
||||||
|
uint32_t i, j, max;
|
||||||
|
|
||||||
|
max = ctx->plugin->info.natives_num;
|
||||||
|
|
||||||
|
for (i=0; i<max; i++)
|
||||||
|
{
|
||||||
|
if (ctx->natives[i].status == SP_NATIVE_OKAY && !overwrite)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (j=0; (natives[j].name) && (!num || j<num); j++)
|
||||||
|
{
|
||||||
|
if (!strcmp(ctx->natives[i].name, natives[j].name))
|
||||||
|
{
|
||||||
|
ctx->natives[i].pfn = natives[j].func;
|
||||||
|
ctx->natives[i].status = SP_NATIVE_OKAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SP_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SP_BindNative(sp_context_t *ctx, sp_nativeinfo_t *native, uint32_t status)
|
||||||
|
{
|
||||||
|
uint32_t index, err;
|
||||||
|
|
||||||
|
if ((err = SP_FindNativeByName(ctx, native->name, &index)) != SP_ERR_NONE)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
ctx->natives[index].pfn = native->func;
|
||||||
|
ctx->natives[index].status = status;
|
||||||
|
|
||||||
|
return SP_ERR_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int SP_BindNativeToAny(sp_context_t *ctx, SPVM_NATIVE_FUNC native)
|
||||||
|
{
|
||||||
|
uint32_t nativesnum, i;
|
||||||
|
|
||||||
|
nativesnum = ctx->plugin->info.natives_num;
|
||||||
|
|
||||||
|
for (i=0; i<nativesnum; i++)
|
||||||
|
{
|
||||||
|
if (ctx->natives[i].status != SP_NATIVE_OKAY)
|
||||||
|
{
|
||||||
|
ctx->natives[i].pfn = native;
|
||||||
|
ctx->natives[i].status = SP_NATIVE_PENDING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return SP_ERR_NONE;
|
return SP_ERR_NONE;
|
||||||
}
|
}
|
@ -240,7 +240,7 @@ int SP_PushCellsFromArray(sp_context_t *ctx, cell_t array[], unsigned int numcel
|
|||||||
* Binds a list of native names and their function pointers to a context.
|
* Binds a list of native names and their function pointers to a context.
|
||||||
* If num is 0, the list is read until an entry with a NULL name is reached.
|
* If num is 0, the list is read until an entry with a NULL name is reached.
|
||||||
* All natives are assigned a status of SP_NATIVE_OKAY by default.
|
* All natives are assigned a status of SP_NATIVE_OKAY by default.
|
||||||
* If overwrite is non-zero, already registered arrays will be overwritten.
|
* If overwrite is non-zero, already registered natives will be overwritten.
|
||||||
*
|
*
|
||||||
* @param ctx Context pointer.
|
* @param ctx Context pointer.
|
||||||
* @param natives Array of natives.
|
* @param natives Array of natives.
|
||||||
@ -250,6 +250,8 @@ int SP_BindNatives(sp_context_t *ctx, sp_nativeinfo_t *natives, unsigned int num
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Binds a single native. Overwrites any existing bind.
|
* Binds a single native. Overwrites any existing bind.
|
||||||
|
* If the context does not contain the native that will be binded the function will return
|
||||||
|
* with a SP_ERR_NOT_FOUND error.
|
||||||
*
|
*
|
||||||
* @param ctx Context pointer.
|
* @param ctx Context pointer.
|
||||||
* @param native Pointer to native.
|
* @param native Pointer to native.
|
||||||
@ -263,7 +265,7 @@ int SP_BindNative(sp_context_t *ctx, sp_nativeinfo_t *native, uint32_t status);
|
|||||||
*
|
*
|
||||||
* @param ctx Context pointer.
|
* @param ctx Context pointer.
|
||||||
*/
|
*/
|
||||||
int SP_BindNativeToAny(sp_context_t *ctx, sp_nativeinfo_t *native);
|
int SP_BindNativeToAny(sp_context_t *ctx, SPVM_NATIVE_FUNC native);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes a public function in a context.
|
* Executes a public function in a context.
|
||||||
|
Loading…
Reference in New Issue
Block a user