Back to index

lightning-sunbird  0.9+nobinonly
Classes | Typedefs | Functions | Variables
jsj_JavaMember.c File Reference
#include <stdlib.h>
#include <string.h>
#include "jsj_private.h"

Go to the source code of this file.

Classes

struct  JavaMethodOrFieldValue

Typedefs

typedef struct
JavaMethodOrFieldValue 
JavaMethodOrFieldValue

Functions

JSObjectjsj_CreateJavaMember (JSContext *cx, jsval method_val, jsval field_val)
 JavaMember_finalize (JSContext *cx, JSObject *obj)
 JavaMember_convert (JSContext *cx, JSObject *obj, JSType type, jsval *vp)
 JavaMember_Call (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
JSBool jsj_init_JavaMember (JSContext *cx, JSObject *global_obj)

Variables

JSClass JavaMember_class

Class Documentation

struct JavaMethodOrFieldValue

Definition at line 67 of file jsj_JavaMember.c.

Class Members
jsval field_val
jsval method_val

Typedef Documentation


Function Documentation

JavaMember_Call ( JSContext cx,
JSObject obj,
uintN  argc,
jsval argv,
jsval rval 
)

Definition at line 154 of file jsj_JavaMember.c.

{
    JS_ASSERT(0);
    return JS_TRUE;
}
JavaMember_convert ( JSContext cx,
JSObject obj,
JSType  type,
jsval vp 
)

Definition at line 114 of file jsj_JavaMember.c.

{
    JavaMethodOrFieldValue *member_val;
        
    member_val = JS_GetPrivate(cx, obj);
    if (!member_val) {
        if (type == JSTYPE_OBJECT) {
            *vp = OBJECT_TO_JSVAL(obj);
            return JS_TRUE;
        }
        
        JS_ReportError(cx, "illegal operation on JavaObject prototype object");
        return JS_FALSE;
    }

    switch (type) {
    case JSTYPE_VOID:
    case JSTYPE_STRING:
    case JSTYPE_NUMBER:
    case JSTYPE_BOOLEAN:
    case JSTYPE_OBJECT:
        *vp = member_val->field_val;
        return JS_TRUE;

    case JSTYPE_FUNCTION:
        *vp = member_val->method_val;
        return JS_TRUE;

    default:
        JS_ASSERT(0);
        return JS_FALSE;
    }
}

Here is the call graph for this function:

JavaMember_finalize ( JSContext cx,
JSObject obj 
)

Definition at line 99 of file jsj_JavaMember.c.

{
    JavaMethodOrFieldValue *member_val;

    member_val = JS_GetPrivate(cx, obj);
    if (!member_val)
        return;

    JS_RemoveRoot(cx, &member_val->method_val);
    if (JSVAL_IS_GCTHING(member_val->field_val))
        JS_RemoveRoot(cx, &member_val->field_val);
    JS_free(cx, member_val);
}

Here is the call graph for this function:

JSObject* jsj_CreateJavaMember ( JSContext cx,
jsval  method_val,
jsval  field_val 
)

Definition at line 73 of file jsj_JavaMember.c.

{
    JavaMethodOrFieldValue *member_val;
    JSObject *JavaMember_obj;
    
    member_val = (JavaMethodOrFieldValue *)JS_malloc(cx, sizeof(*member_val));
    if (!member_val)
        return NULL;
    
    JavaMember_obj = JS_NewObject(cx, &JavaMember_class, 0, 0);
    if (!JavaMember_obj) {
        JS_free(cx, member_val);
        return NULL;
    }

    JS_SetPrivate(cx, JavaMember_obj, (void *)member_val);
    member_val->method_val = method_val;
    JS_AddNamedRoot(cx, &member_val->method_val, "&member_val->method_val");
    member_val->field_val = field_val;
    if (JSVAL_IS_GCTHING(field_val))
        JS_AddNamedRoot(cx, &member_val->field_val, "&member_val->field_val");

    return JavaMember_obj;
}

Here is the call graph for this function:

Here is the caller graph for this function:

JSBool jsj_init_JavaMember ( JSContext cx,
JSObject global_obj 
)

Definition at line 177 of file jsj_JavaMember.c.

{
    if (!JS_InitClass(cx, global_obj, 
        0, &JavaMember_class, 0, 0,
        0, 0,
        0, 0))
        return JS_FALSE;

    return JS_TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation