diff --git a/mozilla/js/ref/jsd/java/jre/jre.c b/mozilla/js/ref/jsd/java/jre/jre.c deleted file mode 100644 index 7ddcb05ff89..00000000000 --- a/mozilla/js/ref/jsd/java/jre/jre.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * @(#)jre.c 1.4 97/05/19 David Connelly - * - * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved. - * - * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, - * modify and redistribute this software in source and binary code form, - * provided that i) this copyright notice and license appear on all copies of - * the software; and ii) Licensee does not utilize the software in a manner - * which is disparaging to Sun. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY - * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR - * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE - * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING - * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS - * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, - * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER - * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF - * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * This software is not designed or intended for use in on-line control of - * aircraft, air traffic, aircraft navigation or aircraft communications; or in - * the design, construction, operation or maintenance of any nuclear - * facility. Licensee represents and warrants that it will not use or - * redistribute the Software for such purposes. - */ - -/* - * Portable JRE Support functions. - */ - -#include -#include -#include -#include "jre.h" - -/* - * Exits the runtime with the specified error message. - */ -void -JRE_FatalError(JNIEnv *env, const char *msg) -{ - if ((*env)->ExceptionOccurred(env)) { - (*env)->ExceptionDescribe(env); - } - (*env)->FatalError(env, msg); -} - -/* - * Parses a runtime version string. Returns 0 if the successful, otherwise - * returns -1 if the format of the version string was invalid. - */ -jint -JRE_ParseVersion(const char *ver, char **majorp, char **minorp, char **microp) -{ - int n1 = 0, n2 = 0, n3 = 0; - - sscanf(ver, "%*[0-9]%n.%*[0-9]%n.%*[0-9a-zA-Z]%n", &n1, &n2, &n3); - if (n1 == 0 || n2 == 0) { - return -1; - } - if (n3 != 0) { - if (n3 != (int)strlen(ver)) { - return -1; - } - } else if (n2 != (int)strlen(ver)) { - return -1; - } - *majorp = JRE_Malloc(n1 + 1); - strncpy(*majorp, ver, n1); - (*majorp)[n1] = 0; - *minorp = JRE_Malloc(n2 - n1); - strncpy(*minorp, ver + n1 + 1, n2 - n1 - 1); - (*minorp)[n2 - n1 - 1] = 0; - if (n3 != 0) { - *microp = JRE_Malloc(n3 - n2); - strncpy(*microp, ver + n2 + 1, n3 - n2 - 1); - (*microp)[n3 - n2 - 1] = 0; - } - return 0; -} - -/* - * Creates a version number string from the specified major, minor, and - * micro version numbers. - */ -char * -JRE_MakeVersion(const char *major, const char *minor, const char *micro) -{ - char *ver = 0; - - if (major != 0 && minor != 0) { - int len = strlen(major) + strlen(minor); - if (micro != 0) { - ver = JRE_Malloc(len + strlen(micro) + 3); - sprintf(ver, "%s.%s.%s", major, minor, micro); - } else { - ver = JRE_Malloc(len + 2); - sprintf(ver, "%s.%s", major, minor); - } - } - return ver; -} - -/* - * Allocate memory or die. - */ -void * -JRE_Malloc(size_t size) -{ - void *p = malloc(size); - if (p == 0) { - perror("malloc"); - exit(1); - } - return p; -} diff --git a/mozilla/js/ref/jsd/java/jre/jre.h b/mozilla/js/ref/jsd/java/jre/jre.h deleted file mode 100644 index 177c870b733..00000000000 --- a/mozilla/js/ref/jsd/java/jre/jre.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * @(#)jre.h 1.7 97/05/19 David Connelly - * - * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved. - * - * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, - * modify and redistribute this software in source and binary code form, - * provided that i) this copyright notice and license appear on all copies of - * the software; and ii) Licensee does not utilize the software in a manner - * which is disparaging to Sun. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY - * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR - * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE - * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING - * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS - * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, - * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER - * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF - * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * This software is not designed or intended for use in on-line control of - * aircraft, air traffic, aircraft navigation or aircraft communications; or in - * the design, construction, operation or maintenance of any nuclear - * facility. Licensee represents and warrants that it will not use or - * redistribute the Software for such purposes. - */ - -/* - * Portable JRE support functions. - */ - -#include -#include -#include - -#include "jre_md.h" - -/* - * Java runtime settings. - */ -typedef struct JRESettings { - char *javaHome; /* Java home directory */ - char *runtimeLib; /* Runtime shared library or DLL */ - char *classPath; /* Default class path */ - char *compiler; /* Just-in-time (JIT) compiler */ - char *majorVersion; /* Major version of runtime */ - char *minorVersion; /* Minor version of runtime */ - char *microVersion; /* Micro version of runtime */ -} JRESettings; - -/* - * JRE functions. - */ -void *JRE_LoadLibrary(const char *path); -void JRE_UnloadLibrary(void *handle); -jint JRE_GetDefaultJavaVMInitArgs(void *handle, void *vmargsp); -jint JRE_CreateJavaVM(void *handle, JavaVM **vmp, JNIEnv **envp, - void *vmargsp); -jint JRE_GetCurrentSettings(JRESettings *set); -jint JRE_GetSettings(JRESettings *set, const char *ver); -jint JRE_GetDefaultSettings(JRESettings *set); -jint JRE_ParseVersion(const char *version, - char **majorp, char **minorp, char **microp); -char *JRE_MakeVersion(const char *major, const char *minor, const char *micro); -void *JRE_Malloc(size_t size); -void JRE_FatalError(JNIEnv *env, const char *msg); -char *JRE_GetDefaultRuntimeLib(const char *dir); -char *JRE_GetDefaultClassPath(const char *dir); diff --git a/mozilla/js/ref/jsd/java/jre/win32/jre_md.c b/mozilla/js/ref/jsd/java/jre/win32/jre_md.c deleted file mode 100644 index a881b0d3d72..00000000000 --- a/mozilla/js/ref/jsd/java/jre/win32/jre_md.c +++ /dev/null @@ -1,290 +0,0 @@ -/* - * @(#)jre_md.c 1.6 97/05/15 David Connelly - * - * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved. - * - * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, - * modify and redistribute this software in source and binary code form, - * provided that i) this copyright notice and license appear on all copies of - * the software; and ii) Licensee does not utilize the software in a manner - * which is disparaging to Sun. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY - * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR - * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE - * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING - * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS - * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, - * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER - * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF - * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * This software is not designed or intended for use in on-line control of - * aircraft, air traffic, aircraft navigation or aircraft communications; or in - * the design, construction, operation or maintenance of any nuclear - * facility. Licensee represents and warrants that it will not use or - * redistribute the Software for such purposes. - */ - -/* - * Win32 specific JRE support functions - */ - -#include -#include -#include -#include "jre.h" - -#define JRE_KEY "Software\\JavaSoft\\Java Runtime Environment" -#define JDK_KEY "Software\\JavaSoft\\Java Development Kit" - -#define RUNTIME_LIB "javai.dll" - -/* From jre_main.c */ -extern jboolean debug; - -/* Forward Declarations */ -jint LoadSettings(JRESettings *set, HKEY key); -jint GetSettings(JRESettings *set, const char *version, const char *keyname); -char *GetStringValue(HKEY key, const char *name); - -/* - * Retrieve settings from registry for current runtime version. Returns - * 0 if successful otherwise returns -1 if no installed runtime was found - * or the registry data was invalid. - */ -jint -JRE_GetCurrentSettings(JRESettings *set) -{ - jint r = -1; - HKEY key; - - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) == 0) { - char *ver = GetStringValue(key, "CurrentVersion"); - if (ver != 0) { - r = JRE_GetSettings(set, ver); - } - free(ver); - RegCloseKey(key); - } - return r; -} - -/* - * Retrieves settings from registry for specified runtime version. - * Searches for either installed JRE and JDK runtimes. Returns 0 if - * successful otherwise returns -1 if requested version of runtime - * could not be found. - */ -jint -JRE_GetSettings(JRESettings *set, const char *version) -{ - if (GetSettings(set, version, JRE_KEY) != 0) { - return GetSettings(set, version, JDK_KEY); - } - return 0; -} - -jint -GetSettings(JRESettings *set, const char *version, const char *keyname) -{ - HKEY key; - int r = -1; - - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, KEY_READ, &key) == 0) { - char *major, *minor, *micro = 0; - if (JRE_ParseVersion(version, &major, &minor, µ) == 0) { - HKEY subkey; - char *ver = JRE_MakeVersion(major, minor, 0); - set->majorVersion = major; - set->minorVersion = minor; - if (RegOpenKeyEx(key, ver, 0, KEY_READ, &subkey) == 0) { - if ((r = LoadSettings(set, subkey)) == 0) { - if (micro != 0) { - if (set->microVersion == 0 || - strcmp(micro, set->microVersion) != 0) { - r = -1; - } - } - } - RegCloseKey(subkey); - } - free(ver); - } - RegCloseKey(key); - } - return r; -} - -/* - * Load runtime settings from specified registry key. Returns 0 if - * successful otherwise -1 if the registry data was invalid. - */ -static jint -LoadSettings(JRESettings *set, HKEY key) -{ - /* Full path name of JRE home directory (required) */ - set->javaHome = GetStringValue(key, "JavaHome"); - if (set->javaHome == 0) { - return -1; - } - /* Full path name of JRE runtime DLL */ - set->runtimeLib = GetStringValue(key, "RuntimeLib"); - if (set->runtimeLib == 0) { - set->runtimeLib = JRE_GetDefaultRuntimeLib(set->javaHome); - } - /* Class path setting to override default */ - set->classPath = GetStringValue(key, "ClassPath"); - if (set->classPath == 0) { - set->classPath = JRE_GetDefaultClassPath(set->javaHome); - } - /* Optional JIT compiler library name */ - set->compiler = GetStringValue(key, "Compiler"); - /* Release micro-version */ - set->microVersion = GetStringValue(key, "MicroVersion"); - return 0; -} - -/* - * Returns string data for the specified registry value name, or - * NULL if not found. - */ -static char * -GetStringValue(HKEY key, const char *name) -{ - DWORD type, size; - char *value = 0; - - if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0 && - type == REG_SZ ) { - value = JRE_Malloc(size); - if (RegQueryValueEx(key, name, 0, 0, value, &size) != 0) { - free(value); - value = 0; - } - } - return value; -} - -/* - * Returns default runtime settings based on location of this program. - * Makes best attempt at determining location of runtime. Returns 0 - * if successful or -1 if a runtime could not be found. - */ -jint -JRE_GetDefaultSettings(JRESettings *set) -{ - char buf[MAX_PATH], *bp; - int n; - - // Try to obtain default value for Java home directory based on - // location of this executable. - - if ((n = GetModuleFileName(0, buf, MAX_PATH)) == 0) { - return -1; - } - bp = buf + n; - while (*--bp != '\\') ; - bp -= 4; - if (bp < buf || strnicmp(bp, "\\bin", 4) != 0) { - return -1; - } - *bp = '\0'; - set->javaHome = strdup(buf); - - // Get default runtime library - set->runtimeLib = JRE_GetDefaultRuntimeLib(set->javaHome); - - // Get default class path - set->classPath = JRE_GetDefaultClassPath(set->javaHome); - - // Reset other fields since these are unknown - set->compiler = 0; - set->majorVersion = 0; - set->minorVersion = 0; - set->microVersion = 0; - - return 0; -} - -/* - * Return default runtime library for specified Java home directory. - */ -char * -JRE_GetDefaultRuntimeLib(const char *dir) -{ - char *cp = JRE_Malloc(strlen(dir) + sizeof(RUNTIME_LIB) + 8); - sprintf(cp, "%s\\bin\\" RUNTIME_LIB, dir); - return cp; -} - -/* - * Return default class path for specified Java home directory. - */ -char * -JRE_GetDefaultClassPath(const char *dir) -{ - char *cp = JRE_Malloc(strlen(dir) * 4 + 64); - sprintf(cp, "%s\\lib\\rt.jar;%s\\lib\\i18n.jar;%s\\lib\\classes.zip;" - "%s\\classes", dir, dir, dir, dir); - return cp; -} - -/* - * Loads the runtime library corresponding to 'libname' and returns - * an opaque handle to the library. - */ -void * -JRE_LoadLibrary(const char *path) -{ - return (void *)LoadLibrary(path); -} - -/* - * Unloads the runtime library associated with handle. - */ -void -JRE_UnloadLibrary(void *handle) -{ - FreeLibrary(handle); -} - -/* - * Loads default VM args for the specified runtime library handle. - */ -jint -JRE_GetDefaultJavaVMInitArgs(void *handle, void *vmargs) -{ - FARPROC proc = GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs"); - return proc != 0 ? ((*proc)(vmargs), 0) : -1; -} - -/* - * Creates a Java VM for the specified runtime library handle. - */ -jint -JRE_CreateJavaVM(void *handle, JavaVM **vmp, JNIEnv **envp, void *vmargs) -{ - FARPROC proc = GetProcAddress(handle, "JNI_CreateJavaVM"); - return proc != 0 ? (*proc)(vmp, envp, vmargs) : -1; -} - -/* - * Entry point for JREW (Windows-only) version of the runtime loader. - * This entry point is called when the '-subsystem:windows' linker - * option is used, and will cause the resulting executable to run - * detached from the console. - */ - -/** -* int WINAPI -* WinMain(HINSTANCE inst, HINSTANCE prevInst, LPSTR cmdLine, int cmdShow) -* { -* __declspec(dllimport) char **__initenv; -* -* __initenv = _environ; -* exit(main(__argc, __argv)); -* } -*/ diff --git a/mozilla/js/ref/jsd/java/jre/win32/jre_md.h b/mozilla/js/ref/jsd/java/jre/win32/jre_md.h deleted file mode 100644 index 40aac7bc36e..00000000000 --- a/mozilla/js/ref/jsd/java/jre/win32/jre_md.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * @(#)jre_md.h 1.1 97/05/19 David Connelly - * - * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved. - * - * Sun grants you ("Licensee") a non-exclusive, royalty free, license to use, - * modify and redistribute this software in source and binary code form, - * provided that i) this copyright notice and license appear on all copies of - * the software; and ii) Licensee does not utilize the software in a manner - * which is disparaging to Sun. - * - * This software is provided "AS IS," without a warranty of any kind. ALL - * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY - * IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR - * NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE - * LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING - * OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS - * LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, - * INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER - * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF - * OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * This software is not designed or intended for use in on-line control of - * aircraft, air traffic, aircraft navigation or aircraft communications; or in - * the design, construction, operation or maintenance of any nuclear - * facility. Licensee represents and warrants that it will not use or - * redistribute the Software for such purposes. - */ - -/* - * Win32 specific JRE support definitions - */ - -#define FILE_SEPARATOR '\\' -#define PATH_SEPARATOR ';' diff --git a/mozilla/js/ref/jsd/java/jsd_jntv.c b/mozilla/js/ref/jsd/java/jsd_jntv.c deleted file mode 100644 index ac3242580f0..00000000000 --- a/mozilla/js/ref/jsd/java/jsd_jntv.c +++ /dev/null @@ -1,1690 +0,0 @@ - -#include "jsdj.h" - -/***************************************************************************/ - -#define ASSERT_RETURN_VOID(x) \ -PR_BEGIN_MACRO \ - if(!(x)) \ - { \ - PR_ASSERT(0); \ - return; \ - } \ -PR_END_MACRO - -#define ASSERT_RETURN_VALUE(x,v)\ -PR_BEGIN_MACRO \ - if(!(x)) \ - { \ - PR_ASSERT(0); \ - return v; \ - } \ -PR_END_MACRO - -#define CHECK_RETURN_VOID(x) \ -PR_BEGIN_MACRO \ - if(!(x)) \ - { \ - return; \ - } \ -PR_END_MACRO - -#define CHECK_RETURN_VALUE(x,v) \ -PR_BEGIN_MACRO \ - if(!(x)) \ - { \ - return v; \ - } \ -PR_END_MACRO - -#define ASSERT_GOTO(x,w) \ -PR_BEGIN_MACRO \ - if(!(x)) \ - { \ - PR_ASSERT(0); \ - goto w; \ - } \ -PR_END_MACRO - -#define CHECK_GOTO(x,w) \ -PR_BEGIN_MACRO \ - if(!(x)) \ - { \ - goto w; \ - } \ -PR_END_MACRO - -#ifdef DEBUG -#define ASSERT_CLEAR_EXCEPTION(e) \ -PR_BEGIN_MACRO \ - if((*e)->ExceptionOccurred(e)) \ - { \ - (*e)->ExceptionDescribe(e); \ - PR_ASSERT(0); \ - } \ - (*e)->ExceptionClear(e); \ -PR_END_MACRO -#else /* ! DEBUG */ -#define ASSERT_CLEAR_EXCEPTION(e) (*e)->ExceptionClear(e) -#endif /* DEBUG */ - -#define CHECK_CLEAR_EXCEPTION(e) (*e)->ExceptionClear(e) - - -/***************************************************************************/ - -#ifdef DEBUG -void JSDJ_ASSERT_VALID_CONTEXT(JSDJContext* jsdjc) -{ - PR_ASSERT(jsdjc); -} -#endif /* DEBUG */ - -static JSDJContext* _HACK_CONTEXT = NULL; - -JSDJContext* -jsdj_CreateContext() -{ - JSDJContext* jsdjc; - jsdjc = (JSDJContext*) calloc(1, sizeof(JSDJContext)); - _HACK_CONTEXT = jsdjc; - return jsdjc; -} - -void -jsdj_DestroyContext(JSDJContext* jsdjc) -{ - free(jsdjc); - _HACK_CONTEXT = NULL; -} - -void -jsdj_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env) -{ - jsdjc->env = env; -} - -JNIEnv* -jsdj_GetJNIEnvForCurrentThread(JSDJContext* jsdjc) -{ - return jsdjc->env; -} - -void -jsdj_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc) -{ - jsdjc->jsdc = jsdc; -} - -JSDContext* -jsdj_GetJSDContext(JSDJContext* jsdjc) -{ - return jsdjc->jsdc; -} - -void -jsdj_SetStartStopCallback(JSDJContext* jsdjc, JSDJStartStopCallback cb, - void* closure) -{ - jsdjc->startStopCallback = cb; - jsdjc->startStopCallbackData = closure; -} - -static JSDJContext* -_getJSDJContext(JNIEnv *env) -{ - return _HACK_CONTEXT; -} - -/***************************************************************************/ -/***************************************************************************/ -/***************************************************************************/ -/***************************************************************************/ - -static jobject -_constructInteger(JNIEnv *env, long i) -{ - jclass clazz; - jmethodID mid; - - clazz = (*env)->FindClass(env, "java/lang/Integer"); - ASSERT_RETURN_VALUE(clazz, NULL); - mid = (*env)->GetMethodID(env, clazz, "", "(I)V"); - ASSERT_RETURN_VALUE(mid, NULL); - return (*env)->NewObject(env, clazz, mid, i); -} - -static jmethodID -_getObjectMethodID(JNIEnv *env, jobject o, const char* method, const char* sig) -{ - jclass clazz = (*env)->GetObjectClass(env, o); - ASSERT_RETURN_VALUE(clazz, NULL); - return (*env)->GetMethodID(env, clazz, method, sig ); -} - -static jobject -_putHash(JNIEnv *env, jobject tbl, jobject key, jobject ob) -{ - jmethodID mid = _getObjectMethodID(env, tbl, "put", - "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); - ASSERT_RETURN_VALUE(mid, NULL); - return (*env)->CallObjectMethod(env, tbl, mid, key, ob); -} - -static jobject -_getHash(JNIEnv *env, jobject tbl, jobject key) -{ - jmethodID mid = _getObjectMethodID(env, tbl, "get", - "(Ljava/lang/Object;)Ljava/lang/Object;"); - ASSERT_RETURN_VALUE(mid, NULL); - return (*env)->CallObjectMethod(env, tbl, mid, key); -} - -static jobject -_removeHash(JNIEnv *env, jobject tbl, jobject key) -{ - jmethodID mid = _getObjectMethodID(env, tbl, "remove", - "(Ljava/lang/Object;)Ljava/lang/Object;"); - ASSERT_RETURN_VALUE(mid, NULL); - return (*env)->CallObjectMethod(env, tbl, mid, key); -} - -static jobject -_constructJSStackFrameInfo(JNIEnv *env, - JSDStackFrameInfo* jsdframe, - jobject threadstate) -{ - jclass clazz; - jmethodID mid; - jobject frame; - - clazz = (*env)->FindClass(env, "netscape/jsdebug/JSStackFrameInfo"); - ASSERT_RETURN_VALUE(clazz, NULL); - mid = (*env)->GetMethodID(env, clazz, "", - "(Lnetscape/jsdebug/JSThreadState;)V"); - ASSERT_RETURN_VALUE(mid, NULL); - frame = (*env)->NewObject(env, clazz, mid, threadstate); - if( frame ) - { - jfieldID fid; - - fid = (*env)->GetFieldID(env, clazz, "_nativePtr", "I"); - ASSERT_RETURN_VALUE(fid, NULL); - (*env)->SetIntField(env, frame, fid, (long) jsdframe); - - /* XXX fill in additional fields... */ - - } - return frame; -} - - -static jobject -_constructJSThreadState(JNIEnv *env, - JSDStackFrameInfo* jsdframe, - JSDThreadState* jsdstate) -{ - jclass clazz; - jmethodID mid; - jobject threadState; - - clazz = (*env)->FindClass(env, "netscape/jsdebug/JSThreadState"); - ASSERT_RETURN_VALUE(clazz, NULL); - mid = (*env)->GetMethodID(env, clazz, "", - "()V"); - ASSERT_RETURN_VALUE(mid, NULL); - threadState = (*env)->NewObject(env, clazz, mid); - if( threadState ) - { - jfieldID fid; - - /* valid */ - fid = (*env)->GetFieldID(env, clazz, "valid", "Z"); - ASSERT_RETURN_VALUE(fid, NULL); - (*env)->SetBooleanField(env, threadState, fid, JNI_TRUE); - - /* currentFramePtr */ - fid = (*env)->GetFieldID(env, clazz, "currentFramePtr", "I"); - ASSERT_RETURN_VALUE(fid, NULL); - (*env)->SetIntField(env, threadState, fid, (long) jsdframe); - - /* nativeThreadState */ - fid = (*env)->GetFieldID(env, clazz, "nativeThreadState", "I"); - ASSERT_RETURN_VALUE(fid, NULL); - (*env)->SetIntField(env, threadState, fid, (long) jsdstate ); - - /* continueState */ - fid = (*env)->GetFieldID(env, clazz, "continueState", "I"); - ASSERT_RETURN_VALUE(fid, NULL); - (*env)->SetIntField(env, threadState, fid, DEBUG_STATE_RUN ); - - /* XXX fill in additional fields... */ - - } - return threadState; -} - -static jobject -_constructScript(JNIEnv *env, JSDContext* jsdc, JSDScript* jsdscript) -{ - jclass clazz; - jmethodID mid; - jobject script; - char* url = (char*)JSD_GetScriptFilename (jsdc, jsdscript); - char* function = (char*)JSD_GetScriptFunctionName (jsdc, jsdscript); - int base = JSD_GetScriptBaseLineNumber (jsdc, jsdscript); - int extent = JSD_GetScriptLineExtent (jsdc, jsdscript); - - if( ! url ) - { - return NULL; - /* url = ""; */ - } - - clazz = (*env)->FindClass(env, "netscape/jsdebug/Script"); - ASSERT_RETURN_VALUE(clazz, NULL); - mid = (*env)->GetMethodID(env, clazz, "", "()V"); - ASSERT_RETURN_VALUE(mid, NULL); - script = (*env)->NewObject(env, clazz, mid); - if( script ) - { - jfieldID fid; - - /* _url */ - fid = (*env)->GetFieldID(env, clazz, "_url", "Ljava/lang/String;"); - ASSERT_RETURN_VALUE(fid, NULL); - (*env)->SetObjectField(env, script, fid, - (*env)->NewStringUTF(env, url)); - - /* _function */ - fid = (*env)->GetFieldID(env, clazz, "_function", "Ljava/lang/String;"); - ASSERT_RETURN_VALUE(fid, NULL); - (*env)->SetObjectField(env, script, fid, - function ? (*env)->NewStringUTF(env, function) : NULL); - - /* _baseLineNumber */ - fid = (*env)->GetFieldID(env, clazz, "_baseLineNumber", "I"); - ASSERT_RETURN_VALUE(fid, NULL); - (*env)->SetIntField(env, script, fid, base); - - /* _lineExtent */ - fid = (*env)->GetFieldID(env, clazz, "_lineExtent", "I"); - ASSERT_RETURN_VALUE(fid, NULL); - (*env)->SetIntField(env, script, fid, extent); - - /* _nativePtr */ - fid = (*env)->GetFieldID(env, clazz, "_nativePtr", "I"); - ASSERT_RETURN_VALUE(fid, NULL); - (*env)->SetIntField(env, script, fid, (long)jsdscript); - - /* XXX fill in additional fields... */ - } - return script; -} - -static jobject -_constructJSPC(JNIEnv *env, jobject script, long pc) -{ - jclass clazz; - jmethodID mid; - jobject pcOb; - - clazz = (*env)->FindClass(env, "netscape/jsdebug/JSPC" ); - ASSERT_RETURN_VALUE(clazz, NULL); - mid = (*env)->GetMethodID(env, clazz, "", - "(Lnetscape/jsdebug/Script;I)V"); - ASSERT_RETURN_VALUE(mid, NULL); - pcOb = (*env)->NewObject(env, clazz, mid, script, pc); - /* XXX fill in additional fields... */ - return pcOb; -} - -static jobject -_constructJSSourceLocation(JNIEnv *env, jobject pc, long line) -{ - jclass clazz; - jmethodID mid; - jobject loc; - - clazz = (*env)->FindClass(env, "netscape/jsdebug/JSSourceLocation"); - ASSERT_RETURN_VALUE(clazz, NULL); - mid = (*env)->GetMethodID(env, clazz, "", - "(Lnetscape/jsdebug/JSPC;I)V"); - ASSERT_RETURN_VALUE(mid, NULL); - loc = (*env)->NewObject(env, clazz, mid, pc, line); - /* XXX fill in additional fields... */ - return loc; -} - -static jobject -_getScriptHook(JNIEnv *env, JSDJContext* jsdjc) -{ - jclass clazz; - jfieldID fid; - - clazz = (*env)->GetObjectClass(env, jsdjc->controller); - ASSERT_RETURN_VALUE(clazz, NULL); - fid = (*env)->GetFieldID(env, clazz, "scriptHook", - "Lnetscape/jsdebug/ScriptHook;"); - ASSERT_RETURN_VALUE(fid, NULL); - return (*env)->GetObjectField(env, jsdjc->controller, fid); -} - -static jobject -_getInterruptHook(JNIEnv *env, JSDJContext* jsdjc) -{ - jclass clazz; - jfieldID fid; - - clazz = (*env)->GetObjectClass(env, jsdjc->controller); - ASSERT_RETURN_VALUE(clazz, NULL); - fid = (*env)->GetFieldID(env, clazz, "interruptHook", - "Lnetscape/jsdebug/InterruptHook;"); - ASSERT_RETURN_VALUE(fid, NULL); - return (*env)->GetObjectField(env, jsdjc->controller, fid); -} - -static jobject -_getDebugBreakHook(JNIEnv *env, JSDJContext* jsdjc) -{ - jclass clazz; - jfieldID fid; - - clazz = (*env)->GetObjectClass(env, jsdjc->controller); - ASSERT_RETURN_VALUE(clazz, NULL); - fid = (*env)->GetFieldID(env, clazz, "debugBreakHook", - "Lnetscape/jsdebug/DebugBreakHook;"); - ASSERT_RETURN_VALUE(fid, NULL); - return (*env)->GetObjectField(env, jsdjc->controller, fid); -} - -static jobject -_getInstructionHook(JNIEnv *env, JSDJContext* jsdjc, jobject pc) -{ - jmethodID mid; - - mid = _getObjectMethodID(env, jsdjc->controller, "getInstructionHook0", - "(Lnetscape/jsdebug/PC;)Lnetscape/jsdebug/InstructionHook;"); - ASSERT_RETURN_VALUE(mid, NULL); - return (*env)->CallObjectMethod(env, jsdjc->controller, mid, pc); -} - -static jobject -_getErrorReporter(JNIEnv *env, JSDJContext* jsdjc) -{ - jclass clazz; - jfieldID fid; - - clazz = (*env)->GetObjectClass(env, jsdjc->controller); - ASSERT_RETURN_VALUE(clazz, NULL); - fid = (*env)->GetFieldID(env, clazz, "errorReporter", - "Lnetscape/jsdebug/JSErrorReporter;"); - ASSERT_RETURN_VALUE(fid, NULL); - return (*env)->GetObjectField(env, jsdjc->controller, fid); -} - -static jobject -_getScriptTable(JNIEnv *env, JSDJContext* jsdjc) -{ - jclass clazz; - jfieldID fid; - - clazz = (*env)->GetObjectClass(env, jsdjc->controller); - ASSERT_RETURN_VALUE(clazz, NULL); - fid = (*env)->GetFieldID(env, clazz, "scriptTable", - "Lnetscape/util/Hashtable;"); - ASSERT_RETURN_VALUE(fid, NULL); - return (*env)->GetObjectField(env, jsdjc->controller, fid); -} - -static jobject -_scriptObFromJSDScriptPtr(JNIEnv *env, JSDJContext* jsdjc, JSDScript* jsdscript) -{ - jobject tbl; - jobject key; - - tbl = _getScriptTable(env, jsdjc); - ASSERT_RETURN_VALUE(tbl, NULL); - key = _constructInteger(env,(long)jsdscript); - ASSERT_RETURN_VALUE(key, NULL); - return _getHash(env, tbl, key); -} - -static JSDThreadState* -_JSDThreadStateFromJSStackFrameInfo(JNIEnv *env, jobject frame) -{ - jclass clazz; - jfieldID fid; - jobject threadState; - - clazz = (*env)->GetObjectClass(env, frame); - ASSERT_RETURN_VALUE(clazz, NULL); - fid = (*env)->GetFieldID(env, clazz, "threadState", - "Lnetscape/jsdebug/ThreadStateBase;"); - ASSERT_RETURN_VALUE(fid, NULL); - threadState = (*env)->GetObjectField(env, frame, fid); - ASSERT_RETURN_VALUE(threadState, NULL); - - clazz = (*env)->GetObjectClass(env, threadState); - ASSERT_RETURN_VALUE(clazz, NULL); - fid = (*env)->GetFieldID(env, clazz, "nativeThreadState", "I"); - ASSERT_RETURN_VALUE(fid, NULL); - return (JSDThreadState*) (*env)->GetIntField(env, threadState, fid); -} - -static JSDStackFrameInfo* -_JSDStackFrameInfoFromJSStackFrameInfo(JNIEnv *env, jobject frame) -{ - jclass clazz; - jfieldID fid; - - clazz = (*env)->GetObjectClass(env, frame); - ASSERT_RETURN_VALUE(clazz, NULL); - fid = (*env)->GetFieldID(env, clazz, "_nativePtr", "I"); - ASSERT_RETURN_VALUE(fid, NULL); - return (JSDStackFrameInfo*) (*env)->GetIntField(env, frame, fid); -} - -static char* -_allocCString(JNIEnv *env, jstring str) -{ - jsize len; - char* buf; - - len = (*env)->GetStringUTFLength(env, str); - buf = malloc(len+1); - ASSERT_RETURN_VALUE(buf, NULL); - buf[0] = 0; - if(len) - { - const jbyte* temp = (*env)->GetStringUTFChars(env, str, NULL); - if(temp) - { - strncpy(buf, temp, len); - (*env)->ReleaseStringUTFChars(env, str, temp); - buf[len] = 0; - } - } - return buf; -} - - -static jstring -_NewStringUTF_No_Z(JNIEnv *env, const char* str, uintN len) -{ - jstring textOb; - char* temp; - - temp = malloc(len+1); - ASSERT_RETURN_VALUE(temp, NULL); - - strncpy(temp, str, len); - temp[len] = 0; - textOb = (*env)->NewStringUTF(env, temp); - free(temp); - return textOb; -} - -/***************************************************************************/ - -void PR_CALLBACK -_scriptHook(JSDContext* jsdc, - JSDScript* jsdscript, - JSBool creating, - void* callerdata) -{ - JNIEnv* env; - JSDJContext* jsdjc; - jobject script; - jobject tbl; - jobject key; - jobject hook; - jmethodID mid; - - jsdjc = (JSDJContext*) callerdata; - ASSERT_RETURN_VOID(jsdjc && jsdjc->controller); - - env = jsdj_GetJNIEnvForCurrentThread(jsdjc); - ASSERT_RETURN_VOID(env); - - ASSERT_CLEAR_EXCEPTION(env); - - tbl = _getScriptTable(env, jsdjc); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(tbl); - - key = _constructInteger(env, (long)jsdscript); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(key); - - hook = _getScriptHook(env, jsdjc); - CHECK_CLEAR_EXCEPTION(env); - - if( creating ) - { - script = _constructScript(env, jsdc, jsdscript); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(script); - - /* add it to the hash table */ - _putHash( env, tbl, key, script ); - ASSERT_CLEAR_EXCEPTION(env); - if( hook ) - { - /* call the hook */ - mid = _getObjectMethodID(env, hook, "justLoadedScript", - "(Lnetscape/jsdebug/Script;)V" ); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(mid); - (*env)->CallVoidMethod(env, hook, mid, script); - ASSERT_CLEAR_EXCEPTION(env); - } - } - else - { - /* find Java Object for Script */ - script = _getHash(env, tbl, key); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(script); - - /* remove it from the hash table */ - _removeHash(env, tbl, key); - ASSERT_CLEAR_EXCEPTION(env); - - if( hook ) - { - /* call the hook */ - mid = _getObjectMethodID(env, hook, "aboutToUnloadScript", - "(Lnetscape/jsdebug/Script;)V" ); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(mid); - (*env)->CallVoidMethod(env, hook, mid, script); - ASSERT_CLEAR_EXCEPTION(env); - } - - /* set the Script as invalid */ - mid = _getObjectMethodID(env, script, "_setInvalid", - "()V" ); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(mid); - (*env)->CallVoidMethod(env, script, mid); - ASSERT_CLEAR_EXCEPTION(env); - } -} - -/***************************************************************************/ -uintN PR_CALLBACK -_executionHook(JSDContext* jsdc, - JSDThreadState* jsdstate, - uintN type, - void* callerdata) -{ - JNIEnv* env; - JSDJContext* jsdjc; - JSDStackFrameInfo* jsdframe; - JSDScript* jsdscript; - jobject script; - jobject threadState; - jobject pcOb; - jobject tbl; - jobject key; - jobject hook; - jmethodID mid; - jfieldID fid; - jclass clazz; - int pc; - - jsdjc = (JSDJContext*) callerdata; - ASSERT_RETURN_VALUE(jsdjc && jsdjc->controller, JSD_HOOK_RETURN_HOOK_ERROR); - - env = jsdj_GetJNIEnvForCurrentThread(jsdjc); - ASSERT_RETURN_VALUE(env, JSD_HOOK_RETURN_HOOK_ERROR); - ASSERT_CLEAR_EXCEPTION(env); - - /* get the JSDStackFrameInfo */ - jsdframe = JSD_GetStackFrame(jsdc, jsdstate); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdframe, JSD_HOOK_RETURN_HOOK_ERROR); - - /* get the JSDScript */ - jsdscript = JSD_GetScriptForStackFrame(jsdc, jsdstate, jsdframe); - ASSERT_RETURN_VALUE(jsdscript, JSD_HOOK_RETURN_HOOK_ERROR); - - /* find Java Object for Script */ - - tbl = _getScriptTable(env, jsdjc); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(tbl, JSD_HOOK_RETURN_HOOK_ERROR); - - key = _constructInteger(env, (long)jsdscript); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(key, JSD_HOOK_RETURN_HOOK_ERROR); - - script = _getHash(env, tbl, key); - CHECK_CLEAR_EXCEPTION(env); - CHECK_RETURN_VALUE(script, JSD_HOOK_RETURN_HOOK_ERROR); - - /* generate a JSPC */ - pc = JSD_GetPCForStackFrame(jsdc, jsdstate, jsdframe); - pcOb = _constructJSPC(env, script, pc); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(pcOb, JSD_HOOK_RETURN_HOOK_ERROR); - - /* build a JSThreadState */ - threadState = _constructJSThreadState(env, jsdframe, jsdstate); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(threadState, JSD_HOOK_RETURN_HOOK_ERROR); - - /* find and call the appropriate Hook */ - if( JSD_HOOK_INTERRUPTED == type ) - { - /* clear the JSD level hook (must reset on next sendInterrupt0()*/ - JSD_ClearInterruptHook(jsdc); - - hook = _getInterruptHook(env, jsdjc); - CHECK_CLEAR_EXCEPTION(env); - CHECK_RETURN_VALUE(hook, JSD_HOOK_RETURN_HOOK_ERROR); - - /* call the hook */ - mid = _getObjectMethodID(env, hook, "aboutToExecute", - "(Lnetscape/jsdebug/ThreadStateBase;Lnetscape/jsdebug/PC;)V"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(mid, JSD_HOOK_RETURN_HOOK_ERROR); - (*env)->CallVoidMethod(env, hook, mid, threadState, pcOb); - ASSERT_CLEAR_EXCEPTION(env); - } - else if( JSD_HOOK_DEBUG_REQUESTED == type ) - { - hook = _getDebugBreakHook(env, jsdjc); - CHECK_CLEAR_EXCEPTION(env); - CHECK_RETURN_VALUE(hook, JSD_HOOK_RETURN_HOOK_ERROR); - - /* call the hook */ - mid = _getObjectMethodID(env, hook, "aboutToExecute", - "(Lnetscape/jsdebug/ThreadStateBase;Lnetscape/jsdebug/PC;)V"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(mid, JSD_HOOK_RETURN_HOOK_ERROR); - (*env)->CallVoidMethod(env, hook, mid, threadState, pcOb); - ASSERT_CLEAR_EXCEPTION(env); - } - else if( JSD_HOOK_BREAKPOINT == type ) - { - hook = _getInstructionHook(env, jsdjc, pcOb); - CHECK_CLEAR_EXCEPTION(env); - CHECK_RETURN_VALUE(hook, JSD_HOOK_RETURN_HOOK_ERROR); - - /* call the hook */ - mid = _getObjectMethodID(env, hook, "aboutToExecute", - "(Lnetscape/jsdebug/ThreadStateBase;)V"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(mid, JSD_HOOK_RETURN_HOOK_ERROR); - (*env)->CallVoidMethod(env, hook, mid, threadState); - ASSERT_CLEAR_EXCEPTION(env); - } - - /* should we abort? */ - - clazz = (*env)->GetObjectClass(env, threadState); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, JSD_HOOK_RETURN_CONTINUE); - - fid = (*env)->GetFieldID(env, clazz, "continueState", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, JSD_HOOK_RETURN_CONTINUE); - - if( DEBUG_STATE_THROW == (*env)->GetIntField(env, threadState, fid) ) - return JSD_HOOK_RETURN_ABORT; - - return JSD_HOOK_RETURN_CONTINUE; -} - -/***************************************************************************/ - -uintN PR_CALLBACK -_errorReporter( JSDContext* jsdc, - JSContext* cx, - const char* message, - JSErrorReport* report, - void* callerdata ) -{ - JNIEnv* env; - JSDJContext* jsdjc; - jmethodID mid; - jobject reporter; - jobject msg = NULL; - jobject filename = NULL; - int lineno = 0; - jobject linebuf = NULL; - int tokenOffset = 0; - int retval; - - jsdjc = (JSDJContext*) callerdata; - ASSERT_RETURN_VALUE(jsdjc && jsdjc->controller, JSD_ERROR_REPORTER_PASS_ALONG); - - env = jsdj_GetJNIEnvForCurrentThread(jsdjc); - ASSERT_RETURN_VALUE(env, JSD_ERROR_REPORTER_PASS_ALONG); - ASSERT_CLEAR_EXCEPTION(env); - - reporter = _getErrorReporter(env, jsdjc); - CHECK_CLEAR_EXCEPTION(env); - CHECK_RETURN_VALUE(reporter, JSD_ERROR_REPORTER_PASS_ALONG); - - if( message ) - msg = (*env)->NewStringUTF(env, message); - if( report && report->filename ) - filename = (*env)->NewStringUTF(env, report->filename); - if( report && report->linebuf ) - linebuf = (*env)->NewStringUTF(env, report->linebuf); - if( report ) - lineno = report->lineno; - if( report && report->linebuf && report->tokenptr ) - tokenOffset = report->tokenptr - report->linebuf; - - /* call the hook */ - mid = _getObjectMethodID(env, reporter, "reportError", - "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;I)I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(mid, JSD_HOOK_RETURN_HOOK_ERROR); - - retval = (*env)->CallIntMethod(env, reporter, mid, - msg, filename, lineno, linebuf, tokenOffset); - ASSERT_CLEAR_EXCEPTION(env); - return retval; -} - -/***************************************************************************/ -/* - * Class: netscape_jsdebug_DebugController - * Method: setInstructionHook0 - * Signature: (Lnetscape/jsdebug/PC;)V - */ -JNIEXPORT void JNICALL Java_netscape_jsdebug_DebugController_setInstructionHook0 - (JNIEnv *env, jobject self, jobject pcOb) -{ - jobject script; - JSDScript* jsdscript; - uintN pc; - JSDJContext* jsdjc; - jmethodID mid; - jclass clazz; - jfieldID fid; - - jsdjc = _getJSDJContext(env); - ASSERT_RETURN_VOID(jsdjc && jsdjc->jsdc && jsdjc->controller); - - mid = _getObjectMethodID(env, pcOb, "getScript", - "()Lnetscape/jsdebug/Script;"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(mid); - - script = (*env)->CallObjectMethod(env, pcOb, mid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(script); - - clazz = (*env)->FindClass(env, "netscape/jsdebug/Script"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(clazz); - - fid = (*env)->GetFieldID(env, clazz, "_nativePtr", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(fid); - - jsdscript = (JSDScript*) (*env)->GetIntField(env, script, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(jsdscript); - - mid = _getObjectMethodID(env, pcOb, "getPC", "()I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(mid); - - pc = (uintN) (*env)->CallIntMethod(env, pcOb, mid); - ASSERT_CLEAR_EXCEPTION(env); - - JSD_SetExecutionHook(jsdjc->jsdc, jsdscript, pc, _executionHook, jsdjc); -} - -/* - * Class: netscape_jsdebug_DebugController - * Method: sendInterrupt0 - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_netscape_jsdebug_DebugController_sendInterrupt0 - (JNIEnv *env, jobject self) -{ - JSDJContext* jsdjc; - - jsdjc = _getJSDJContext(env); - ASSERT_RETURN_VOID(jsdjc && jsdjc->jsdc && jsdjc->controller); - ASSERT_CLEAR_EXCEPTION(env); - JSD_SetInterruptHook(jsdjc->jsdc, _executionHook, jsdjc); -} - -/* - * Class: netscape_jsdebug_DebugController - * Method: _setController - * Signature: (Z)V - */ -JNIEXPORT void JNICALL Java_netscape_jsdebug_DebugController__1setController - (JNIEnv *env, jobject self, jboolean on) -{ - /* - ** XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX - ** NOTE: in Navigator we turn native debug support on and off in this - ** function. Here we just connect/disconnect from that support. - ** XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX - */ - - JSDJContext* jsdjc; - jclass clazz; - jfieldID fid; - - jsdjc = _getJSDJContext(env); - ASSERT_GOTO(jsdjc && jsdjc->jsdc, LABEL_FAILURE); - ASSERT_CLEAR_EXCEPTION(env); - - if(on) - { - jsdjc->controller = (*env)->NewGlobalRef(env,self); - JSD_SetScriptHook(jsdjc->jsdc, _scriptHook, jsdjc); - JSD_SetErrorReporter(jsdjc->jsdc, _errorReporter, jsdjc); - JSD_SetDebugBreakHook(jsdjc->jsdc, _executionHook, jsdjc); - } - else - { - JSD_SetDebugBreakHook(jsdjc->jsdc, NULL, NULL); - JSD_SetErrorReporter(jsdjc->jsdc, NULL, NULL); - JSD_SetScriptHook(jsdjc->jsdc, NULL, NULL); - (*env)->DeleteGlobalRef(env,jsdjc->controller); - ASSERT_CLEAR_EXCEPTION(env); - jsdjc->controller = NULL; - jsdjc = NULL; /* for setting below... */ - } - - /* store the _nativeContext in the controller */ - clazz = (*env)->FindClass(env, "netscape/jsdebug/DebugController"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_GOTO(clazz, LABEL_FAILURE); - - fid = (*env)->GetFieldID(env, clazz, "_nativeContext", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_GOTO(fid, LABEL_FAILURE); - (*env)->SetIntField(env, self, fid, (long)jsdjc); - ASSERT_CLEAR_EXCEPTION(env); - - if(jsdjc->startStopCallback) - (*jsdjc->startStopCallback)(jsdjc, on ? JSDJ_START_SUCCESS : JSDJ_STOP, - jsdjc->startStopCallbackData); - return; - -LABEL_FAILURE: - if(jsdjc->startStopCallback) - (*jsdjc->startStopCallback)(jsdjc, on ? JSDJ_START_FAILURE : JSDJ_STOP, - jsdjc->startStopCallbackData); -} - -/* - * Class: netscape_jsdebug_DebugController - * Method: executeScriptInStackFrame0 - * Signature: (Lnetscape/jsdebug/JSStackFrameInfo;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL Java_netscape_jsdebug_DebugController_executeScriptInStackFrame0 - (JNIEnv *env, jobject self, jobject frame, jstring text, - jstring filename, jint lineno) -{ - JSDJContext* jsdjc; - JSDThreadState* jsdthreadstate; - JSDStackFrameInfo* jsdframe; - char* filenameC; - char* srcC; - JSString* jsstr; - jsval rval; - JSBool success; - int srclen; - jstring retval; - - jsdjc = _getJSDJContext(env); - ASSERT_RETURN_VALUE(jsdjc && jsdjc->jsdc && jsdjc->controller, NULL); - ASSERT_CLEAR_EXCEPTION(env); - - jsdthreadstate = _JSDThreadStateFromJSStackFrameInfo(env, frame); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdthreadstate, NULL); - - jsdframe = _JSDStackFrameInfoFromJSStackFrameInfo(env, frame); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdframe, NULL); - - filenameC = _allocCString(env, filename); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(filenameC, NULL); - - srcC = _allocCString(env, text); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(srcC, NULL); - - srclen = strlen(srcC); - - success = JSD_EvaluateScriptInStackFrame(jsdjc->jsdc, - jsdthreadstate, jsdframe, - srcC, srclen, - filenameC, lineno, &rval); - free(filenameC); - free(srcC); - - if( ! success ) - return NULL; - - if( JSVAL_IS_NULL(rval) || JSVAL_IS_VOID(rval) ) - return NULL; - - jsstr = JSD_ValToStringInStackFrame(jsdjc->jsdc, jsdthreadstate, - jsdframe, rval); - if( ! jsstr ) - return NULL; - - retval = (*env)->NewString(env,JS_GetStringChars(jsstr), - JS_GetStringLength(jsstr)); - ASSERT_CLEAR_EXCEPTION(env); - return retval; -} - -/* - * Class: netscape_jsdebug_DebugController - * Method: getNativeMajorVersion - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_netscape_jsdebug_DebugController_getNativeMajorVersion - (JNIEnv *env, jclass clazz) -{ - ASSERT_CLEAR_EXCEPTION(env); - return (jint) JSD_GetMajorVersion(); -} - -/* - * Class: netscape_jsdebug_DebugController - * Method: getNativeMinorVersion - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_netscape_jsdebug_DebugController_getNativeMinorVersion - (JNIEnv *env, jclass clazz) -{ - ASSERT_CLEAR_EXCEPTION(env); - return (jint) JSD_GetMinorVersion(); -} - -/***************************************************************************/ -/* - * Class: netscape_jsdebug_JSPC - * Method: getSourceLocation - * Signature: ()Lnetscape/jsdebug/SourceLocation; - */ -JNIEXPORT jobject JNICALL Java_netscape_jsdebug_JSPC_getSourceLocation - (JNIEnv *env, jobject self) -{ - JSDJContext* jsdjc; - JSDScript* jsdscript; - jobject script; - jobject newPCOb; - jclass clazz; - jfieldID fid; - int line; - int newpc; - int pc; - jobject retval; - - jsdjc = _getJSDJContext(env); - ASSERT_RETURN_VALUE(jsdjc && jsdjc->jsdc && jsdjc->controller, NULL); - ASSERT_CLEAR_EXCEPTION(env); - - clazz = (*env)->GetObjectClass(env, self); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, NULL); - - fid = (*env)->GetFieldID(env, clazz, "script", "Lnetscape/jsdebug/Script;"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - - script = (*env)->GetObjectField(env, self, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(script, NULL); - - clazz = (*env)->GetObjectClass(env, script); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, NULL); - - fid = (*env)->GetFieldID(env, clazz, "_nativePtr", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - - jsdscript = (JSDScript*) (*env)->GetIntField(env, script, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdscript, NULL); - - clazz = (*env)->GetObjectClass(env, self); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, NULL); - - fid = (*env)->GetFieldID(env, clazz, "pc", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - - pc = (*env)->GetIntField(env, self, fid); - ASSERT_CLEAR_EXCEPTION(env); - line = JSD_GetClosestLine(jsdjc->jsdc, jsdscript, pc); - newpc = JSD_GetClosestPC(jsdjc->jsdc, jsdscript, line); - - newPCOb = _constructJSPC(env, script, newpc ); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(newPCOb, NULL); - - retval = _constructJSSourceLocation(env, newPCOb, line); - ASSERT_CLEAR_EXCEPTION(env); - return retval; -} - -/***************************************************************************/ -/* - * Class: netscape_jsdebug_JSSourceTextProvider - * Method: loadSourceTextItem0 - * Signature: (Ljava/lang/String;)Lnetscape/jsdebug/SourceTextItem; - */ -JNIEXPORT jobject JNICALL Java_netscape_jsdebug_JSSourceTextProvider_loadSourceTextItem0 - (JNIEnv *env, jobject self, jstring url) -{ - /* this should attempt to load the source for the indicated URL */ - ASSERT_CLEAR_EXCEPTION(env); - return NULL; -} - -/* - * Class: netscape_jsdebug_JSSourceTextProvider - * Method: refreshSourceTextVector - * Signature: ()V - */ -JNIEXPORT void JNICALL Java_netscape_jsdebug_JSSourceTextProvider_refreshSourceTextVector - (JNIEnv *env, jobject self) -{ - JSDJContext* jsdjc; - jclass clazz; - jmethodID mid; - jclass clazzSelf; - jclass clazzSTI; - jmethodID midFindItem; - jmethodID midSTIctor; - jmethodID midSTIsetText; - jmethodID midSTIsetStatus; - jmethodID midSTIsetDirty; - jmethodID midVectorAddElement; - jfieldID fid; - jobject vec; - jobject itemOb; - JSDSourceText* iterp = 0; - JSDSourceText* item; - - jsdjc = _getJSDJContext(env); - ASSERT_RETURN_VOID(jsdjc && jsdjc->jsdc && jsdjc->controller); - ASSERT_CLEAR_EXCEPTION(env); - - /* gather for later use */ - clazzSelf = (*env)->GetObjectClass(env, self); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(clazzSelf); - - midFindItem = (*env)->GetMethodID(env, clazzSelf, "findSourceTextItem0", - "(Ljava/lang/String;)Lnetscape/jsdebug/SourceTextItem;"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(midFindItem); - - clazzSTI = (*env)->FindClass(env, "netscape/jsdebug/SourceTextItem"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(clazzSTI); - - midSTIctor = (*env)->GetMethodID(env, clazzSTI, "", - "(Ljava/lang/String;Ljava/lang/String;I)V"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(midSTIctor); - - midSTIsetText = (*env)->GetMethodID(env, clazzSTI, "setText", - "(Ljava/lang/String;)V"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(midSTIsetText); - - midSTIsetStatus = (*env)->GetMethodID(env, clazzSTI, "setStatus", "(I)V"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(midSTIsetStatus); - - midSTIsetDirty = (*env)->GetMethodID(env, clazzSTI, "setDirty", "(Z)V"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(midSTIsetDirty); - - /* create new vector */ - clazz = (*env)->FindClass(env, "netscape/util/Vector"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(clazz); - mid = (*env)->GetMethodID(env, clazz, "", "()V"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(mid); - vec = (*env)->NewObject(env, clazz, mid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(vec); - - /* get method id for later */ - midVectorAddElement = (*env)->GetMethodID(env, clazz, "addElement", - "(Ljava/lang/Object;)V"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(midVectorAddElement); - - - /* lock the native subsystem */ - JSD_LockSourceTextSubsystem(jsdjc->jsdc); - - /* iterate through the native items */ - while( 0 != (item = JSD_IterateSources(jsdjc->jsdc, &iterp)) ) - { - const char* url; - jstring urlOb; - int status; - - status = JSD_GetSourceStatus(jsdjc->jsdc,item); - - /* try to find Java object */ - url = JSD_GetSourceURL(jsdjc->jsdc, item); - if( ! url || ! strlen(url) ) /* ignoring those with no url */ - continue; - - urlOb = (*env)->NewStringUTF(env, url); - ASSERT_CLEAR_EXCEPTION(env); - if( ! urlOb ) - continue; - - itemOb = (*env)->CallObjectMethod(env, self, midFindItem, urlOb); - ASSERT_CLEAR_EXCEPTION(env); - - if( ! itemOb ) - { - /* if not found then generate new item */ - - jstring textOb; - const char* str; - int len; - - if( ! JSD_GetSourceText(jsdjc->jsdc, item, &str, &len ) ) - { - str = ""; - len = 0; - } - - /* - * XXX this is pretty lame... - * makeJavaString() used to take a string len and - * didn't require zero termination. - * NewStringUTF() ASSUMES zero termination. - * So, this code makes an otherwise unnecessary copy - * of the string. - * - * XXX the JSD function should (in the future) - * allow for Unicode source text :) - */ - textOb = _NewStringUTF_No_Z(env, str, len); - ASSERT_CLEAR_EXCEPTION(env); - if(! textOb) - { - PR_ASSERT(0); - continue; - } - itemOb = (*env)->NewObject(env, clazzSTI, midSTIctor, - urlOb, textOb, status); - ASSERT_CLEAR_EXCEPTION(env); - } - else if( JSD_IsSourceDirty(jsdjc->jsdc, item) && - JSD_SOURCE_CLEARED != status ) - { - /* if found and dirty then update */ - jstring textOb; - const char* str; - int len; - - if( ! JSD_GetSourceText(jsdjc->jsdc, item, &str, &len ) ) - { - str = ""; - len = 0; - } - - /* - * XXX see "this is pretty lame..." above - */ - - textOb = _NewStringUTF_No_Z(env, str, len); - ASSERT_CLEAR_EXCEPTION(env); - if(! textOb) - { - PR_ASSERT(0); - continue; - } - - (*env)->CallVoidMethod(env, itemOb, midSTIsetText, textOb); - ASSERT_CLEAR_EXCEPTION(env); - (*env)->CallVoidMethod(env, itemOb, midSTIsetStatus, status); - ASSERT_CLEAR_EXCEPTION(env); - (*env)->CallVoidMethod(env, itemOb, midSTIsetDirty, JNI_TRUE); - ASSERT_CLEAR_EXCEPTION(env); - } - - /* we have our copy; clear the native cached text */ - if( JSD_SOURCE_INITED != status && - JSD_SOURCE_PARTIAL != status && - JSD_SOURCE_CLEARED != status ) - { - JSD_ClearSourceText(jsdjc->jsdc, item); - } - - /* set the item clean */ - JSD_SetSourceDirty(jsdjc->jsdc, item, 0 ); - - /* add the item to the vector */ - if( itemOb ) - { - (*env)->CallVoidMethod(env, vec, midVectorAddElement, itemOb); - ASSERT_CLEAR_EXCEPTION(env); - } - } - /* unlock the native subsystem */ - JSD_UnlockSourceTextSubsystem(jsdjc->jsdc); - - /* set main vector to our new vector */ - fid = (*env)->GetFieldID(env, clazzSelf, "_sourceTextVector", - "Lnetscape/util/Vector;"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VOID(fid); - (*env)->SetObjectField(env, self, fid, vec); - ASSERT_CLEAR_EXCEPTION(env); -} - -/***************************************************************************/ -/* - * Class: netscape_jsdebug_JSStackFrameInfo - * Method: getCaller0 - * Signature: ()Lnetscape/jsdebug/StackFrameInfo; - */ -JNIEXPORT jobject JNICALL Java_netscape_jsdebug_JSStackFrameInfo_getCaller0 - (JNIEnv *env, jobject self) -{ - JSDJContext* jsdjc; - jclass clazz; - jfieldID fid; - JSDStackFrameInfo* jsdframeCur; - JSDStackFrameInfo* jsdframeCaller; - JSDThreadState* jsdthreadstate; - jobject threadState; - jobject retval; - - jsdjc = _getJSDJContext(env); - ASSERT_RETURN_VALUE(jsdjc && jsdjc->jsdc && jsdjc->controller, NULL); - ASSERT_CLEAR_EXCEPTION(env); - - clazz = (*env)->GetObjectClass(env, self); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, NULL); - - /* get jsdframeCur */ - fid = (*env)->GetFieldID(env, clazz, "_nativePtr", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - jsdframeCur = (JSDStackFrameInfo*) (*env)->GetIntField(env, self, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdframeCur, NULL); - - /* get threadState */ - fid = (*env)->GetFieldID(env, clazz, "threadState", - "Lnetscape/jsdebug/ThreadStateBase;"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - threadState = (*env)->GetObjectField(env, self, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(threadState, NULL); - - /* get jsdthreadState from threadState */ - clazz = (*env)->GetObjectClass(env, threadState); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, NULL); - fid = (*env)->GetFieldID(env, clazz, "nativeThreadState", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - jsdthreadstate = (JSDThreadState*) (*env)->GetIntField(env, threadState, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdthreadstate, NULL); - - /* get caller frame from JSD */ - jsdframeCaller = JSD_GetCallingStackFrame(jsdjc->jsdc, jsdthreadstate, jsdframeCur); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdframeCaller, NULL); - - retval = _constructJSStackFrameInfo(env, jsdframeCaller, threadState); - ASSERT_CLEAR_EXCEPTION(env); - return retval; -} - -/* - * Class: netscape_jsdebug_JSStackFrameInfo - * Method: getPC - * Signature: ()Lnetscape/jsdebug/PC; - */ -JNIEXPORT jobject JNICALL Java_netscape_jsdebug_JSStackFrameInfo_getPC - (JNIEnv *env, jobject self) -{ - JSDJContext* jsdjc; - jclass clazz; - jfieldID fid; - JSDStackFrameInfo* jsdframe; - JSDThreadState* jsdthreadstate; - JSDScript* jsdscript; - jobject threadState; - jobject script; - int pc; - jobject retval; - - jsdjc = _getJSDJContext(env); - ASSERT_RETURN_VALUE(jsdjc && jsdjc->jsdc && jsdjc->controller, NULL); - ASSERT_CLEAR_EXCEPTION(env); - - clazz = (*env)->GetObjectClass(env, self); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, NULL); - - /* get jsdframe */ - fid = (*env)->GetFieldID(env, clazz, "_nativePtr", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - jsdframe = (JSDStackFrameInfo*) (*env)->GetIntField(env, self, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdframe, NULL); - - /* get threadState */ - fid = (*env)->GetFieldID(env, clazz, "threadState", - "Lnetscape/jsdebug/ThreadStateBase;"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - threadState = (*env)->GetObjectField(env, self, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(threadState, NULL); - - /* get jsdthreadState from threadState */ - clazz = (*env)->GetObjectClass(env, threadState); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, NULL); - fid = (*env)->GetFieldID(env, clazz, "nativeThreadState", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - jsdthreadstate = (JSDThreadState*) (*env)->GetIntField(env, threadState, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdthreadstate, NULL); - - - /* get jsdscript from JSD */ - jsdscript = JSD_GetScriptForStackFrame(jsdjc->jsdc, jsdthreadstate, jsdframe ); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdscript, NULL); - - script = _scriptObFromJSDScriptPtr(env, jsdjc, jsdscript); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(script, NULL); - - pc = JSD_GetPCForStackFrame(jsdjc->jsdc, jsdthreadstate, jsdframe); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(pc, NULL); - - retval = _constructJSPC(env, script, pc); - ASSERT_CLEAR_EXCEPTION(env); - return retval; -} - -/***************************************************************************/ -/* - * Class: netscape_jsdebug_JSThreadState - * Method: countStackFrames - * Signature: ()I - */ -JNIEXPORT jint JNICALL Java_netscape_jsdebug_JSThreadState_countStackFrames - (JNIEnv *env, jobject self) -{ - JSDJContext* jsdjc; - jclass clazz; - jfieldID fid; - JSDThreadState* jsdthreadstate; - - jsdjc = _getJSDJContext(env); - ASSERT_RETURN_VALUE(jsdjc && jsdjc->jsdc && jsdjc->controller, 0); - ASSERT_CLEAR_EXCEPTION(env); - - clazz = (*env)->GetObjectClass(env, self); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, 0); - - fid = (*env)->GetFieldID(env, clazz, "nativeThreadState", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, 0); - jsdthreadstate = (JSDThreadState*) (*env)->GetIntField(env, self, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdthreadstate, 0); - - return (long) JSD_GetCountOfStackFrames(jsdjc->jsdc, jsdthreadstate); -} - -/* - * Class: netscape_jsdebug_JSThreadState - * Method: getCurrentFrame - * Signature: ()Lnetscape/jsdebug/StackFrameInfo; - */ -JNIEXPORT jobject JNICALL Java_netscape_jsdebug_JSThreadState_getCurrentFrame - (JNIEnv *env, jobject self) -{ - JSDJContext* jsdjc; - jclass clazz; - jfieldID fid; - JSDThreadState* jsdthreadstate; - JSDStackFrameInfo* jsdframe; - jobject retval; - - jsdjc = _getJSDJContext(env); - ASSERT_RETURN_VALUE(jsdjc && jsdjc->jsdc && jsdjc->controller, NULL); - ASSERT_CLEAR_EXCEPTION(env); - - clazz = (*env)->GetObjectClass(env, self); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, NULL); - - fid = (*env)->GetFieldID(env, clazz, "nativeThreadState", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - jsdthreadstate = (JSDThreadState*) (*env)->GetIntField(env, self, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdthreadstate, NULL); - - jsdframe = JSD_GetStackFrame(jsdjc->jsdc, jsdthreadstate); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdframe, NULL); - - retval = _constructJSStackFrameInfo(env, jsdframe, self); - ASSERT_CLEAR_EXCEPTION(env); - return retval; -} - -/***************************************************************************/ -/* - * Class: netscape_jsdebug_Script - * Method: getClosestPC - * Signature: (I)Lnetscape/jsdebug/JSPC; - */ -JNIEXPORT jobject JNICALL Java_netscape_jsdebug_Script_getClosestPC - (JNIEnv *env, jobject self, jint lineno) -{ - JSDJContext* jsdjc; - jclass clazz; - jfieldID fid; - JSDScript* jsdscript; - uintN pc; - jobject retval; - - jsdjc = _getJSDJContext(env); - ASSERT_RETURN_VALUE(jsdjc && jsdjc->jsdc && jsdjc->controller, NULL); - ASSERT_CLEAR_EXCEPTION(env); - - clazz = (*env)->GetObjectClass(env, self); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(clazz, NULL); - - fid = (*env)->GetFieldID(env, clazz, "_nativePtr", "I"); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(fid, NULL); - jsdscript = (JSDScript*) (*env)->GetIntField(env, self, fid); - ASSERT_CLEAR_EXCEPTION(env); - ASSERT_RETURN_VALUE(jsdscript, NULL); - - pc = JSD_GetClosestPC(jsdjc->jsdc, jsdscript, lineno); - if( -1 == pc ) - return NULL; - - retval = _constructJSPC(env, self, pc); - ASSERT_CLEAR_EXCEPTION(env); - return retval; -} - -/***************************************************************************/ -/***************************************************************************/ -/* Registration code... */ - -typedef struct { - char* classname; - JNINativeMethod native; -} ClassyJNINativeMethod; - -static ClassyJNINativeMethod _natives[] = -{ - {"netscape/jsdebug/DebugController", - {"setInstructionHook0", - "(Lnetscape/jsdebug/PC;)V", - Java_netscape_jsdebug_DebugController_setInstructionHook0 - } - }, - {"netscape/jsdebug/DebugController", - {"sendInterrupt0", - "()V", - Java_netscape_jsdebug_DebugController_sendInterrupt0 - } - }, - {"netscape/jsdebug/DebugController", - {"_setController", - "(Z)V", - Java_netscape_jsdebug_DebugController__1setController - } - }, - {"netscape/jsdebug/DebugController", - {"executeScriptInStackFrame0", - "(Lnetscape/jsdebug/JSStackFrameInfo;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;", - Java_netscape_jsdebug_DebugController_executeScriptInStackFrame0 - } - }, - {"netscape/jsdebug/DebugController", - {"getNativeMajorVersion", - "()I", - Java_netscape_jsdebug_DebugController_getNativeMajorVersion - } - }, - {"netscape/jsdebug/DebugController", - {"getNativeMinorVersion", - "()I", - Java_netscape_jsdebug_DebugController_getNativeMinorVersion - } - }, - {"netscape/jsdebug/JSPC", - {"getSourceLocation", - "()Lnetscape/jsdebug/SourceLocation;", - Java_netscape_jsdebug_JSPC_getSourceLocation - } - }, - {"netscape/jsdebug/JSSourceTextProvider", - {"loadSourceTextItem0", - "(Ljava/lang/String;)Lnetscape/jsdebug/SourceTextItem;", - Java_netscape_jsdebug_JSSourceTextProvider_loadSourceTextItem0 - } - }, - {"netscape/jsdebug/JSSourceTextProvider", - {"refreshSourceTextVector", - "()V", - Java_netscape_jsdebug_JSSourceTextProvider_refreshSourceTextVector - } - }, - {"netscape/jsdebug/JSStackFrameInfo", - {"getCaller0", - "()Lnetscape/jsdebug/StackFrameInfo;", - Java_netscape_jsdebug_JSStackFrameInfo_getCaller0 - } - }, - {"netscape/jsdebug/JSStackFrameInfo", - {"getPC", - "()Lnetscape/jsdebug/PC;", - Java_netscape_jsdebug_JSStackFrameInfo_getPC - } - }, - {"netscape/jsdebug/JSThreadState", - {"countStackFrames", - "()I", - Java_netscape_jsdebug_JSThreadState_countStackFrames - } - }, - {"netscape/jsdebug/JSThreadState", - {"getCurrentFrame", - "()Lnetscape/jsdebug/StackFrameInfo;", - Java_netscape_jsdebug_JSThreadState_getCurrentFrame - } - }, - {"netscape/jsdebug/Script", - {"getClosestPC", - "(I)Lnetscape/jsdebug/JSPC;", - Java_netscape_jsdebug_Script_getClosestPC - } - } -}; -#define NATIVE_COUNT (sizeof(_natives)/sizeof(_natives[0])) - -/***************************************************************************/ -/***************************************************************************/ -PRBool -jsdj_RegisterNatives(JSDJContext* jsdjc) -{ - int i; - JNIEnv *env = jsdjc->env; - - ASSERT_CLEAR_EXCEPTION(env); - - for( i = 0; i < NATIVE_COUNT; i++ ) - { - jclass clazz; - if( 0 == (clazz = (*env)->FindClass(env, _natives[i].classname)) ) - { - - fprintf(stderr, "failed to find class %s while registering natives\n", - _natives[i].classname ); - - PR_ASSERT(0); - CHECK_CLEAR_EXCEPTION(env); - return PR_FALSE; - } - if( 0 != (*env)->RegisterNatives(env, clazz, &_natives[i].native, 1) ) - { - - fprintf(stderr, "failed to register native %s in %s \n", - _natives[i].native.name, - _natives[i].classname ); - - PR_ASSERT(0); - CHECK_CLEAR_EXCEPTION(env); - return PR_FALSE; - } - } - ASSERT_CLEAR_EXCEPTION(env); - return PR_TRUE; -} - - - diff --git a/mozilla/js/ref/jsd/java/jsd_jvm.c b/mozilla/js/ref/jsd/java/jsd_jvm.c deleted file mode 100644 index 6f25304496b..00000000000 --- a/mozilla/js/ref/jsd/java/jsd_jvm.c +++ /dev/null @@ -1,287 +0,0 @@ - -#include "jsdj.h" - -/***************************************************************************/ -#ifdef JSD_STANDALONE_JAVA_VM -#include "jre.h" - -static char* more_classpath[] = -{ -// {"..\\..\\samples\\jslogger"}, - {"classes"}, - {"ifc12.jar"}, - {"jsd10.jar"}, - {"jsdeb15.jar"} -}; -#define MORE_CLASSPATH_COUNT (sizeof(more_classpath)/sizeof(more_classpath[0])) - -//static char main_class[] = "callnative"; -//static char main_class[] = "simpleIFC"; -// static char* params[] = {"16 Dec 1997"}; -// #define PARAM_COUNT (sizeof(params)/sizeof(params[0])) - -// static char main_class[] = "netscape/jslogger/JSLogger"; -static char main_class[] = "LaunchJSDebugger"; -static char* params[] = {NULL}; -#define PARAM_COUNT 0 - -/* Globals */ -static char **props; /* User-defined properties */ -static int numProps, maxProps; /* Current, max number of properties */ - -static void *handle; -static JavaVM *jvm; -static JNIEnv *env; - -/* Check for null value and return */ -#define NULL_CHECK(e) if ((e) == 0) return 0 - -/* - * Adds a user-defined system property definition. - */ -void AddProperty(char *def) -{ - if (numProps >= maxProps) { - if (props == 0) { - maxProps = 4; - props = JRE_Malloc(maxProps * sizeof(char **)); - } else { - char **tmp; - maxProps *= 2; - tmp = JRE_Malloc(maxProps * sizeof(char **)); - memcpy(tmp, props, numProps * sizeof(char **)); - free(props); - props = tmp; - } - } - props[numProps++] = def; -} - -/* - * Deletes a property definition by name. - */ -void DeleteProperty(const char *name) -{ - int i; - - for (i = 0; i < numProps; ) { - char *def = props[i]; - char *c = strchr(def, '='); - int n; - if (c != 0) { - n = c - def; - } else { - n = strlen(def); - } - if (strncmp(name, def, n) == 0) { - if (i < --numProps) { - memmove(&props[i], &props[i+1], (numProps-i) * sizeof(char **)); - } - } else { - i++; - } - } -} - -/* - * Creates an array of Java string objects from the specified array of C - * strings. Returns 0 if the array could not be created. - */ -jarray NewStringArray(JNIEnv *env, char **cpp, int count) -{ - jclass cls; - jarray ary; - int i; - - NULL_CHECK(cls = (*env)->FindClass(env, "java/lang/String")); - NULL_CHECK(ary = (*env)->NewObjectArray(env, count, cls, 0)); - for (i = 0; i < count; i++) { - jstring str = (*env)->NewStringUTF(env, *cpp++); - NULL_CHECK(str); - (*env)->SetObjectArrayElement(env, ary, i, str); - (*env)->DeleteLocalRef(env, str); - } - return ary; -} - -/***************************************************************************/ - -static JNIEnv* -_CreateJavaVM(void) -{ - JNIEnv* env = NULL; - JDK1_1InitArgs vmargs; - JRESettings set; - - printf("Starting Java...\n"); - - if(JRE_GetCurrentSettings(&set) != 0) - { - if(JRE_GetDefaultSettings(&set) != 0) - { - fprintf(stderr, "Could not locate Java runtime\n"); - return NULL; - } - } - - /* Load runtime library */ - handle = JRE_LoadLibrary(set.runtimeLib); - if (handle == 0) { - fprintf(stderr, "Could not load runtime library: %s\n", - set.runtimeLib); - return NULL; - } - - /* Add pre-defined system properties */ - if (set.javaHome != 0) { - char *def = JRE_Malloc(strlen(set.javaHome) + 16); - sprintf(def, "java.home=%s", set.javaHome); - AddProperty(def); - } - - if (set.compiler != 0) { - char *def = JRE_Malloc(strlen(set.compiler) + 16); - sprintf(def, "java.compiler=%s", set.compiler); - AddProperty(def); - } - - /* - * The following is used to specify that we require at least - * JNI version 1.1. Currently, this field is not checked but - * will be starting with JDK/JRE 1.2. The value returned after - * calling JNI_GetDefaultJavaVMInitArgs() is the actual JNI version - * supported, and is always higher that the requested version. - */ - vmargs.version = 0x00010001; - - if (JRE_GetDefaultJavaVMInitArgs(handle, &vmargs) != 0) { - fprintf(stderr, "Could not initialize Java VM\n"); - return NULL; - } - - /* Tack on our classpath */ - if(MORE_CLASSPATH_COUNT) - { - int i; - int size = strlen(set.classPath) + 1; - char sep[2]; - - sep[0] = PATH_SEPARATOR; - sep[1] = 0; - - for(i = 0; i < MORE_CLASSPATH_COUNT; i++) - size += strlen(more_classpath[i]) + 1; - - vmargs.classpath = malloc(size); - if(vmargs.classpath == 0) - { - fprintf(stderr, "malloc error\n"); - return NULL; - } - - strcpy(vmargs.classpath, set.classPath); - for(i = 0; i < MORE_CLASSPATH_COUNT; i++) - { - strcat(vmargs.classpath, sep); - strcat(vmargs.classpath, more_classpath[i]); - } - } - else - { - vmargs.classpath = set.classPath; - } - -/* -* fprintf(stderr, "classpath: %s\n", vmargs.classpath); -*/ - - /* Set user-defined system properties for Java VM */ - if (props != 0) { - if (numProps == maxProps) { - char **tmp = JRE_Malloc((numProps + 1) * sizeof(char **)); - memcpy(tmp, props, numProps * sizeof(char **)); - free(props); - props = tmp; - } - props[numProps] = 0; - vmargs.properties = props; - } - - - /* verbose? */ -/* -* vmargs.verbose = JNI_TRUE; -*/ - - /* Load and initialize Java VM */ - if (JRE_CreateJavaVM(handle, &jvm, &env, &vmargs) != 0) { - fprintf(stderr, "Could not create Java VM\n"); - return NULL; - } - - /* Free properties */ - if (props != 0) { - free(props); - } - return env; -} - -static PRBool -_StartDebuggerFE(JNIEnv* env) -{ - jclass clazz; - jmethodID mid; - jarray args; - - /* Find class */ - clazz = (*env)->FindClass(env, main_class); - if (clazz == 0) { - fprintf(stderr, "Class not found: %s\n", main_class); - return PR_FALSE; - } - - /* Find main method of class */ - mid = (*env)->GetStaticMethodID(env, clazz, "main", - "([Ljava/lang/String;)V"); - if (mid == 0) { - fprintf(stderr, "In class %s: public static void main(String args[])" - " is not defined\n"); - return PR_FALSE; - } - - /* Invoke main method */ - args = NewStringArray(env, params, PARAM_COUNT); - - if (args == 0) { - JRE_FatalError(env, "Couldn't build argument list for main\n"); - } - (*env)->CallStaticVoidMethod(env, clazz, mid, args); - if ((*env)->ExceptionOccurred(env)) { - (*env)->ExceptionDescribe(env); - } - - return PR_TRUE; -} - -JNIEnv* -jsdj_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc) -{ - JNIEnv* env = NULL; - - env = _CreateJavaVM(); - if( ! env ) - return NULL; - - jsdj_SetJNIEnvForCurrentThread(jsdjc, env); - if( ! jsdj_RegisterNatives(jsdjc) ) - return NULL; - if( ! _StartDebuggerFE(env) ) - return NULL; - - return env; -} - - -#endif /* JSD_STANDALONE_JAVA_VM */ -/***************************************************************************/ - diff --git a/mozilla/js/ref/jsd/java/jsdj.h b/mozilla/js/ref/jsd/java/jsdj.h deleted file mode 100644 index bb70439ac1c..00000000000 --- a/mozilla/js/ref/jsd/java/jsdj.h +++ /dev/null @@ -1,123 +0,0 @@ - -/* -** Header for JavaScript Debugger JNI support (internal functions) -** jband 12-30-97 -*/ - -#ifndef jsdj_h___ -#define jsdj_h___ - -/* Get prtypes.h included first. After that we can use PR macros for doing -* this extern "C" stuff! -*/ -#ifdef __cplusplus -extern "C" -{ -#endif -#include "prtypes.h" -#ifdef __cplusplus -} -#endif - -PR_BEGIN_EXTERN_C -#include "prassert.h" /* for PR_ASSERT */ -#include "jsdjava.h" -#include -#include -#include -PR_END_EXTERN_C - -PR_BEGIN_EXTERN_C - -/***************************************************************************/ -/* defines copied from Java sources. -** NOTE: javah used to put these in the h files, but with JNI does not seem -** to do this anymore. Be careful with synchronization of these -** -*/ - -/* From: ThreadStateBase.java */ - -#define THR_STATUS_UNKNOWN 0x01 -#define THR_STATUS_ZOMBIE 0x02 -#define THR_STATUS_RUNNING 0x03 -#define THR_STATUS_SLEEPING 0x04 -#define THR_STATUS_MONWAIT 0x05 -#define THR_STATUS_CONDWAIT 0x06 -#define THR_STATUS_SUSPENDED 0x07 -#define THR_STATUS_BREAK 0x08 - -#define DEBUG_STATE_DEAD 0x01 -#define DEBUG_STATE_RUN 0x02 -#define DEBUG_STATE_RETURN 0x03 -#define DEBUG_STATE_THROW 0x04 - -/***************************************************************************/ -/* Our structures */ - -typedef struct JSDJContext -{ - JSDContext* jsdc; - JNIEnv* env; /* XXX currently simplified for single threaded case*/ - jobject controller; - JSDJStartStopCallback startStopCallback; - void* startStopCallbackData; - - -} JSDJContext; - -/***************************************************************************/ -/* Code validation support */ - -#ifdef DEBUG -extern void JSDJ_ASSERT_VALID_CONTEXT(JSDJContext* jsdjc); -#else -#define JSDJ_ASSERT_VALID_CONTEXT(x) ((void)0) -#endif - -/***************************************************************************/ -/* higher level functions */ - -extern JSDJContext* -jsdj_CreateContext(); - -extern void -jsdj_DestroyContext(JSDJContext* jsdjc); - -extern void -jsdj_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env); - -extern JNIEnv* -jsdj_GetJNIEnvForCurrentThread(JSDJContext* jsdjc); - -extern void -jsdj_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc); - -extern JSDContext* -jsdj_GetJSDContext(JSDJContext* jsdjc); - -extern PRBool -jsdj_RegisterNatives(JSDJContext* jsdjc); - -extern void -jsdj_SetStartStopCallback(JSDJContext* jsdjc, JSDJStartStopCallback cb, - void* closure); - -/***************************************************************************/ -#ifdef JSD_STANDALONE_JAVA_VM - -extern JNIEnv* -jsdj_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc); - -/** -* extern JNIEnv* -* jsdj_CreateJavaVM(JSDContext* jsdc); -*/ - -#endif /* JSD_STANDALONE_JAVA_VM */ -/***************************************************************************/ - -PR_END_EXTERN_C - -#endif /* jsdj_h___ */ - diff --git a/mozilla/js/ref/jsd/java/jsdjava.c b/mozilla/js/ref/jsd/java/jsdjava.c deleted file mode 100644 index 68f5fb13f00..00000000000 --- a/mozilla/js/ref/jsd/java/jsdjava.c +++ /dev/null @@ -1,73 +0,0 @@ - -#include "jsdj.h" - -PR_PUBLIC_API(JSDJContext*) -JSDJ_CreateContext() -{ - return jsdj_CreateContext(); -} - -PR_PUBLIC_API(void) -JSDJ_DestroyContext(JSDJContext* jsdjc) -{ - JSDJ_ASSERT_VALID_CONTEXT(jsdjc); - jsdj_DestroyContext(jsdjc); -} - -PR_PUBLIC_API(void) -JSDJ_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env) -{ - JSDJ_ASSERT_VALID_CONTEXT(jsdjc); - PR_ASSERT(env); - jsdj_SetJNIEnvForCurrentThread(jsdjc, env); -} - -PR_PUBLIC_API(JNIEnv*) -JSDJ_GetJNIEnvForCurrentThread(JSDJContext* jsdjc) -{ - JSDJ_ASSERT_VALID_CONTEXT(jsdjc); - return jsdj_GetJNIEnvForCurrentThread(jsdjc); -} - -PR_PUBLIC_API(void) -JSDJ_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc) -{ - JSDJ_ASSERT_VALID_CONTEXT(jsdjc); - PR_ASSERT(jsdc); - jsdj_SetJSDContext(jsdjc, jsdc); -} - -PR_PUBLIC_API(JSDContext*) -JSDJ_GetJSDContext(JSDJContext* jsdjc) -{ - JSDJ_ASSERT_VALID_CONTEXT(jsdjc); - return jsdj_GetJSDContext(jsdjc); -} - -PR_PUBLIC_API(PRBool) -JSDJ_RegisterNatives(JSDJContext* jsdjc) -{ - JSDJ_ASSERT_VALID_CONTEXT(jsdjc); - return jsdj_RegisterNatives(jsdjc); -} - -PR_PUBLIC_API(void) -JSDJ_SetStartStopCallback(JSDJContext* jsdjc, JSDJStartStopCallback cb, - void* closure) -{ - JSDJ_ASSERT_VALID_CONTEXT(jsdjc); - jsdj_SetStartStopCallback(jsdjc, cb, closure); -} - -/***************************************************************************/ -#ifdef JSD_STANDALONE_JAVA_VM - -PR_PUBLIC_API(JNIEnv*) -JSDJ_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc) -{ - JSDJ_ASSERT_VALID_CONTEXT(jsdjc); - return jsdj_CreateJavaVMAndStartDebugger(jsdjc); -} - -#endif /* JSD_STANDALONE_JAVA_VM */ -/***************************************************************************/ diff --git a/mozilla/js/ref/jsd/java/jsdjava.h b/mozilla/js/ref/jsd/java/jsdjava.h deleted file mode 100644 index c1a66a16b8b..00000000000 --- a/mozilla/js/ref/jsd/java/jsdjava.h +++ /dev/null @@ -1,82 +0,0 @@ - -/* -** Header for JavaScript Debugger JNI interfaces -** jband 12-30-97 -*/ - -#ifndef jsdjava_h___ -#define jsdjava_h___ - -/* Get prtypes.h included first. After that we can use PR macros for doing -* this extern "C" stuff! -*/ -#ifdef __cplusplus -extern "C" -{ -#endif -#include "prtypes.h" -#ifdef __cplusplus -} -#endif - -PR_BEGIN_EXTERN_C -#include "jsdebug.h" -#include "jni.h" -PR_END_EXTERN_C - - -PR_BEGIN_EXTERN_C - -/***************************************************************************/ -/* Opaque typedefs for handles */ - -typedef struct JSDJContext JSDJContext; - -/***************************************************************************/ -/* High Level functions */ - -extern PR_PUBLIC_API(JSDJContext*) -JSDJ_CreateContext(); - -extern PR_PUBLIC_API(void) -JSDJ_DestroyContext(JSDJContext* jsdjc); - -extern PR_PUBLIC_API(void) -JSDJ_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env); - -extern PR_PUBLIC_API(JNIEnv*) -JSDJ_GetJNIEnvForCurrentThread(JSDJContext* jsdjc); - -extern PR_PUBLIC_API(void) -JSDJ_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc); - -extern PR_PUBLIC_API(JSDContext*) -JSDJ_GetJSDContext(JSDJContext* jsdjc); - -extern PR_PUBLIC_API(PRBool) -JSDJ_RegisterNatives(JSDJContext* jsdjc); - -#define JSDJ_START_SUCCESS 1 -#define JSDJ_START_FAILURE 2 -#define JSDJ_STOP 3 - -typedef void -(*JSDJStartStopCallback)(JSDJContext* jsdjc, int event, void *closure); - -extern PR_PUBLIC_API(void) -JSDJ_SetStartStopCallback(JSDJContext* jsdjc, JSDJStartStopCallback cb, - void* closure); - -/***************************************************************************/ -#ifdef JSD_STANDALONE_JAVA_VM - -extern PR_PUBLIC_API(JNIEnv*) -JSDJ_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc); - -#endif /* JSD_STANDALONE_JAVA_VM */ -/***************************************************************************/ - -PR_END_EXTERN_C - -#endif /* jsdjava_h___ */ - diff --git a/mozilla/js/ref/jsd/run/classes/LaunchJSDebugger.java b/mozilla/js/ref/jsd/run/classes/LaunchJSDebugger.java deleted file mode 100644 index 66ddaa19e34..00000000000 --- a/mozilla/js/ref/jsd/run/classes/LaunchJSDebugger.java +++ /dev/null @@ -1,29 +0,0 @@ -/* -*- Mode: C; tab-width: 8 -*- - * Copyright © 1996, 1997, 1998 Netscape Communications Corporation, - * All Rights Reserved. - */ - -import netscape.jsdebugger.JSDebuggerApp; - -/** -* Launches the JavaScript Debugger in a new thread. -*

-* This exists so that the debugger applet can be run in a standalone -* Java VM (as a Java Application) with no special modification. -* -* @author John Bandhauer -*/ -public class LaunchJSDebugger implements Runnable -{ - public static void main(String[] args) - { - System.out.println("Launching JSDebugger..."); - new Thread(new LaunchJSDebugger()).start(); - } - - public void run() - { - JSDebuggerApp app = new JSDebuggerApp(); - app.run(); - } -} \ No newline at end of file diff --git a/mozilla/js/ref/jsd/run/classes/netscape/security/ForbiddenTargetException.java b/mozilla/js/ref/jsd/run/classes/netscape/security/ForbiddenTargetException.java deleted file mode 100644 index fc329349578..00000000000 --- a/mozilla/js/ref/jsd/run/classes/netscape/security/ForbiddenTargetException.java +++ /dev/null @@ -1,37 +0,0 @@ -// -// ForbiddenTargetException.java -// -- Copyright 1996, Netscape Communications Corp. -// Dan Wallach -// 16 July 1996 -// - -// $Id: ForbiddenTargetException.java,v 1.1 1998-04-24 01:35:06 fur Exp $ - -package netscape.security; - -import java.lang.RuntimeException; - -/** - * This exception is thrown when a privilege request is denied. - * @see netscape.security.PrivilegeManager - */ -public -class ForbiddenTargetException extends java.lang.RuntimeException { - /** - * Constructs an IllegalArgumentException with no detail message. - * A detail message is a String that describes this particular exception. - */ - public ForbiddenTargetException() { - super(); - } - - /** - * Constructs an ForbiddenTargetException with the specified detail message. - * A detail message is a String that describes this particular exception. - * @param s the detail message - */ - public ForbiddenTargetException(String s) { - super(s); - } -} - diff --git a/mozilla/js/ref/jsd/run/classes/netscape/security/PrivilegeManager.java b/mozilla/js/ref/jsd/run/classes/netscape/security/PrivilegeManager.java deleted file mode 100644 index 28802e97f47..00000000000 --- a/mozilla/js/ref/jsd/run/classes/netscape/security/PrivilegeManager.java +++ /dev/null @@ -1,40 +0,0 @@ -// -// jband -- stubbed out version... -// -// PrivilegeManager.java -- Copyright 1996, Netscape Communications Corp. -// Dan Wallach and Raman Tenneti -// - -package netscape.security; - -/** -* Non-functional stubbed out version -*

-* This supports only the entry points used by the JSD system -* @author John Bandhauer -*/ -public final -class PrivilegeManager { - - /** - * check to see if somebody has enabled their privileges to use this target - * @param targetStr A Target name whose access is being checked - * @return nothing - * @exception netscape.security.ForbiddenTargetException thrown if - * access is denied to the Target. - */ - public static void checkPrivilegeEnabled(String targetStr) {} - - /** - * This call enables privileges to the given target until the - * calling method exits. As a side effect, if your principal - * does not have privileges for the target, the user may be - * consulted to grant these privileges. - * - * @param targetStr the name of the Target whose access is being checked - * @return nothing - * @exception netscape.security.ForbiddenTargetException thrown if - * access is denied to the Target. - */ - public static void enablePrivilege(String targetStr) {} -} diff --git a/mozilla/js/ref/jsd/run/readme.txt b/mozilla/js/ref/jsd/run/readme.txt deleted file mode 100644 index ddbfd2e1c6d..00000000000 --- a/mozilla/js/ref/jsd/run/readme.txt +++ /dev/null @@ -1,22 +0,0 @@ -/* jband - 01/13/98 - README... */ - -In order to actually run this code it is necessary to add some stuff... - -0) run the makefile in the directory above to make the executable. - -1) compile the stuff in the classes subdir. This supplies a class to launch -the debugger and stubs for the Communicator security classes. - -2) add jsd10.jar (from Communicator) to this directory. - -3) either create a ifc12.jar from the IFC distributions OR copy the class -tree of the IFC distribution to the classes directory. - -4) install a jsdebugger 1.5 frontend. This can be got by installing it -in Communicator and copying jsdeb15.jar to this directory. Also, the 'images' -and 'sounds' subdirectories need to be copied over. - -Inside Netscape the debugger frontend can be found at: -ftp://sweetlou/products/client/jsdebug15/all/1998_01_13_20_26/jsd15su.jar - -5) need to install the jre (JavaRuntimeEnvironment) from JavaSoft. \ No newline at end of file