NAME

OADL_AddExtern - Define an Extern entry point

SYNOPSIS

OADL_AddExtern(ctx, name, func)

DESCRIPTION

The ctx is the context pointer passed in to the OADL_xxx initialization export function of an external system library. The name is the null-terminated UTF-8 name of the Extern to be defined, including a namespace:: prefix if appropriate. The func is the C function to call when an OADL program calls the defined Extern. It should have a function prototype compatible with this typedef:

typedef int (*OADL_Extern_fp)(void *ctx, OadlVar *pRes,
                              int nargs, const OadlVar *args);

This function is required for every Extern defined by an OADL system library. If a function is not provided for a given Extern, an attempt to call that Extern will result in an ExternCheck error being thrown.

RETURN VALUE

Returns 1 if the Extern was successfully added, or 0 otherwise. Possible reasons for failure include:

EXAMPLE

int OADL_foo(void *ctx, OADL_FindProc_fp findProc)
{
    OADL_AddExtern_fp OADL_AddExtern;
    extern int foo_bar(void *ctx, OadlVar *pRes, int nargs, const OadlVar *args);

    if (!findProc(ctx, "OADL_AddExtern",
                   OADL_SYS_VER, (OADLproc *) &OADL_AddExtern))
    {
        return 0;
    }
    if (!OADL_AddExtern(ctx, "foo::bar", foo_bar)) {
        return 0;
    }
}

SEE ALSO

OADL_xxx