void DEBUG_ITERATE_SOURCES( JSDContext* jsdc ) { JSDSourceText* iterp = NULL; JSDSourceText* jsdsrc = NULL; int dummy; while( NULL != (jsdsrc = jsd_IterateSources(jsdc, &iterp)) ) { const char* url; const char* text; int len; JSBool dirty; JSDStreamStatus status; JSBool gotSrc; url = JSD_GetSourceURL(jsdc, jsdsrc); dirty = JSD_IsSourceDirty(jsdc, jsdsrc); status = JSD_GetSourceStatus(jsdc, jsdsrc); gotSrc = JSD_GetSourceText(jsdc, jsdsrc, &text, &len ); dummy = 0; /* gives us a line to set breakpoint... */ } }
void netscape_jsdebug_JSSourceTextProvider_refreshSourceTextVector(struct Hnetscape_jsdebug_JSSourceTextProvider * self) { JHandle* vec; JHandle* itemOb; JSDSourceText* iterp = 0; JSDSourceText* item; const char* url; struct Hjava_lang_String* urlOb; ExecEnv* ee = EE(); if( ! context || ! controller || ! ee ) return; /* create new vector */ vec = (JHandle*) execute_java_constructor(ee, "netscape/util/Vector", 0, "()"); if( ! vec ) return; /* lock the native subsystem */ JSD_LockSourceTextSubsystem(context); /* iterate through the native items */ while( 0 != (item = JSD_IterateSources(context, &iterp)) ) { int urlStrLen; int status = JSD_GetSourceStatus(context,item); /* try to find Java object */ url = JSD_GetSourceURL(context, item); if( ! url || 0 == (urlStrLen = strlen(url)) ) /* ignoring those with no url */ continue; urlOb = makeJavaString((char*)url,urlStrLen); if( ! urlOb ) continue; itemOb = (JHandle*) execute_java_dynamic_method( ee, (JHandle*)self, "findSourceTextItem0", "(Ljava/lang/String;)Lnetscape/jsdebug/SourceTextItem;", urlOb ); if( ! itemOb ) { /* if not found then generate new item */ struct Hjava_lang_String* textOb; const char* str; int length; if( ! JSD_GetSourceText(context, item, &str, &length ) ) { str = ""; length = 0; } textOb = makeJavaString((char*)str, length); itemOb = (JHandle*) execute_java_constructor(ee, "netscape/jsdebug/SourceTextItem",0, "(Ljava/lang/String;Ljava/lang/String;I)", urlOb, textOb, status ); } else if( JSD_IsSourceDirty(context, item) && JSD_SOURCE_CLEARED != status ) { /* if found and dirty then update */ struct Hjava_lang_String* textOb; const char* str; int length; if( ! JSD_GetSourceText(context, item, &str, &length ) ) { str = ""; length = 0; } textOb = makeJavaString((char*)str, length); execute_java_dynamic_method(ee, itemOb, "setText", "(Ljava/lang/String;)V", textOb); execute_java_dynamic_method(ee, itemOb, "setStatus", "(I)V", status ); execute_java_dynamic_method(ee, itemOb, "setDirty", "(Z)V", 1 ); } /* we have our copy; clear the native cached text */ if( JSD_SOURCE_INITED != status && JSD_SOURCE_PARTIAL != status && JSD_SOURCE_CLEARED != status ) { JSD_ClearSourceText(context, item); } /* set the item clean */ JSD_SetSourceDirty(context, item, FALSE ); /* add the item to the vector */ if( itemOb ) execute_java_dynamic_method(ee, vec, "addElement", "(Ljava/lang/Object;)V", itemOb ); } /* unlock the native subsystem */ JSD_UnlockSourceTextSubsystem(context); /* set main vector to our new vector */ unhand(self)->_sourceTextVector = (struct Hnetscape_util_Vector*) vec; }