Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
jsj_simpleapi.c File Reference
#include "jsjava.h"
#include "jsprf.h"
#include "jsutil.h"
#include <string.h>

Go to the source code of this file.

Functions

static JSJavaThreadStatedefault_map_js_context_to_jsj_thread (JSContext *cx, char **errp)
static JSContextdefault_map_jsj_thread_to_js_context (JSJavaThreadState *jsj_env, JNIEnv *jEnv, char **errp)
static JSObjectdefault_map_java_object_to_js_object (JNIEnv *jEnv, void *hint, char **errp)
static JSBool JS_DLL_CALLBACK default_create_java_vm (SystemJavaVM **jvm, JNIEnv **initialEnv, void *initargs)
static JSBool JS_DLL_CALLBACK default_destroy_java_vm (SystemJavaVM *jvm, JNIEnv *initialEnv)
static JNIEnv *JS_DLL_CALLBACK default_attach_current_thread (SystemJavaVM *jvm)
static JSBool JS_DLL_CALLBACK default_detach_current_thread (SystemJavaVM *jvm, JNIEnv *env)
static SystemJavaVM
*JS_DLL_CALLBACK 
default_get_java_vm (JNIEnv *env)
JSBool JSJ_SimpleInit (JSContext *cx, JSObject *global_obj, SystemJavaVM *java_vm, const char *classpath)
 JSJ_SimpleShutdown ()

Variables

static JSJavaVMthe_jsj_vm = NULL
static JSContextthe_cx = NULL
static JSJavaThreadStatethe_jsj_thread = NULL
static JSObjectthe_global_js_obj = NULL
JSJCallbacks jsj_default_callbacks

Function Documentation

Definition at line 128 of file jsj_simpleapi.c.

{
    JavaVM* java_vm = (JavaVM*)jvm;
    JNIEnv* env = NULL;
    (*java_vm)->AttachCurrentThread(java_vm, &env, NULL);
    return env;
}
static JSBool JS_DLL_CALLBACK default_create_java_vm ( SystemJavaVM **  jvm,
JNIEnv **  initialEnv,
void initargs 
) [static]

Definition at line 84 of file jsj_simpleapi.c.

{
    jint err;
    const char* user_classpath = (const char*)initargs;
    char* full_classpath = NULL;

    /* No Java VM supplied, so create our own */
    JDK1_1InitArgs vm_args;
    memset(&vm_args, 0, sizeof(vm_args));

    /* Magic constant indicates JRE version 1.1 */
    vm_args.version = 0x00010001;
    JNI_GetDefaultJavaVMInitArgs(&vm_args);

    /* Prepend the classpath argument to the default JVM classpath */
    if (user_classpath) {
#if defined(XP_UNIX) || defined(XP_BEOS)
        full_classpath = JS_smprintf("%s:%s", user_classpath, vm_args.classpath);
#else
        full_classpath = JS_smprintf("%s;%s", user_classpath, vm_args.classpath);
#endif
        if (!full_classpath) {
            return JS_FALSE;
        }
        vm_args.classpath = (char*)full_classpath;
    }

    err = JNI_CreateJavaVM((JavaVM**)jvm, initialEnv, &vm_args);
    
    if (full_classpath)
        JS_smprintf_free(full_classpath);
    
    return err == 0;
}

Here is the call graph for this function:

static JSBool JS_DLL_CALLBACK default_destroy_java_vm ( SystemJavaVM jvm,
JNIEnv initialEnv 
) [static]

Definition at line 120 of file jsj_simpleapi.c.

{
    JavaVM* java_vm = (JavaVM*)jvm;
    jint err = (*java_vm)->DestroyJavaVM(java_vm);
    return err == 0;
}

Definition at line 137 of file jsj_simpleapi.c.

{
    JavaVM* java_vm = (JavaVM*)jvm;
    /* assert that env is the JNIEnv of the current thread */
    jint err = (*java_vm)->DetachCurrentThread(java_vm);
    return err == 0;
}

Definition at line 146 of file jsj_simpleapi.c.

{
    JavaVM* java_vm = NULL;
    (*env)->GetJavaVM(env, &java_vm);
    return (SystemJavaVM*)java_vm;
}
static JSObject* default_map_java_object_to_js_object ( JNIEnv jEnv,
void hint,
char **  errp 
) [static]

Definition at line 78 of file jsj_simpleapi.c.

{
    return the_global_js_obj;
}
static JSJavaThreadState* default_map_js_context_to_jsj_thread ( JSContext cx,
char **  errp 
) [static]

Definition at line 59 of file jsj_simpleapi.c.

{
    return the_jsj_thread;
}
static JSContext* default_map_jsj_thread_to_js_context ( JSJavaThreadState jsj_env,
JNIEnv jEnv,
char **  errp 
) [static]

Definition at line 66 of file jsj_simpleapi.c.

{
    return the_cx;
}
JSBool JSJ_SimpleInit ( JSContext cx,
JSObject global_obj,
SystemJavaVM java_vm,
const char *  classpath 
)

Definition at line 179 of file jsj_simpleapi.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 211 of file jsj_simpleapi.c.

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

JSContext* the_cx = NULL [static]

Definition at line 53 of file jsj_simpleapi.c.

Definition at line 55 of file jsj_simpleapi.c.

Definition at line 54 of file jsj_simpleapi.c.

JSJavaVM* the_jsj_vm = NULL [static]

Definition at line 52 of file jsj_simpleapi.c.