From 948f6f521c241c74bf58efa73394826c5d446da9 Mon Sep 17 00:00:00 2001 From: "jband%netscape.com" Date: Wed, 16 Sep 1998 02:07:50 +0000 Subject: [PATCH] (not part of client build) initial checkin of mozilla/js/jsdj (migrated from ns/js/jsdj) git-svn-id: svn://10.0.0.236/trunk@10115 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/js/jsdj/README | 30 + mozilla/js/jsdj/build/README | 33 + mozilla/js/jsdj/build/gen_date.awk | 31 + .../js/jsdj/build/images/blue-ball-small.gif | Bin 0 -> 255 bytes mozilla/js/jsdj/build/images/blue-ball.gif | Bin 0 -> 925 bytes mozilla/js/jsdj/build/images/class-index.gif | Bin 0 -> 1497 bytes .../jsdj/build/images/constructor-index.gif | Bin 0 -> 1711 bytes mozilla/js/jsdj/build/images/constructors.gif | Bin 0 -> 1565 bytes mozilla/js/jsdj/build/images/error-index.gif | Bin 0 -> 1438 bytes .../js/jsdj/build/images/exception-index.gif | Bin 0 -> 1707 bytes .../js/jsdj/build/images/green-ball-small.gif | Bin 0 -> 102 bytes mozilla/js/jsdj/build/images/green-ball.gif | Bin 0 -> 886 bytes .../js/jsdj/build/images/interface-index.gif | Bin 0 -> 1648 bytes mozilla/js/jsdj/build/images/magenta-ball.gif | Bin 0 -> 896 bytes mozilla/js/jsdj/build/images/method-index.gif | Bin 0 -> 1588 bytes mozilla/js/jsdj/build/images/methods.gif | Bin 0 -> 1403 bytes .../js/jsdj/build/images/package-index.gif | Bin 0 -> 1607 bytes .../js/jsdj/build/images/red-ball-small.gif | Bin 0 -> 255 bytes mozilla/js/jsdj/build/images/red-ball.gif | Bin 0 -> 527 bytes .../js/jsdj/build/images/variable-index.gif | Bin 0 -> 1443 bytes mozilla/js/jsdj/build/images/variables.gif | Bin 0 -> 1241 bytes .../jsdj/build/images/yellow-ball-small.gif | Bin 0 -> 255 bytes mozilla/js/jsdj/build/images/yellow-ball.gif | Bin 0 -> 925 bytes mozilla/js/jsdj/build/jsdj.mak | 517 +++++++ mozilla/js/jsdj/build/mk.bat | 1 + mozilla/js/jsdj/build/mk_ifcui_std.bat | 2 + .../js/jsdj/build/mk_ifcui_std_fast_jar.bat | 1 + mozilla/js/jsdj/classes/README | 7 + .../jsdebugging/api/AdapterLoader.java | 29 + .../jsdebugging/api/DebugBreakHook.java | 35 + .../jsdebugging/api/DebugController.java | 138 ++ .../netscape/jsdebugging/api/ExecResult.java | 33 + .../com/netscape/jsdebugging/api/Hook.java | 27 + .../jsdebugging/api/InstructionHook.java | 50 + .../jsdebugging/api/InterruptHook.java | 36 + .../jsdebugging/api/InvalidInfoException.java | 39 + .../jsdebugging/api/JSErrorReporter.java | 33 + .../com/netscape/jsdebugging/api/JSPC.java | 41 + .../jsdebugging/api/JSSourceLocation.java | 43 + .../jsdebugging/api/JSStackFrameInfo.java | 45 + .../jsdebugging/api/JSThreadState.java | 23 + .../com/netscape/jsdebugging/api/PC.java | 37 + .../netscape/jsdebugging/api/Property.java | 53 + .../com/netscape/jsdebugging/api/README | 9 + .../com/netscape/jsdebugging/api/Script.java | 35 + .../netscape/jsdebugging/api/ScriptHook.java | 49 + .../jsdebugging/api/ScriptSection.java | 26 + .../jsdebugging/api/SourceLocation.java | 45 + .../jsdebugging/api/SourceTextItem.java | 39 + .../jsdebugging/api/SourceTextProvider.java | 27 + .../jsdebugging/api/StackFrameInfo.java | 42 + .../jsdebugging/api/ThreadStateBase.java | 134 ++ .../com/netscape/jsdebugging/api/Value.java | 56 + .../api/corba/AdapterLoaderCorba.java | 54 + .../api/corba/DebugBreakHookCorba.java | 60 + .../api/corba/DebugControllerCorba.java | 559 ++++++++ .../api/corba/ExecResultCorba.java | 43 + .../api/corba/InstructionHookCorba.java | 50 + .../api/corba/InterruptHookCorba.java | 66 + .../api/corba/JSErrorReporterCorba.java | 46 + .../jsdebugging/api/corba/JSPCCorba.java | 91 ++ .../api/corba/JSSourceLocationCorba.java | 56 + .../api/corba/JSStackFrameInfoCorba.java | 77 ++ .../api/corba/JSThreadStateCorba.java | 179 +++ .../jsdebugging/api/corba/MyNaming.java | 71 + .../jsdebugging/api/corba/ScriptCorba.java | 91 ++ .../api/corba/ScriptHookCorba.java | 54 + .../api/corba/ScriptSectionCorba.java | 37 + .../api/corba/SourceTextItemCorba.java | 114 ++ .../api/corba/SourceTextProviderCorba.java | 171 +++ .../api/local/AdapterLoaderLocal.java | 41 + .../jsdebugging/api/local/Callback.java | 24 + .../api/local/DebugBreakHookLocal.java | 55 + .../api/local/DebugControllerLocal.java | 449 ++++++ .../api/local/ExecResultLocal.java | 62 + .../api/local/InstructionHookLocal.java | 47 + .../api/local/InterruptHookLocal.java | 56 + .../api/local/JSErrorReporterLocal.java | 42 + .../jsdebugging/api/local/JSPCLocal.java | 68 + .../api/local/JSSourceLocationLocal.java | 53 + .../api/local/JSStackFrameInfoLocal.java | 110 ++ .../api/local/JSThreadStateLocal.java | 226 ++++ .../jsdebugging/api/local/PropertyLocal.java | 58 + .../com/netscape/jsdebugging/api/local/README | 5 + .../api/local/ScriptHookLocal.java | 47 + .../jsdebugging/api/local/ScriptLocal.java | 63 + .../api/local/ScriptSectionLocal.java | 37 + .../api/local/SourceTextItemLocal.java | 80 ++ .../api/local/SourceTextProviderLocal.java | 138 ++ .../jsdebugging/api/local/ValueLocal.java | 160 +++ .../api/rhino/AdapterLoaderRhino.java | 41 + .../jsdebugging/api/rhino/Callback.java | 24 + .../api/rhino/DebugBreakHookRhino.java | 55 + .../api/rhino/DebugControllerRhino.java | 396 ++++++ .../api/rhino/ExecResultRhino.java | 43 + .../api/rhino/InstructionHookRhino.java | 47 + .../api/rhino/InterruptHookRhino.java | 56 + .../api/rhino/JSErrorReporterRhino.java | 42 + .../jsdebugging/api/rhino/JSPCRhino.java | 68 + .../api/rhino/JSSourceLocationRhino.java | 53 + .../api/rhino/JSStackFrameInfoRhino.java | 83 ++ .../api/rhino/JSThreadStateRhino.java | 244 ++++ .../com/netscape/jsdebugging/api/rhino/README | 5 + .../api/rhino/ScriptHookRhino.java | 47 + .../jsdebugging/api/rhino/ScriptRhino.java | 69 + .../api/rhino/ScriptSectionRhino.java | 37 + .../api/rhino/SourceTextItemRhino.java | 79 ++ .../api/rhino/SourceTextProviderRhino.java | 147 ++ .../jsdebugging/apitests/Analyzer.java | 166 +++ .../jsdebugging/apitests/Harness.java | 127 ++ .../netscape/jsdebugging/apitests/Main.java | 202 +++ .../com/netscape/jsdebugging/apitests/README | 5 + .../analyzers/AnalyzeErrorReports.java | 44 + .../analyzing/analyzers/AnalyzeEvals.java | 49 + .../analyzers/AnalyzeInterrupts.java | 393 ++++++ .../analyzers/AnalyzeScriptPools.java | 149 ++ .../analyzers/AnalyzeSourceLocations.java | 87 ++ .../analyzing/analyzers/AnalyzerBase.java | 169 +++ .../apitests/analyzing/data/DFrame.java | 66 + .../apitests/analyzing/data/DInterrupt.java | 68 + .../apitests/analyzing/data/DStack.java | 69 + .../apitests/analyzing/data/DTestInfo.java | 87 ++ .../apitests/analyzing/data/Data.java | 61 + .../apitests/analyzing/data/DataError.java | 73 + .../apitests/analyzing/data/DataEval.java | 101 ++ .../apitests/analyzing/data/DataPC.java | 65 + .../apitests/analyzing/data/DataPool.java | 129 ++ .../analyzing/data/DataPoolManager.java | 173 +++ .../apitests/analyzing/data/DataScript.java | 83 ++ .../apitests/analyzing/data/DataSection.java | 54 + .../analyzing/data/DataSerializable.java | 64 + .../analyzing/data/DataSourceLocation.java | 59 + .../apitests/analyzing/tree/TreeNode.java | 104 ++ .../apitests/analyzing/tree/TreePrinter.java | 80 ++ .../apitests/analyzing/tree/TreeUtils.java | 212 +++ .../apitests/testing/MyErrorReporter.java | 47 + .../apitests/testing/MyInstructionHook.java | 41 + .../apitests/testing/MyInterruptHook.java | 41 + .../apitests/testing/MyScriptHook.java | 46 + .../jsdebugging/apitests/testing/Test.java | 52 + .../apitests/testing/TestSuite.java | 115 ++ .../apitests/testing/desc/DescError.java | 59 + .../apitests/testing/desc/DescEval.java | 61 + .../apitests/testing/desc/DescFrame.java | 46 + .../apitests/testing/desc/DescInterrupt.java | 48 + .../apitests/testing/desc/DescLine.java | 48 + .../apitests/testing/desc/DescLines.java | 48 + .../apitests/testing/desc/DescPC.java | 49 + .../apitests/testing/desc/DescScript.java | 56 + .../testing/desc/DescScriptLoaded.java | 41 + .../testing/desc/DescScriptUnLoaded.java | 41 + .../apitests/testing/desc/DescSection.java | 42 + .../apitests/testing/desc/DescSections.java | 47 + .../testing/desc/DescSourceLocation.java | 47 + .../apitests/testing/desc/DescStack.java | 57 + .../apitests/testing/desc/DescStep.java | 41 + .../apitests/testing/desc/Descriptor.java | 71 + .../testing/desc/DescriptorManager.java | 76 ++ .../testing/desc/DescriptorSerializable.java | 89 ++ .../testing/tests/TestErrorReporter.java | 67 + .../testing/tests/TestEvalInStackFrame.java | 80 ++ .../testing/tests/TestInterrupts.java | 53 + .../testing/tests/TestScriptLoading.java | 59 + .../apitests/testing/tests/TestStepping.java | 69 + .../jsdebugging/apitests/xml/HTMLWriter.java | 215 +++ .../jsdebugging/apitests/xml/TagHandler.java | 32 + .../jsdebugging/apitests/xml/Tags.java | 144 ++ .../jsdebugging/apitests/xml/TreeCreator.java | 59 + .../jsdebugging/apitests/xml/XMLEscape.java | 64 + .../jsdebugging/apitests/xml/XMLParser.java | 85 ++ .../jsdebugging/apitests/xml/XMLWriter.java | 131 ++ .../netscape/jsdebugging/engine/IContext.java | 39 + .../jsdebugging/engine/IErrorSink.java | 25 + .../jsdebugging/engine/IPrintSink.java | 24 + .../netscape/jsdebugging/engine/IRuntime.java | 32 + .../jsdebugging/engine/IRuntimeCreator.java | 27 + .../com/netscape/jsdebugging/engine/README | 6 + .../engine/local/ContextLocal.java | 100 ++ .../netscape/jsdebugging/engine/local/README | 5 + .../engine/local/RuntimeCreatorLocal.java | 31 + .../engine/local/RuntimeLocal.java | 83 ++ .../engine/rhino/ContextRhino.java | 288 ++++ .../netscape/jsdebugging/engine/rhino/README | 5 + .../engine/rhino/RuntimeCreatorRhino.java | 31 + .../engine/rhino/RuntimeRhino.java | 87 ++ .../ifcui/BackgroundHackListView.java | 63 + .../jsdebugging/ifcui/Breakpoint.java | 144 ++ .../ifcui/BreakpointEditorDialog.java | 194 +++ .../jsdebugging/ifcui/BreakpointHook.java | 153 +++ .../jsdebugging/ifcui/BreakpointSaver.java | 79 ++ .../jsdebugging/ifcui/BreakpointTyrant.java | 547 ++++++++ .../ifcui/BreakpointTyrantUpdate.java | 47 + .../jsdebugging/ifcui/BreakpointView.java | 380 ++++++ .../netscape/jsdebugging/ifcui/BuildDate.java | 21 + .../netscape/jsdebugging/ifcui/CallChain.java | 86 ++ .../jsdebugging/ifcui/ChainableHook.java | 32 + .../netscape/jsdebugging/ifcui/CmdState.java | 42 + .../jsdebugging/ifcui/CommandTyrant.java | 743 ++++++++++ .../jsdebugging/ifcui/CommandView.java | 373 +++++ .../jsdebugging/ifcui/ConsolePrinter.java | 29 + .../jsdebugging/ifcui/ConsoleTyrant.java | 237 ++++ .../jsdebugging/ifcui/ConsoleView.java | 347 +++++ .../jsdebugging/ifcui/ControlTyrant.java | 645 +++++++++ .../ifcui/ControlTyrantUpdate.java | 38 + .../jsdebugging/ifcui/EditKeyTextFilter.java | 69 + .../netscape/jsdebugging/ifcui/Emperor.java | 673 +++++++++ .../jsdebugging/ifcui/EmperorOwner.java | 28 + .../com/netscape/jsdebugging/ifcui/Env.java | 204 +++ .../jsdebugging/ifcui/ErrorReport.java | 49 + .../ifcui/ErrorReporterDialog.java | 198 +++ .../jsdebugging/ifcui/HostNameDialog.java | 189 +++ .../jsdebugging/ifcui/InspectorNodeModel.java | 152 +++ .../jsdebugging/ifcui/InspectorTyrant.java | 325 +++++ .../jsdebugging/ifcui/InspectorView.java | 806 +++++++++++ .../jsdebugging/ifcui/JSDebuggerApp.java | 709 ++++++++++ .../jsdebugging/ifcui/JSDebuggerApplet.java | 75 + .../jsdebugging/ifcui/LicenseViewer.java | 138 ++ .../netscape/jsdebugging/ifcui/Location.java | 126 ++ .../com/netscape/jsdebugging/ifcui/Log.java | 242 ++++ .../jsdebugging/ifcui/MouseMenuView.java | 309 +++++ .../jsdebugging/ifcui/PageListView.java | 248 ++++ .../jsdebugging/ifcui/PrefsSupport.java | 33 + .../com/netscape/jsdebugging/ifcui/README | 11 + .../jsdebugging/ifcui/SmartItemListView.java | 77 ++ .../jsdebugging/ifcui/SmartListItem.java | 64 + .../ifcui/SourceLineItemModel.java | 41 + .../jsdebugging/ifcui/SourceTyrant.java | 356 +++++ .../jsdebugging/ifcui/SourceTyrantUpdate.java | 43 + .../jsdebugging/ifcui/SourceView.java | 1204 +++++++++++++++++ .../jsdebugging/ifcui/SourceViewManager.java | 288 ++++ .../jsdebugging/ifcui/SourceViewSaver.java | 64 + .../jsdebugging/ifcui/StackTyrant.java | 177 +++ .../netscape/jsdebugging/ifcui/StackView.java | 311 +++++ .../jsdebugging/ifcui/StatusWindow.java | 80 ++ .../jsdebugging/ifcui/StepHandler.java | 37 + .../netscape/jsdebugging/ifcui/StepInto.java | 75 + .../netscape/jsdebugging/ifcui/StepOut.java | 63 + .../netscape/jsdebugging/ifcui/StepOver.java | 77 ++ .../jsdebugging/ifcui/StringEditorDialog.java | 105 ++ .../com/netscape/jsdebugging/ifcui/Test.java | 581 ++++++++ .../com/netscape/jsdebugging/ifcui/Util.java | 91 ++ .../jsdebugging/ifcui/WatchSaver.java | 75 + .../jsdebugging/ifcui/WatchTyrant.java | 123 ++ .../netscape/jsdebugging/ifcui/WatchView.java | 282 ++++ .../launcher/local/LaunchJSDebugger.java | 44 + .../LaunchNetscapeJavaScriptDebugger.java | 54 + .../netscape/jsdebugging/ifcui/palomar/README | 5 + .../palomar/util/AssertFailureHandler.java | 40 + .../jsdebugging/ifcui/palomar/util/ER.java | 225 +++ .../ifcui/palomar/widget/BorderView.java | 86 ++ .../palomar/widget/GrayScaleImageFilter.java | 64 + .../widget/HighlightingImageFilter.java | 83 ++ .../ifcui/palomar/widget/ImageView.java | 150 ++ .../ifcui/palomar/widget/PopupButton.java | 367 +++++ .../ifcui/palomar/widget/SeparatorView.java | 52 + .../ifcui/palomar/widget/StringView.java | 115 ++ .../widget/layout/BoxSpringLayout.java | 559 ++++++++ .../ifcui/palomar/widget/layout/BoxView.java | 853 ++++++++++++ .../palomar/widget/layout/MarginLayout.java | 190 +++ .../palomar/widget/layout/MarginView.java | 88 ++ .../palomar/widget/layout/Shapeable.java | 29 + .../widget/layout/ShapeableLayoutManager.java | 32 + .../palomar/widget/layout/ShapeableView.java | 88 ++ .../palomar/widget/layout/SplitterView.java | 326 +++++ .../ifcui/palomar/widget/layout/Spring.java | 82 ++ .../palomar/widget/layout/math/Spring.java | 53 + .../widget/layout/math/SpringVector.java | 93 ++ .../widget/toolTip/ToolTipExternalWindow.java | 46 + .../widget/toolTip/ToolTipRootView.java | 419 ++++++ .../ifcui/palomar/widget/toolbar/Toolbar.java | 323 +++++ .../palomar/widget/toolbar/ToolbarTray.java | 122 ++ .../jsdebugging/jsdb/Documentation.html | 207 +++ .../jsdebugging/jsdb/JSDBBreakpoint.java | 69 + .../jsdebugging/jsdb/JSDBBreakpointsList.java | 184 +++ .../jsdebugging/jsdb/JSDBErrorReporter.java | 50 + .../jsdebugging/jsdb/JSDBInstructionHook.java | 48 + .../jsdebugging/jsdb/JSDBInterruptHook.java | 319 +++++ .../jsdebugging/jsdb/JSDBScriptHook.java | 58 + .../com/netscape/jsdebugging/jsdb/Main.java | 211 +++ .../com/netscape/jsdebugging/jsdb/sample.js | 11 + .../jsdebugging/jslogger/CallChain.java | 80 ++ .../jsdebugging/jslogger/ControlPanel.java | 206 +++ .../jsdebugging/jslogger/JSLogger.java | 183 +++ .../jslogger/JSLoggerAsIFCApplet.java | 56 + .../jsdebugging/jslogger/MyErrorReporter.java | 54 + .../jsdebugging/jslogger/MyInterruptHook.java | 230 ++++ .../jsdebugging/jslogger/MyScriptHook.java | 91 ++ .../com/netscape/jsdebugging/jslogger/README | 5 + .../remote/corba/IDebugController.java | 71 + .../remote/corba/IDebugControllerHelper.java | 60 + .../remote/corba/IDebugControllerHolder.java | 18 + .../jsdebugging/remote/corba/IExecResult.java | 34 + .../remote/corba/IExecResultHelper.java | 55 + .../remote/corba/IExecResultHolder.java | 18 + .../remote/corba/IJSErrorReporter.java | 35 + .../remote/corba/IJSErrorReporterHelper.java | 60 + .../remote/corba/IJSErrorReporterHolder.java | 18 + .../remote/corba/IJSExecutionHook.java | 7 + .../remote/corba/IJSExecutionHookHelper.java | 60 + .../remote/corba/IJSExecutionHookHolder.java | 18 + .../jsdebugging/remote/corba/IJSPC.java | 19 + .../jsdebugging/remote/corba/IJSPCHelper.java | 40 + .../jsdebugging/remote/corba/IJSPCHolder.java | 18 + .../remote/corba/IJSSourceLocation.java | 19 + .../remote/corba/IJSSourceLocationHelper.java | 40 + .../remote/corba/IJSSourceLocationHolder.java | 18 + .../remote/corba/IJSStackFrameInfo.java | 19 + .../remote/corba/IJSStackFrameInfoHelper.java | 40 + .../remote/corba/IJSStackFrameInfoHolder.java | 18 + .../remote/corba/IJSThreadState.java | 68 + .../remote/corba/IJSThreadStateHelper.java | 52 + .../remote/corba/IJSThreadStateHolder.java | 18 + .../jsdebugging/remote/corba/IScript.java | 31 + .../remote/corba/IScriptHelper.java | 52 + .../remote/corba/IScriptHolder.java | 18 + .../jsdebugging/remote/corba/IScriptHook.java | 9 + .../remote/corba/IScriptHookHelper.java | 60 + .../remote/corba/IScriptHookHolder.java | 18 + .../remote/corba/IScriptSection.java | 19 + .../remote/corba/IScriptSectionHelper.java | 40 + .../remote/corba/IScriptSectionHolder.java | 18 + .../remote/corba/ISourceTextProvider.java | 40 + .../corba/ISourceTextProviderHelper.java | 60 + .../corba/ISourceTextProviderHolder.java | 18 + .../sequence_of_stringHelper.java | 45 + .../sequence_of_stringHolder.java | 18 + .../remote/corba/StringReciever.java | 9 + .../remote/corba/StringRecieverHelper.java | 60 + .../remote/corba/StringRecieverHolder.java | 18 + .../remote/corba/TestInterface.java | 12 + .../remote/corba/TestInterfaceHelper.java | 60 + .../remote/corba/TestInterfaceHolder.java | 18 + .../sequence_of_ThingHelper.java | 45 + .../sequence_of_ThingHolder.java | 18 + .../jsdebugging/remote/corba/Thing.java | 19 + .../jsdebugging/remote/corba/ThingHelper.java | 40 + .../jsdebugging/remote/corba/ThingHolder.java | 18 + .../remote/corba/_sk_IDebugController.java | 241 ++++ .../remote/corba/_sk_IJSErrorReporter.java | 49 + .../remote/corba/_sk_IJSExecutionHook.java | 42 + .../remote/corba/_sk_IScriptHook.java | 47 + .../remote/corba/_sk_ISourceTextProvider.java | 91 ++ .../remote/corba/_sk_StringReciever.java | 47 + .../remote/corba/_sk_TestInterface.java | 61 + .../remote/corba/_st_IDebugController.java | 427 ++++++ .../remote/corba/_st_IJSErrorReporter.java | 38 + .../remote/corba/_st_IJSExecutionHook.java | 26 + .../remote/corba/_st_IScriptHook.java | 37 + .../remote/corba/_st_ISourceTextProvider.java | 129 ++ .../remote/corba/_st_StringReciever.java | 37 + .../remote/corba/_st_TestInterface.java | 64 + .../sequence_of_IJSStackFrameInfoHelper.java | 45 + .../sequence_of_IJSStackFrameInfoHolder.java | 18 + .../sequence_of_IScriptSectionHelper.java | 45 + .../sequence_of_IScriptSectionHolder.java | 18 + .../jsdebugging/tools/depend/Main.java | 704 ++++++++++ .../netscape/nativejsengine/IErrorSink.java | 25 + .../netscape/nativejsengine/IPrintSink.java | 24 + .../netscape/nativejsengine/JSContext.java | 92 ++ .../netscape/nativejsengine/JSRuntime.java | 67 + .../com/netscape/nativejsengine/README | 8 + .../netscape/jsdebug/DebugBreakHook.java | 41 + .../netscape/jsdebug/DebugController.java | 390 ++++++ .../jsdj/classes/netscape/jsdebug/Hook.java | 32 + .../netscape/jsdebug/InstructionHook.java | 55 + .../netscape/jsdebug/InterruptHook.java | 39 + .../jsdebug/InvalidInfoException.java | 46 + .../netscape/jsdebug/JSErrorReporter.java | 70 + .../jsdj/classes/netscape/jsdebug/JSPC.java | 76 ++ .../netscape/jsdebug/JSSourceLocation.java | 63 + .../jsdebug/JSSourceTextProvider.java | 130 ++ .../netscape/jsdebug/JSStackFrameInfo.java | 60 + .../netscape/jsdebug/JSThreadState.java | 80 ++ .../js/jsdj/classes/netscape/jsdebug/PC.java | 42 + .../classes/netscape/jsdebug/Property.java | 129 ++ .../js/jsdj/classes/netscape/jsdebug/README | 8 + .../jsdj/classes/netscape/jsdebug/Script.java | 82 ++ .../classes/netscape/jsdebug/ScriptHook.java | 57 + .../netscape/jsdebug/SourceLocation.java | 53 + .../netscape/jsdebug/SourceTextItem.java | 107 ++ .../netscape/jsdebug/SourceTextProvider.java | 58 + .../netscape/jsdebug/StackFrameInfo.java | 94 ++ .../netscape/jsdebug/ThreadStateBase.java | 241 ++++ .../jsdj/classes/netscape/jsdebug/Value.java | 282 ++++ mozilla/js/jsdj/ifcui/install/install.js | 486 +++++++ .../js/jsdj/ifcui/run/images/AbortTool.gif | Bin 0 -> 901 bytes .../jsdj/ifcui/run/images/BreakpointTool.gif | Bin 0 -> 925 bytes mozilla/js/jsdj/ifcui/run/images/CopyTool.gif | Bin 0 -> 900 bytes mozilla/js/jsdj/ifcui/run/images/EvalTool.gif | Bin 0 -> 928 bytes .../jsdj/ifcui/run/images/HalfSpaceTool.gif | Bin 0 -> 827 bytes .../jsdj/ifcui/run/images/InterruptTool.gif | Bin 0 -> 904 bytes .../jsdj/ifcui/run/images/NarrowSpaceTool.gif | Bin 0 -> 816 bytes mozilla/js/jsdj/ifcui/run/images/Nautical.gif | Bin 0 -> 10890 bytes .../js/jsdj/ifcui/run/images/PageListTool.gif | Bin 0 -> 931 bytes .../js/jsdj/ifcui/run/images/PasteTool.gif | Bin 0 -> 919 bytes .../js/jsdj/ifcui/run/images/RefreshTool.gif | Bin 0 -> 935 bytes mozilla/js/jsdj/ifcui/run/images/RunTool.gif | Bin 0 -> 880 bytes .../js/jsdj/ifcui/run/images/StepIntoTool.gif | Bin 0 -> 923 bytes .../js/jsdj/ifcui/run/images/StepOutTool.gif | Bin 0 -> 913 bytes .../js/jsdj/ifcui/run/images/StepOverTool.gif | Bin 0 -> 928 bytes .../ifcui/run/images/ToolbarCollapser.gif | Bin 0 -> 921 bytes mozilla/js/jsdj/ifcui/run/images/jsd.gif | Bin 0 -> 12846 bytes mozilla/js/jsdj/ifcui/run/jsdebugger.html | 127 ++ .../js/jsdj/ifcui/run/jsdebugger4server.html | 134 ++ mozilla/js/jsdj/ifcui/run/license.html | 296 ++++ mozilla/js/jsdj/ifcui/run/readme.txt | 125 ++ .../js/jsdj/ifcui/run/samples/badlines.html | 54 + .../jsdj/ifcui/run/samples/images/item1.gif | Bin 0 -> 658 bytes .../jsdj/ifcui/run/samples/images/item2.gif | Bin 0 -> 693 bytes .../jsdj/ifcui/run/samples/images/item3.gif | Bin 0 -> 676 bytes .../jsdj/ifcui/run/samples/images/item4.gif | Bin 0 -> 685 bytes mozilla/js/jsdj/ifcui/run/samples/include.js | 3 + mozilla/js/jsdj/ifcui/run/samples/index.html | 15 + mozilla/js/jsdj/ifcui/run/samples/layers.html | 139 ++ mozilla/js/jsdj/ifcui/run/samples/misc.html | 43 + mozilla/js/jsdj/ifcui/run/samples/props.html | 45 + .../js/jsdj/ifcui/run/samples/recursion.html | 48 + mozilla/js/jsdj/ifcui/run/samples/runerr.html | 46 + mozilla/js/jsdj/ifcui/run/sounds/droplet.au | Bin 0 -> 1256 bytes mozilla/js/jsdj/jslogger/JSLogger.html | 21 + mozilla/js/jsdj/stub_classes/README | 7 + .../netscape/applet/EmbeddedProgramOwner.java | 26 + .../applet/EmbeddedProgramTracker.java | 23 + .../netscape/javascript/JSException.java | 74 + .../netscape/javascript/JSObject.java | 168 +++ .../netscape/javascript/JSProxy.java | 39 + .../netscape/javascript/JSRunnable.java | 51 + .../netscape/javascript/JSUtil.java | 39 + .../security/ForbiddenTargetException.java | 48 + .../netscape/security/PrivilegeManager.java | 64 + mozilla/js/jsdj/test/jsdb.bat | 6 + mozilla/js/jsdj/test/objects.js | 40 + mozilla/js/jsdj/test/sample.js | 11 + 433 files changed, 41040 insertions(+) create mode 100644 mozilla/js/jsdj/README create mode 100644 mozilla/js/jsdj/build/README create mode 100644 mozilla/js/jsdj/build/gen_date.awk create mode 100644 mozilla/js/jsdj/build/images/blue-ball-small.gif create mode 100644 mozilla/js/jsdj/build/images/blue-ball.gif create mode 100644 mozilla/js/jsdj/build/images/class-index.gif create mode 100644 mozilla/js/jsdj/build/images/constructor-index.gif create mode 100644 mozilla/js/jsdj/build/images/constructors.gif create mode 100644 mozilla/js/jsdj/build/images/error-index.gif create mode 100644 mozilla/js/jsdj/build/images/exception-index.gif create mode 100644 mozilla/js/jsdj/build/images/green-ball-small.gif create mode 100644 mozilla/js/jsdj/build/images/green-ball.gif create mode 100644 mozilla/js/jsdj/build/images/interface-index.gif create mode 100644 mozilla/js/jsdj/build/images/magenta-ball.gif create mode 100644 mozilla/js/jsdj/build/images/method-index.gif create mode 100644 mozilla/js/jsdj/build/images/methods.gif create mode 100644 mozilla/js/jsdj/build/images/package-index.gif create mode 100644 mozilla/js/jsdj/build/images/red-ball-small.gif create mode 100644 mozilla/js/jsdj/build/images/red-ball.gif create mode 100644 mozilla/js/jsdj/build/images/variable-index.gif create mode 100644 mozilla/js/jsdj/build/images/variables.gif create mode 100644 mozilla/js/jsdj/build/images/yellow-ball-small.gif create mode 100644 mozilla/js/jsdj/build/images/yellow-ball.gif create mode 100644 mozilla/js/jsdj/build/jsdj.mak create mode 100755 mozilla/js/jsdj/build/mk.bat create mode 100755 mozilla/js/jsdj/build/mk_ifcui_std.bat create mode 100755 mozilla/js/jsdj/build/mk_ifcui_std_fast_jar.bat create mode 100644 mozilla/js/jsdj/classes/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/AdapterLoader.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/DebugBreakHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/DebugController.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ExecResult.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Hook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InstructionHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InterruptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InvalidInfoException.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSErrorReporter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSPC.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSSourceLocation.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSStackFrameInfo.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSThreadState.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/PC.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Property.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Script.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ScriptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ScriptSection.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceLocation.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceTextItem.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceTextProvider.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/StackFrameInfo.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ThreadStateBase.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Value.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/AdapterLoaderCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/DebugBreakHookCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/DebugControllerCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ExecResultCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/InstructionHookCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/InterruptHookCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSErrorReporterCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSPCCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSSourceLocationCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSStackFrameInfoCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSThreadStateCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/MyNaming.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptHookCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptSectionCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/SourceTextItemCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/SourceTextProviderCorba.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/AdapterLoaderLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/Callback.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/DebugBreakHookLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/DebugControllerLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ExecResultLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/InstructionHookLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/InterruptHookLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSErrorReporterLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSPCLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSSourceLocationLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSStackFrameInfoLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSThreadStateLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/PropertyLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptHookLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptSectionLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/SourceTextItemLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/SourceTextProviderLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ValueLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/AdapterLoaderRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/Callback.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/DebugBreakHookRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/DebugControllerRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ExecResultRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/InstructionHookRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/InterruptHookRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSErrorReporterRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSPCRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSSourceLocationRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSStackFrameInfoRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSThreadStateRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptHookRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptSectionRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/SourceTextItemRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/SourceTextProviderRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Analyzer.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Harness.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Main.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeErrorReports.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeEvals.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeInterrupts.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeScriptPools.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeSourceLocations.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzerBase.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DFrame.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DInterrupt.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DStack.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DTestInfo.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/Data.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataError.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataEval.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPC.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPool.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPoolManager.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataScript.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSection.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSerializable.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSourceLocation.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/tree/TreeNode.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/tree/TreePrinter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/tree/TreeUtils.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/MyErrorReporter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/MyInstructionHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/MyInterruptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/MyScriptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/Test.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/TestSuite.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescError.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescEval.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescFrame.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescInterrupt.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescLine.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescLines.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescPC.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescScript.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescScriptLoaded.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescScriptUnLoaded.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescSection.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescSections.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescSourceLocation.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescStack.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescStep.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/Descriptor.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescriptorManager.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/desc/DescriptorSerializable.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/tests/TestErrorReporter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/tests/TestEvalInStackFrame.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/tests/TestInterrupts.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/tests/TestScriptLoading.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/testing/tests/TestStepping.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/HTMLWriter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/TagHandler.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/Tags.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/TreeCreator.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLEscape.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLParser.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLWriter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IContext.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IErrorSink.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IPrintSink.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IRuntime.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IRuntimeCreator.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/ContextLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/RuntimeCreatorLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/RuntimeLocal.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/ContextRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/RuntimeCreatorRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/RuntimeRhino.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BackgroundHackListView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Breakpoint.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointEditorDialog.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointSaver.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointTyrant.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointTyrantUpdate.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BuildDate.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CallChain.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ChainableHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CmdState.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CommandTyrant.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CommandView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsolePrinter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsoleTyrant.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsoleView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ControlTyrant.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ControlTyrantUpdate.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/EditKeyTextFilter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Emperor.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/EmperorOwner.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Env.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ErrorReport.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ErrorReporterDialog.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/HostNameDialog.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorNodeModel.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorTyrant.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/JSDebuggerApp.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/JSDebuggerApplet.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/LicenseViewer.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Location.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Log.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/MouseMenuView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/PageListView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/PrefsSupport.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SmartItemListView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SmartListItem.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceLineItemModel.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceTyrant.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceTyrantUpdate.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceViewManager.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceViewSaver.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StackTyrant.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StackView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StatusWindow.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepHandler.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepInto.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepOut.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepOver.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StringEditorDialog.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Test.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Util.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchSaver.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchTyrant.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/launcher/local/LaunchJSDebugger.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/launcher/rhino/LaunchNetscapeJavaScriptDebugger.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/util/AssertFailureHandler.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/util/ER.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/BorderView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/GrayScaleImageFilter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/HighlightingImageFilter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/ImageView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/PopupButton.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/SeparatorView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/StringView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/BoxSpringLayout.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/BoxView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/MarginLayout.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/MarginView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/Shapeable.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/ShapeableLayoutManager.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/ShapeableView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/SplitterView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/Spring.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/math/Spring.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/math/SpringVector.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/toolTip/ToolTipExternalWindow.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/toolTip/ToolTipRootView.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/toolbar/Toolbar.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/toolbar/ToolbarTray.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/Documentation.html create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBBreakpoint.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBBreakpointsList.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBErrorReporter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBInstructionHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBInterruptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBScriptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/Main.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/sample.js create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/CallChain.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/ControlPanel.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/JSLogger.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/JSLoggerAsIFCApplet.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyErrorReporter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyInterruptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyScriptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/README create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugController.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugControllerHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugControllerHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResult.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResultHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResultHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporterHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporterHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHookHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHookHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPC.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPCHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPCHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocation.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocationHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocationHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfo.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfoHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfoHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadState.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadStateHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadStateHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScript.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHookHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHookHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSection.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSectionHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSectionHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProvider.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderPackage/sequence_of_stringHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderPackage/sequence_of_stringHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringReciever.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringRecieverHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringRecieverHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterface.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfaceHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfaceHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfacePackage/sequence_of_ThingHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfacePackage/sequence_of_ThingHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/Thing.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ThingHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ThingHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IDebugController.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IJSErrorReporter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IJSExecutionHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IScriptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_ISourceTextProvider.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_StringReciever.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_TestInterface.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IDebugController.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IJSErrorReporter.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IJSExecutionHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IScriptHook.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_ISourceTextProvider.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_StringReciever.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_TestInterface.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IJSStackFrameInfoHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IJSStackFrameInfoHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IScriptSectionHelper.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IScriptSectionHolder.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/jsdebugging/tools/depend/Main.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/nativejsengine/IErrorSink.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/nativejsengine/IPrintSink.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/nativejsengine/JSContext.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/nativejsengine/JSRuntime.java create mode 100644 mozilla/js/jsdj/classes/com/netscape/nativejsengine/README create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/DebugBreakHook.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/DebugController.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/Hook.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/InstructionHook.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/InterruptHook.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/InvalidInfoException.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/JSErrorReporter.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/JSPC.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/JSSourceLocation.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/JSSourceTextProvider.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/JSStackFrameInfo.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/JSThreadState.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/PC.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/Property.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/README create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/Script.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/ScriptHook.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/SourceLocation.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/SourceTextItem.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/SourceTextProvider.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/StackFrameInfo.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/ThreadStateBase.java create mode 100644 mozilla/js/jsdj/classes/netscape/jsdebug/Value.java create mode 100644 mozilla/js/jsdj/ifcui/install/install.js create mode 100644 mozilla/js/jsdj/ifcui/run/images/AbortTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/BreakpointTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/CopyTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/EvalTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/HalfSpaceTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/InterruptTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/NarrowSpaceTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/Nautical.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/PageListTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/PasteTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/RefreshTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/RunTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/StepIntoTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/StepOutTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/StepOverTool.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/ToolbarCollapser.gif create mode 100644 mozilla/js/jsdj/ifcui/run/images/jsd.gif create mode 100644 mozilla/js/jsdj/ifcui/run/jsdebugger.html create mode 100644 mozilla/js/jsdj/ifcui/run/jsdebugger4server.html create mode 100644 mozilla/js/jsdj/ifcui/run/license.html create mode 100644 mozilla/js/jsdj/ifcui/run/readme.txt create mode 100644 mozilla/js/jsdj/ifcui/run/samples/badlines.html create mode 100644 mozilla/js/jsdj/ifcui/run/samples/images/item1.gif create mode 100644 mozilla/js/jsdj/ifcui/run/samples/images/item2.gif create mode 100644 mozilla/js/jsdj/ifcui/run/samples/images/item3.gif create mode 100644 mozilla/js/jsdj/ifcui/run/samples/images/item4.gif create mode 100644 mozilla/js/jsdj/ifcui/run/samples/include.js create mode 100644 mozilla/js/jsdj/ifcui/run/samples/index.html create mode 100644 mozilla/js/jsdj/ifcui/run/samples/layers.html create mode 100644 mozilla/js/jsdj/ifcui/run/samples/misc.html create mode 100644 mozilla/js/jsdj/ifcui/run/samples/props.html create mode 100644 mozilla/js/jsdj/ifcui/run/samples/recursion.html create mode 100644 mozilla/js/jsdj/ifcui/run/samples/runerr.html create mode 100644 mozilla/js/jsdj/ifcui/run/sounds/droplet.au create mode 100644 mozilla/js/jsdj/jslogger/JSLogger.html create mode 100644 mozilla/js/jsdj/stub_classes/README create mode 100644 mozilla/js/jsdj/stub_classes/netscape/applet/EmbeddedProgramOwner.java create mode 100644 mozilla/js/jsdj/stub_classes/netscape/applet/EmbeddedProgramTracker.java create mode 100644 mozilla/js/jsdj/stub_classes/netscape/javascript/JSException.java create mode 100644 mozilla/js/jsdj/stub_classes/netscape/javascript/JSObject.java create mode 100644 mozilla/js/jsdj/stub_classes/netscape/javascript/JSProxy.java create mode 100644 mozilla/js/jsdj/stub_classes/netscape/javascript/JSRunnable.java create mode 100644 mozilla/js/jsdj/stub_classes/netscape/javascript/JSUtil.java create mode 100644 mozilla/js/jsdj/stub_classes/netscape/security/ForbiddenTargetException.java create mode 100644 mozilla/js/jsdj/stub_classes/netscape/security/PrivilegeManager.java create mode 100755 mozilla/js/jsdj/test/jsdb.bat create mode 100644 mozilla/js/jsdj/test/objects.js create mode 100644 mozilla/js/jsdj/test/sample.js diff --git a/mozilla/js/jsdj/README b/mozilla/js/jsdj/README new file mode 100644 index 00000000000..1097d61f79e --- /dev/null +++ b/mozilla/js/jsdj/README @@ -0,0 +1,30 @@ +/* jband - 09/14/98 - */ + +js/jsdj contains virtually all of the Java code for JavaScript Debugging +(native parts of the code for JavaScript can be found in js/jsd). + +This includes the full source to Netscape JavaScript Debugger, adapter parts, +jslogger, a simple console debugger, a test system, and some build tools. + +The notable subdirs are: + +build - stuff to build the code +classes - trees of source files +dist - generated output dir +ifcui - auxilary pieces of the JavaScript Debugger +jslogger - auxilary pieces of a smaple JavaScript logging app +stub_classes - stubbed out mozilla classes to allow standalone debugging +test - a place for subsystem tests + +The source to the debugger lives in: + jsdj/classes/com/netscape/jsdebugging/ifcui + +All building is done in: + jsdj/build + +*************************************************************************** +*** 09/15/98 +*** NOTE: some of this relates to code in js/jsd that is not yet checked in. +*** New stuff in js/jsd will go in when new js/src lands (later this week). +*** I decided to check this in anyway... +*************************************************************************** diff --git a/mozilla/js/jsdj/build/README b/mozilla/js/jsdj/build/README new file mode 100644 index 00000000000..81493e379b4 --- /dev/null +++ b/mozilla/js/jsdj/build/README @@ -0,0 +1,33 @@ +/* jband - 09/14/98 - */ + +The build system here currently supports only Microsoft nmake (I use the one +from MSDEV 4.2). It assumes that Symantec Visual Cafe is installed (i.e. it uses +sj.exe), and also uses awk. I mostly use the 4NT shell, but I think that +everything still works with the default NT shell. + +This system can build all the Java code here. It can also do jar packaging (with +dependency checks to assure that you have the right stuff) and produce javadocs. + +Netscape's JavaScript in Java engine (known as Rhino) is not currently available +to the public. The flag 'NO_RHINO=1' is necessary for many of the makefile +targets when used outside of Netscape. + +There is code here to also build a Corba/iiop connection for remote debugging to +a Netscape Internal version of Enterprise Server 3.51. This is not fully +functional on the server side. You should normally use the NO_CORBA=1 build +flag. If you want to play with this stuff then you need an install of ES3.51 and +you need to set the ES3_ROOT environment variable to point to that install. +(e.g. mine is 'set ES3_ROOT=E:\Netscape\SuiteSpot'. NOTE: the code in +com.netscape.jsdebugging.remote.corba is *generated* in an 'interesting' build +system in js/jsd/corba/src -- it would not be a good idea to modify this +generated code. + +'nmake -f jsdj.mak help' will display a list of possible targets (might not be +up to date :). + +'nmake -f jsdj.mak all NO_RHINO=1 NO_CORBA=1' will build everything. + +There are a few .bat files for convenience to build the targets I often build. + + + diff --git a/mozilla/js/jsdj/build/gen_date.awk b/mozilla/js/jsdj/build/gen_date.awk new file mode 100644 index 00000000000..e278faa4daf --- /dev/null +++ b/mozilla/js/jsdj/build/gen_date.awk @@ -0,0 +1,31 @@ +# +# This requires -vpackage_name=whatever.the.name.of.the.package.is +# + +BEGIN{ +print +print "// generated automatically by gen_date.awk" +print +print "package "package_name";" +print +print "class BuildDate" +print "{" +print strftime(" // %A, %B %d, %Y at %I:%M %p"); +print +print " public static final long buildDate = " systime() "000L;" +print +print " public static final java.util.Date date()" +print " {" +print " return new java.util.Date(buildDate);" +print " }" +print +print " public static final String display()" +print " {" +print " return date().toString();" +print " }" +print "}" +} + + + + diff --git a/mozilla/js/jsdj/build/images/blue-ball-small.gif b/mozilla/js/jsdj/build/images/blue-ball-small.gif new file mode 100644 index 0000000000000000000000000000000000000000..d4c5cde5b005117d443e595db216e8a212831f75 GIT binary patch literal 255 zcmZ?wbhEHbWMg1s_{zYrfB$|4hW}cM-Hp}9+?~z|3!KYIKF7jvjf3Go2g7@IhGW&$ z$JiOpi3t2RH2E*U0Tg`B!7!(1`TwQI{!0k_XJ**T$}mMlphZLRKR?GcCWaOkhA4K1 zdu$9_*%^}e?>)xJu$PTtEdyf|1A~`FZ#itU_uxX2H&oKM(5Rm1JCoE59jPZuy1E+ zQx>xD8(@q9h(scxP{`qMEG#SxhJE31IFU%Sx3?Q}pU+p2cT7HDkb(2MAd8c!3H|p(}ox{^0PDpsEsUa1^qp%-^D8l6;9WGRe zP!y3;$?3#353k7{DmW<-sU+(V7-|{Bc?cRxHMyUnlo31QWrGppY7-C?SeX&Zqci_J zBeg0@`(bqxo>?TF6Wp-ckv|6^2wpZFoMIOBlb65za78a8NwM%&)P0!cw7{(4R}(8!arG)0e@W2D=$^=?I!3g;gyB zYPzvmiX9LMaizhP4zWs9PD|9dsQ;xbf6`I_Gd3*+Uit}e-N@$FR*p3mmR(NI$gI0n zZ82qL6$s@mjlQ}}+j!fz%&Eua%S_f5Q}Muv5NP?Bv-5RzvF+K}Sof9UHC4x-ocGUG z+_@V|?RCU{{_5K>))?t7s4V}Hx4B`mYt?ew8Si-0WT)vCchA82$$Gynhq literal 0 HcmV?d00001 diff --git a/mozilla/js/jsdj/build/images/class-index.gif b/mozilla/js/jsdj/build/images/class-index.gif new file mode 100644 index 0000000000000000000000000000000000000000..7f276bcb242e6136502f60bded36f5326bab534a GIT binary patch literal 1497 zcmb7@`%~0a7{-q?Y2KDe%mI-s1Zg3Lq|>U9H@q)oZA_wrilXB|E=pKl8zj6SB5Fp8 zXOz`l5pa=3G+L50Nh&suiZrl_kfVW;GUh4kd&U!U++CNP>z|LK&f)P(i3vmy8m|2;+na!lZi3DdCK8PPiaks#ZaX zU_@{t1Q8NSL{cIdk(@|DBnoIl8d_+^YpLd_!zksH3QDCKi;6MIIAww|sVH#C8ReXE zLAg{=cq;@s2+pMn68z$KT0OXP^85dgUG96`e^qC_6RL^t996AZ&4s38Vu zbOH+;7z}MlOSK~P8rP_CBsPX1;SXa`2`SYA-RoBr?v1K_x|gJ&+_|gux}#K#?sU|) z-G&vi+k;xZ8%sHGPl7Z)2W$!9!IOIw(P%V2K0aElR;SZVn>Nj0Ff3ZMC?zFj{rdIU z+1dH|`6iReYPHtX)Y$FzmX?-|jt-~O`J(r~5BdN9__<}pmb4n9Z9n@a?hATOv ztRVHKb8Ug_JO?zAU*t+|oqHFE7ct~(2s zRL>YU?^9dVx+7Wsu7doG=H`GSYduya{{ETgM(^Qiz3DSis|(XE$n;|UZf+jdXZ+$ldQ1JNEdy^k0>1w6x%c&$tzqFE zJ16a*v1EVvnb}3FpJg1lWoUcc(!Ok}CGl86WWVFf3nOBait?T&1&-nyE){#~w#E#d zXUYk*XiZatT1yJQyf#2vm}v|u*}aKbV$G$RUz18mNU+6h%xzs^IyS1e_2|cQ!u<|S zj`?;&SIPcet$&tQn|p^?j~k=zojAj;TB6efbCQZ3rBT<+Rkx$&TN`JVbypPkn;Cqv zHjwY#R$q*XUmM{3yP~EmG`YRF$usvs-SnXM$Cw9J4oW}&>bkbdpEb);8>^0OOnqqI p>k)8jN|U+!VS~rMK|SJK|A6F+xd;fVotzLv!E_;6g3$T1w}NPM3jIUWkF9VMnaJ?7!MRd5-x%Z z3LYW|=z$GH6piKJa4j&xA%Y`F69*Ad8IH1fzi0k|>@PR(?7q+Yd7k%st6f&v*zTCD zV~qOHmxB=^2vLL>LL5PbF~S64iZDZ%3zq~VLJ*;dFhscUmSRK+q7+evC>L58MvNdv z5o3sPP(mCdP7tSvGsK|)ZIA{nXolBZm?Ip5F~yi+%!RQ~5rPTDgki!33b>>MQ;I3W zlnYSsmJ!S-W(+e9jL?cX!JJ~wFo&r?4PpQdlz;_yFc`E!8nmF93xOTFql7WSIJgHWcuP1XoDmN8AP>NVZioZ?0|Yn(Y7hfxpoFKu0fRvs zq(O@d$qCm`!(o(iAxQ8CW1(V=R&NgxfM18fPx15esfNKa2sBodjLnp#;|IXXIS z*s#IV(^DdmgoK2|#Kg#CGPzu?P$)`EOI0dWZEbB!OG{5r&zIi+KIH%ZGpqk=9fZ_q zfzT@aCq|9ts9=nNbK#kP{un*k{FjPC`MubQbG&rX_n8llO~ZQ{DlYAGh%<7Woi%!6 zmP%&2DetiJ<>tzSg`Q>M?)$SJrI~v)-#`DGiDQzPx5l7zlIai0%M(Se=1IBLIhF|y zo*f7Bew6)`v&SDMMVp@qLQI|`no1|B4-r;d?(S(5nQD|@7!*%v+6*t@$cih^jO3z-_ zKj-z;0z;+uLVUsdg?;zd_*2&`_dYtm6L;OR3)z1A`k0^F4C(?Utq-;-UtSd3cD1HQ zt=c?Yf1u;_(@l;%((Pn%RfjS|H_($2^eOY?M#N~bO?AnhF8+nXD5e}ZP@40owvtx@chsqReypS#4b0{irm zr%8W3D)u_0Kgr}((3^M>a>udT{l#7pi`!!7I$OBe zY>moxvXRS(+;@6}?Ok=&U*oolXD1tb*&0V#br!d#+K5crPfbiJnU%J?sBPBYtKFok{j@=WON=!OZ zRS}w*heb+NPWGJ>{Dzq%Cd|&`#G2!xU2#4uax;$8h0jxBE_WW;lG|W7kX)EaKIY0D z-kHnKZZC_=OR3Hl%{v(tY5V%Zh%$ZSoT62`7vv-rjcvc=JTKJf%AJ^svqw^jRwmqf z){)@MG)B{C34bM=3vj^+8De zaHz6W-+$1>cYR}UXSuk0aKr6#N!YU|oBfA;bW8j+pBjSKPw9ObYcae|bKHNpzayt0 K@{>+9vi}!y*+B~c literal 0 HcmV?d00001 diff --git a/mozilla/js/jsdj/build/images/constructors.gif b/mozilla/js/jsdj/build/images/constructors.gif new file mode 100644 index 0000000000000000000000000000000000000000..d1a6ae507ca808dd0df7f7cef51fbb3a4aa7050a GIT binary patch literal 1565 zcmb7@`BT$J7{=GpatY&z(?V0l;su7H(iP8Qn<5spb?_P#3@YdX;ZRX4P(`hBSV=u7 zghio(igJfbw5ek&ibPkPVhIxBSP+q>5{w|AwzGXV_8;i}l6hzMecsRWyx)8guw>r+ zO;6D@G=$zBj1WPHBE%5l2r7&bCJ0l68Nys#5{w8zgd)Na;o>dDh!R98q6|?kS{X)+ zAVv{mh;dLt93xH;r-(Dep#W`=1}$iY*IdjIhhR)GW*BoZ7Ait8p_njCxS)VbN-(9E zGEBLEg13xdMloZUabSd2%n9ZcbA~xg1!@ojXrKfvxP!r<4bq?m&0H7~H5^I^BZLco zFcvCG31x(GVHYUil2O7KVI1586uc#z63z$*dyofULN~+#{s96U0yT&MG*H4*;DEuP z4bq^+MRMXAYB-EiE`kJqFcvDtDC3YT*aZr>q?}O>IYQD90C2%`2pZf%l#mBtLN~+# zOkfxs0yT&MG;{(MaKK>D25BxQL#_Uk_40` zcd=eel!DQcj@Y)vut2tW5X-k<2?v%*APt`bYze{xPnJ>0!NEZyk+{3NdwYBP`uYY2 z2Fm5~=;-K#goM=8)XdDxf`WpIiVBTJqt$A4I$c*+m)UH7+xy>#{QrMkUyT}pP%HXK zw2J?PwGBs=w&VTPr++vLtWSe&C5UiYa%9Qe|6;evj=L2s%x`zSDIw?Tl%c-NViGlhxWYb zbg);QZdb;w)iJU zi)GbC(_haHzLnnx`glm1({CX=jJ)nK6}Z5pQl>FKD=0?lU{8x4m^tvV6zhm*xGxxn=L^pPwb) z-+pfB(SgAyZlU|0r!;OzyzV(XA&OI#(}o5=cS)R!F2X5c*u1;#kYU%n&=g7X+RkND zCPfye*h%Mf>>u^*w8t4O@2kS%2VO;l9viyiyiOVBnd6*3!_=cnUZ~IR*x}n4@ zamopE$IY(bB*)^($84oG@20J{8h)bOW?J({qSP+xasJ_pmm>XK^AjVFOIL&&i;F^2 zj3pO3uNzC&u6Vu5Sn8rR{#fMG?B8?h(;3sxRQ}RE&~u^SO0Kc2@#1%7RV8}6u{E1z znzE{sb_v}n4OX`&vDn}>;CR*@=WtE>>hcw%u9i1PVM(|otx2mZ=*z| zz9yS{XSK#=a_`p5%Y$O;K6AYv;?*3qyLXqYH2>N2*3GK&V@(%w%LnxvSKS_L-*$WS PkYQ(QY`uO&2U_?qzhC(7 literal 0 HcmV?d00001 diff --git a/mozilla/js/jsdj/build/images/error-index.gif b/mozilla/js/jsdj/build/images/error-index.gif new file mode 100644 index 0000000000000000000000000000000000000000..22835ff8c64d5af8369f589cf17819263a8e8fbc GIT binary patch literal 1438 zcmb7@`%lzI6vaohC@5C@P`jvk^|? z5d;SbWdYqTO;^}jqvfGkrC>*Fb%g>gsS2cmhETNxVwj#;`ww(}+1$+Bb3f;iL1qChzXF@O`;T}+U%Oqz~FbR9e1DNPW9PkeaI0QAs01Zk!1qTL08`98{ zDmitH8b@$0Rgmz9v8aULLLyh#1qCj-6kH-lB#i*Th35zwZV@H&04BN-2bf?O4nYku zK%)~_;J{#LLt3g8sn@thjU%x!1POl_i%LkT7HC_)qOfgL?bEg-1!c=!t=AT%Vzi~B zwrw-4kZm5+@@-hkfo&3`@i|~i2oIiYqllA}lSZS_YPCK-J|Q6?QBhHGad9arDLS1_ zuh$n96&VZ$v)SCx(9quA-r3pN-`_tvI{LErzYqEU|G17%n?gtz@lvhoKS5?plJgD= z!|N(r4$gSpBet#15JKim@h#V`c<08E1$6iCZS^}s4=;K(e^!L0roCudSXJXcbNg?W zuGl#*b^PQxamF{YC)DI^Y$;jgI`ORgJHw4b0R=g;$~Gk5stP~uk?LRU9(6YQ;~#|o zso^`t8>ZW5I(F7>IvU(ka>%2^wEm*k@%VfG8+UcoCB?NyZnF-pyRyEiEO4f7a7#tO z)HRQ1>gw)abGSddv$ylfR#UQ5%Jpw_=7&usp0}U87<)SKYh_IEp`TA=Cf@!s&3kp^ zME#cD;KUz08jJt#ZI4?ve{F5RzU02Dkg<+G?vAeQ_-X08>*5#EeZ#+0hiz&OptlAy z;wJB&3d$S*w5O}y*=5Ap_xXVJtAh7k${Y7Q?R7VfEw9L%w3fOh_T`i4T`qYSTC&U2 z?BYXXvbXIwF3vd-XmtrraJ#hqi{Z2a=Wyo-rCarxemX;e*8FDW0ej0U2?sOXOLrVu zG_kTe$#Y)#!_R6X+Pacw1AE6OA6<a$PY+xSsahrgG_qS18kzdTrL zvi#Pw+tYHjZ;0humwRY0_GevRW^O(3`P=0K7l(_?DYa`V8lHIsL^n=dym_Q~^LT{k h6*4{dmeFp0?0KX8(oaS%Ij(%1ZkZhxo4$$!{0r;mrQ`qr literal 0 HcmV?d00001 diff --git a/mozilla/js/jsdj/build/images/exception-index.gif b/mozilla/js/jsdj/build/images/exception-index.gif new file mode 100644 index 0000000000000000000000000000000000000000..e3830d9c52e7899bb62b56f56f71ba304108ed83 GIT binary patch literal 1707 zcmbu8`8U>C9LH}Xqh)ktwCQO(70S|bM@O0F6hqB4mZpZ3Wg>UtA%pNJ)C}RVWNXsR zGDNZ+OA8)GCLzm}7HbD(nL3pz&y*5z=ktB$Pni4L=iK{we_rqR=lk9Djk(d*!=f2l z=so)HV1x)l6d{HXM^IsmFhQ6i%n;_nCBcXgL?|K*5iY!?7*T>KMU)}Rg;s_UBZyJN z7-Afh5XXoU#3|woaVS6=q(KXs;WZcL2!~)yF=iNZVJuXHU_vorm~eptE-As3V#+Y( z0u;Pu1T%^m!;AwXv|>&$r25pcAEokO~A)$st31NhA!5@r; zic&%up>i?g0wk5>5$cgo8cE12CZ*;sE~u0S z(BeXJ!Zp-z7^PeY68ynfs2HP+L#|*KDBzNEMmgjNNkag@1i4AO_IT30S}ZgFzdlxv(PPHC#gthr`AoNbm<^p<VfhLy!GU5DNW=2Y1gr?V6vdC&FeDofQAAKSJ&p%Ka<2g?Q`?wv92@~H58 zUmKWZ$=^AiG-?`YJ$a?Zv24wor=zYar=}&N`<{xEe6$QE-bxzFFLyl*X&A6c3rgPV z=SZ+L`FyBygZAMAWa_63?~i8Xy#Xeh7OyfL(tno}shXIR5@FMKWrbv#9vBE!Ssy71 z5FM*^JIp zA}`&4o1>Ydb%f^Z!FVtAbx+b3pRijUfAj~HoJ5<6bq=R}FXbH#i#2?ao7W;YbGu?P zPg6TbGm1Yynjg6^(mh9d*1a!Fa$ff1vGUpzsTYF%sW`w&-S}l@hO;y|H>=FXJxb@( zl>C4{E1UDm?ktz37piY@*B7_>7m&-I^K_rzP&sSXS~c1*Y4F`Y%~iJ5?f2#u-)y(< zUM(w`Z@e<;h)I<=H{LmC#8BQZ_Bu5FmFW9Ab)_BhKh(NfylyUaDwNla8+2?;83`|N ztMy-!>XD%AEwXLgVB70mhac)C+%f2iDXpLUH3qXUm6jd9Yx+7>RB>{;Qm1%NOQYv~ z^JtH2?VC-v-{@H6GF94X_xR(rR*gxIw;fC3dOfoBh914$`L);IH+uF*O!?PqP;q;g z#L1$p9=AlUyw^hd){33GS-1Mo5N^6b@IHq>j zSIJ__;C(wsNwuYJ`qjSla?8El4!`$%JZ^%Y%Vod7l5t)m2T*2osjI1th4qU;ET zqaQM8*dde{LLf;n7Q$h%>a}2d6BZ}%!kd1Kx^Opw)rz+x{Tn@3--idD?}zWh)6;jd zGcwkQMr;9`a{z@xA(zX=VzJH5&3ryzsZp<{){O$yi%epSykn|uqsCFG;uQs@`U-Q52>&hCxbUfhhbH*< zB>$Y*;>5CWFNH~i)VTk>Ef@xd6|Ak}Sr+G1yrx#p!onhyvyf$I8o8|DgbdS^8B^nN z+)0X5PckXah|E;ohQu+zAy*+$M5vx(h;X8CQRl)y1(JyncUY1(&r~@XunVcwK3!g$ zus0?*ykNy*F;;py`Xb#zxY)so;OwjjFp~>BLwOtF^{{pz)k2J*pEnD39Sk=VFV;QC zdZFem+5pSrfV&hxCPZ^X^FTf&o99*LT>O9iOThor?E*YFxZQ651cX5}3442&<^o-U zD-=F6Kh`}}-+c6X@WQ;StLe{=`CzY)?rd;1?CE&>r2E1CzH9x#;1}QVy2jweZ!^)k b+wIz}<7UU3?Va8Cc|Xtde!pua;^hw8 zjf||(TlC+-2oZ!RLJT2}pu!kof-psxA=RGx;qh5&#Io!7NUea028_) z4qyVq;1H-m44|PCuz&*wgEmNWVMW4gxP}@IhmApy;19+^#W)uhXjs2MVc4j!Ps5S~ zC`0bTdJRzujD~cCZ5s>=$OaF>@(oym1H&YchR*@E1mS@v!zg5GYHDU?CK8G4?d_eN zojpB0WipvuE{}|ijEjp?DwSDTS$TPR8jYs5wzj#sS+Ca*3=BYT%l|l5BNL1eYC*Qb zpCJ4blZ-jaH?eRnICne7c$&@Dnt~@zXo}JDG*|WcdkHgfV0(?)|6crD$Kz!)_vO?o zMPBt=sZa)OfD`#(3>&3*R&OzPF4A zo;IzM7Tnc@d@=5%V!2vYw&F8!-u)Su|Eg&DD05=jjRAdi*!cODy$*x78_)M$D{rU$ z4Go!I@*F>!QB}Z?9}MUCRUWyyAf>HQ^z^h(r((`;L6#%Asp(gr z>C&a8%eJP~`OM5dZ6Y3S{9PPAGCMuqPx3hD*p@(Dw#__6c6{{vNL6mu`pYV(wU-rXRu@$H3aMh@m8c4-b&^bMvrByPlUQqc zhMn6K`&K{m4aM#IHSD{bvbo0!qM*tI806I{{V znVf%9KaTAw8P4$CTdd7^MAV}94(W+%r}#4!@g15kZ_V&$i6v9U4y06@e;l;8YI?+p zCAAjXN%QxX?sMxai*oyX|1GN&+t;_pX9s;-uFa|KL)~J7J9v9kbUL)^3?oK2)|{TGwO$>4&nV&5t%tFK$|uHM`)UYo>chgS1mI zSTph8kRSGK#JiBrc)e!?nL~x+glNYf_>1ctSxfly(4I(&Rl$|ch zQC=)sb|@{D6j&0BMQ|7``J~#ujKK-K@TOo8;ciA+3%-u@Z}eV0FE6~$kLTs>>N(aK z9BM=(RsqgAfI^{=%jF`GNUc`O=kt|HB_5AE!`&?drfK%|^#OB7n)GluJOEr7iK!?1 z_lV>1%TwUUWwQ?-n76NAEl|D4WX8yQrr9>?9F;2GQBbNcFvp1SKT@3wUn{t0f`3o) zZ<$q2EDLv17&Azni=S-4Fwn1JX&EoGIICfvS~&|dvrtb%QIJTGiwPW6V44bJS}cZ} zNr~!7CdU|2n5Ns1IYJyt6*5JT>M4dGCn}e8E`%zOO$4~ZlC*iI%1OvVFol3YBra;U zAR7p%@GV2mLek))mP02w3C%)MAu8}Ch?H0t#8fn<88L`SNx7!eE}3m7?1IMJumx}d zRWGQn(`YnWE|>WiEM;0tgM+X9{)Ltsi>(v*J(;ejCrj<^rS^T}{r+)3!gzD4yfk93 zjIDUVip652^nCDjx|wjPgA>8oSrK3+XLyEkAK?wKHX_wbj5d)s3HAmUZm3=?dyw@) z%Ug64ERO^3QUQgKgc}JDl;esytTE@}|Lb1@;xD%g@L=zHyZ#dp&R~nMt9x#0n>@Nk zLZLbGsEs`N5$ISPnr|EZ+1uPLJf05t4!+pBcHkU69Q!cQn?4cVan~b6&HI;%J6)d5 ipGSj{#>rdzKh|nNa(+5BY)`%InRw=U+S#xHhyDV{fCq2@ literal 0 HcmV?d00001 diff --git a/mozilla/js/jsdj/build/images/method-index.gif b/mozilla/js/jsdj/build/images/method-index.gif new file mode 100644 index 0000000000000000000000000000000000000000..a05e7051160fc7b579abde9ea02e0af9d796cb8e GIT binary patch literal 1588 zcmbu8`%{xg6o$8swRpi>TSNpV4x-$=j4LRL^)?VMSOH~<0#d3hj1-Vm5hF!Fjey!| zi9i;lTojQsL-?5@ zN4B8Z$c+9w7$JfXMTjB95mXo>Oc16BGlaRgBp4Bb2t|Y;!o^#P5haLHL>Z!7v@(ns zL5w2C5aXbPI7XZxP7!B_Ljl?#4O-9)ueq2b4#AjW%rNF+EL4PGLNQ^Oa6ti=lwe9R zWtegS1#cO_jAF(xB%Cnz=9}YB-b-MhF-F zU@TOW63PhW!Y)w2C8LBf!Z^4GD0oXaC7cls_8of`~w6y1ZofiXrP3rzyX6n z8>B&ti{!*L)NmN3Tm%XJU@TOOQN|%xunQD$Njak&a)hKI0N{e>5Hz@jC?OBPgl>of zn7}YN1ZofiXy^ni;DEuP4boh!NW6w?sNrzf7z7FaU@TOObFo0n`UQn$qhg9kFeTVS#M%AeL{z5)LerKpH*=*b;;Xo-Ct~wY9aKot=w|i>IgOnl)0!u=G)O9Ak>aL#GfGk ziI1!}IzQHa?S+zShpaw!3v1pjNjqxooYL=p(6Jm%Di=;&8gtq|~MRP4|B};=b)lgD$$eDa3ihu>6uKrbU$?FP|WH?bhMY zh*bY~i*{Yz>FdiS}N%Hvw!X9rJQ*7fKHjL%d_W>a*b{N9n9 zT?wi<=REmeMO%6jmjy>l;>V7%amZ+Jz1$OjXVt^Vj49cRBGVlH(FMkjjI@{dyJbte zj!Ft1Jdt{6t?Z9K^bH9MTfBXsR95-Owl{Ni>YJzE%_g}{zJ5RMD?8~q7&0w+di)zn z?7VGT3lepG=Du8?ys^$1n}f2tcMn&dizr-J?b@ZhP-_#lWz#Kb{*eu%))D2w?NaAM zOJrHkwq({VwkbX8H8`NkwzJApPL)0CkI%W1UvWGzD5Rn!&1+mmg=)Q9(YeH1uCt2v zb$UDI{A%L$VYzAgsBn4e$lIdRmFitC+K&RAzTS9!;*6k+P3sjNp8DmNp4Z%vt7dAl z^y7xA(xQw#r!=dNX#%?)4VvnwgZ(e+S$3$l=JBY>ahlFRee{{uvsUVT>9x1#=^N|D z$L-`9g<8YFn1=ILtcHFn&;Kg5zeKaZxiI1ShhL;<^)}IL{ zuX;VzNc_n?^6*eX7$KYxL5L)%C?%8;$_W*ON_EL7VT>?Nm>^85x118r2r&3Ufsi1}!pg{>N++i@ZAq_1wOJzvaIGi!Tm{k5S z78U1=3&y3g3kqBc&V*n>!abnymPyW}U=sF_2Qbl%IN%=;a0qIM0UDHe3Jwg0Hl(2? zRdVVYHICq1svzMHV^Imgg+#8f3kqCvDY!(ANE!iv3(pZW+#*Wk0Zeow4luzm9D*8R zfJP^&AkY zzA|DnueV(6$iI>i^R?G^jrUESI}=*BU1|@_sI*_RYCg1WHsnqWR1_R^bcIddxL$iG ztg~R*uj4;|U--l7wQhS?YA@-YoPX5h^>TVsSwuv*B{#&;+c0CEzdXM=vnubUGZVs; zn||7uX^jr=wd}fL4S&Wzt|~9n@YC)?HIoOjC+(fbM{M7$dG%Iz(_%U4mh;}g;(c#J*zTkXX+1f0xs*;Ex*Z%Accf4NMA8e@V-`baM8Lsr( zn^bFvjCZNk|J~M=QsL$}`)=iqmYe2EZRgG2V|_oGhl?I~#-x4v$lO+kc6WDd!?EoA znJ20X7ivyq(fGSJQnP$#8xjvcy?XRy)tf=5>Ob)w8?8uucJZl`rmdQ>>K9YTbmm<( z$s?8(V{c~+G*)OdBS|H@KF@4+EVXzxcQ}HAV~(57v7>W0xCJ*}@EG5jTY-cM>8=*uPvWoksuw literal 0 HcmV?d00001 diff --git a/mozilla/js/jsdj/build/images/package-index.gif b/mozilla/js/jsdj/build/images/package-index.gif new file mode 100644 index 0000000000000000000000000000000000000000..f894d4210d743ad9a4f0736159ef226279508dc1 GIT binary patch literal 1607 zcmb7@{a4Ic9LMi2iOh#iFQzPd{(&$DWDm~y-Q+B1=ob^z#cRzRRKd|?gIiGXy=lyxT-=FV%zi8ns z_mFNh3B5rd4n~L|L=j>LaRe2{2or=U!VF<9E(u12AVLvgh;Z?iVnhj|6j6pK7p)8< zMi8TjF~m41A&wCzh*QKF;!uD#NP`wM!)q?)h(j=@7&DBy7z-64m{3d@CR|X!B_)_r zOc|zJK*3u^Fr%0;%s4PYE9L}qiaEm^rUEsH0W?qo7Tm#L&<1JHf@UrZi5de0KNt%Y<6JDzynaDp-l*88c}W7w zoV!@BIZDB3PDgCpY*-+hJ&5I-v4jKjB#?&B0k#C;fhY4QWNB$>ZEfxB>@1Z^Wir{) zrArkGMR<64TwI(=rAkXn%gM>nXfy_c!Duwr)zz6yrrzG(5550=$p8PxzHjhH2-Tyh zqE-ASh7RNCf`yG&QTFwuVOB1Idq*Oq8aYvZqO!*R=KgUwthrKq`bM&?EXCpNraaHX zjz66N)es!jUcWX1XYG=piCgl%ydFXgAW7>`}2MU(|aqo#IJfqkD~ZDZRBg4 zfmsXM!*ZHk~`<%&WCR0-7Pd@r@r}J{NeK2OB1#}DUQvG zXc?pu2k0x%JTz1S9 zHS@^cr@#0I#jiR#;+x5xS&e7nbpDX&%w&F0jtKlL4Z5+f|~j=H+L6=dwTt!$6W=rEcR(-X$8 z&)u2du|8YZlYh&}x#!RIdNR9)^ucQ z%kJN)+ORO3C&_201iKS$7W2B$d;n*V#Q{a^b2zd+Dl2Foc7nk@o`{}q$3aX7UwXhtze++%Rs z%3zqxAaQK(-n|TlYZ(lq7!g_I20uKI2S4!EsS88&8xncF+^+0Bu|S=In4~#0Kfh|*#H0l literal 0 HcmV?d00001 diff --git a/mozilla/js/jsdj/build/images/red-ball.gif b/mozilla/js/jsdj/build/images/red-ball.gif new file mode 100644 index 0000000000000000000000000000000000000000..dca92960148cb3751f9b2de8cf96f26293c15888 GIT binary patch literal 527 zcmcJMziSg=9L66(&J2aVi;%_P#(>K^^{z=xdQDRM#@aO1)Lefl7qX-fl+XW@ z`sd~iK*8Nv#q1N@I((tDJMPhfrt8|m(PBE2S-O{9?Btd+#!9}BE#}%E=LltubdV+?^w{QDD&UP!DFem}Dv;v1J$vjQXn#5L&hGoXpXYhMXJO!inX^7A zCoW`=yf~B)MhGWF5F!aGN(p6zazX{6Qe84i7$b}mCJ2-2EvJMt!a3oBaH(1aC4v#b zi4a6cC=p4CWJGcz1(7JA4QXhh8Ly?9qYk5#Qz|HxYAhi>)@zPZF`Cm++cq0k z$Yu{}`DQHTz&r`k_#Ch$ga=RNQN-HX+R@R`)z#J8+uPsYKO`h1Ha1qH(WIrNWo2dQ zbh^^gQiH)@G#X7NQ)_E$S65eGU*C(~|32jZ|MTXP5yJ>+Bc7^N{U?ZpB*!f$1k{%N zw9CTQeZ|=gPMO)(&OrwQ>JI;`9cS-5!fE5GmOLl_z0)n~j-1&uepc=Z(>G-;`Bvfk z=UmAzU!;G}>)g7Nx`gwE^HQcRw$wTO_Ql-zu@m>(C5Du~k`olU_OV+~&C3Ve%VIXU zT{;$?x3k|TwAZiB*OWDVs6Qt9L}dNa)r)L;qw5#-GPBI#OXM(@LYH8b3x2dkbwK!_vM#9J0ulWXa<}|F|Q=(aZ(;@n^_MF5? z8P12-tlB%teK2-&iS;PwoOe%+y138Z#*$~-`BirAcHViX-TzXEPQTecb@1){bW^~! zg4z1^)w@H(Xk^i9{jA&i$uVg*+7Gr=lwv_^XsP^%?opPJ5soE{~HGv*;FUaUo+A%=}>Om=)~x>;qP=; z^4xRP)yIP}?KKr+3M(#G?})kDQ&roO(QT-?_4+YG<4T`iL*c~qw%W3Ro{B1wn-o%{ zx9oB~+UQeL^?g-Ok;k`(!-hB~_rFj4aWC+mF@COAQ>;zyo!aovUz+5w sV|x$W|B-~xxKKUJVcmv^iyhk@oVFVJ^>GG~+d!Ip#fx=rYg;qjqp&5*56)XiS!CEk;f*N9g1|_g?hr!T>G_=sn#*nFTl$2UZHvTXc zl~Ph^so2;B1unIcT1(Av4=B8qtR!p6u!lT=iEhLJ|A2r)P(uvRpu|&fU@){H4J|gw znQPQIS}8U`!XL(>(pqUouCNOVTq@Rzkt32u0N}!N1P!-{5_td<-G~EBFbs#Fh8UpH z2`q46Ftj1fW<};Tu2JJKHijVK4`WejX0t$R{f5HYsM)8rBm-sTZq{o>X&9|^%(gAV z2HEmpmTzGh2i7D=<8#245FR{PqsV5nWoBmP=jS^dj*^m+^73+z$5UHd+t}FX^ZERK ze=ryfg+c=Z1JP(S7K=?xOw7*CqWAxt2X5YZ2hp!oVEzR2Pf#*b@4SU8j~^P|m7KP0 zbL4n%t=ta^Brz7Yn*0v*W}2vK%QBZTk;Lc4x2q__vi;C;Ij+aerHQbj9Qk zfd?x~e=hb{m32Q+eYL6R>&s7em9{4}^cOCTe4g6jJXmvZ+4CJMjyQX2?z>pAbM;Wm z3+I2Sig#@o&iSIaV#~%OTjMP~?asv`eQsCy+H3BIqCM5u#)lp&EJ&PoZF1UfubuRa zJonDCeP8XU+Z=s;rZg~Uzv4Z!^^r4^gX*t~=XTwdyXyA*`t_0ZmDQo;n;N7))Edhg z`svR1H*cVGn_1yGQ>SyfS?@qdw7`ZOiwT&55~ETNa+{JkWI3 zHaEL*PDNzwsRb{de`)9aqwd7&TYt|Vdu5TF&h}*liVp3WTjzVZBYYy=+nO=eu(v(4 zJH+eZ(#&07@DeedbK?}HuNH`pgXd~_-~XMfqPwk3g^ iwpSNByn%StZuwqqUW^!UHCRD16L literal 0 HcmV?d00001 diff --git a/mozilla/js/jsdj/build/images/yellow-ball-small.gif b/mozilla/js/jsdj/build/images/yellow-ball-small.gif new file mode 100644 index 0000000000000000000000000000000000000000..8e5f57cdfcbfbd4ccd3504bdae10cbc9215ef8ca GIT binary patch literal 255 zcmZ?wbhEHbWMg1s_{zYrfB*hN$Eweqb2@iU;N-dFYu6Zl|7Upqp5gE@hGWO7kDp`s z|6kz$AH(1OIUYY}m_CQ$|Er$=PnLfFFR*tnL;n)y sGDQbOfc(V3Cgadhz@e~&ha-_oX=Vt6)LFL4i~$e0dEFQiU0rr literal 0 HcmV?d00001 diff --git a/mozilla/js/jsdj/build/images/yellow-ball.gif b/mozilla/js/jsdj/build/images/yellow-ball.gif new file mode 100644 index 0000000000000000000000000000000000000000..2b8c0bb3d6baad5fdb28a878b33c265daeafe9d4 GIT binary patch literal 925 zcmdUu?@Lp06viLZ+znRy1_>)xIn!`b#FeO|s9b4wePPbBn*H=n%T~->M79@-tzUGr zgk@M-A&pDiD$Iko>IY+h7 z;uk)^$}` zsYCCFPT9nRx&>`_<=mB~>_lzjh5BeT`ry#|pyCRtW>sbVsu+o2h7g;?3k8bedZosL zS#xtU{pDwf8;jw#4EiR~c;_!-fdFoJ5DJAF+-!!7uOpn>jlEWU9>yad4vBcF1pEQq ze+cV-2m+i=cG`(N0kSNps%W?4s>CZUNj2M5Ca9t-0yDuv5GG+(kfXRfDsqTfiFXla ziNP$xL{fx0Cy7}C$nn7BW;_|i2xoS~WQBehW*>MFdLzbsrJOjr@WZj zXsA8&qsk~w&Wz{}U!Kc;=uf $(JSDEBUGGING_DIR)\ifcui\BuildDate.java + @echo building com.netscape.jsdebugging.ifcui + @sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\*.java + +com_netscape_jsdebugging_ifcui_launcher_local : ifcui + @echo building com.netscape.jsdebugging.ifcui.launcher.local + @sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\launcher\local\*.java + +com_netscape_jsdebugging_ifcui_launcher_rhino : com_netscape_jsdebugging_api_rhino ifcui + @echo building com.netscape.jsdebugging.ifcui.launcher.rhino + @sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\ifcui\launcher\rhino\*.java + +com_netscape_jsdebugging_apitests : core + @echo building com.netscape.jsdebugging.apitests etc... + @sj $(JAVAFLAGS)\ + $(JSDEBUGGING_DIR)\apitests\*.java\ + $(JSDEBUGGING_DIR)\apitests\xml\*.java\ + $(JSDEBUGGING_DIR)\apitests\testing\*.java\ + $(JSDEBUGGING_DIR)\apitests\testing\desc\*.java\ + $(JSDEBUGGING_DIR)\apitests\testing\tests\*.java\ + $(JSDEBUGGING_DIR)\apitests\analyzing\*.java\ + $(JSDEBUGGING_DIR)\apitests\analyzing\analyzers\*.java\ + $(JSDEBUGGING_DIR)\apitests\analyzing\data\*.java\ + $(JSDEBUGGING_DIR)\apitests\analyzing\tree\*.java + +com_netscape_jsdebugging_jslogger : + @echo building com.netscape.jsdebugging.jslogger + @sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\jslogger\*.java + +com_netscape_jsdebugging_tools_depend : + @echo building com.netscape.jsdebugging.tools.depend + @sj $(JAVAFLAGS) $(JSDEBUGGING_DIR)\tools\depend\*.java + +com_netscape_jsdebugging_remote_corba : initial_state + @echo building com.netscape.jsdebugging.remote.corba + @if "$(ES3_ROOT)" == "" @echo !!! ES3_ROOT is not set !!! + @if not exist $(ES3_ROOT)\NUL @echo !!! $(ES3_ROOT) does not exist !!! + @sj $(CORBA_JAVA_FLAGS) \ + $(JSDEBUGGING_DIR)\remote\corba\*.java \ + $(JSDEBUGGING_DIR)\remote\corba\ISourceTextProviderPackage\*.java \ + $(JSDEBUGGING_DIR)\remote\corba\TestInterfacePackage\*.java \ + +com_netscape_jsdebugging_api_corba : com_netscape_jsdebugging_api com_netscape_jsdebugging_remote_corba ifcui + @echo building com.netscape.jsdebugging.api.corba + @sj $(CORBA_JAVA_FLAGS) $(JSDEBUGGING_DIR)\api\corba\*.java + +api_corba_fast : + @echo building com.netscape.jsdebugging.api.corba + @sj $(CORBA_JAVA_FLAGS) $(JSDEBUGGING_DIR)\api\corba\*.java + +########## packaging ################# + +JSLOGGER_CLASS_FILES = \ + com\netscape\jsdebugging\jslogger\*.class \ + com\netscape\jsdebugging\ifcui\Log.class \ + com\netscape\jsdebugging\ifcui\Env.class \ + com\netscape\jsdebugging\ifcui\palomar\util\*.class + +JSLOGGER_EXPECTED_DEPENDENCIES = \ + -i java \ + -i netscape/application \ + -i netscape/util \ + -i netscape/jsdebug \ + -i netscape/security + +check_depend_jslogger : + @echo checking for unexpected dependencies in jslogger + @cd $(FROM_BUILD_TO_DIST_CLASSES) + @jre -cp . com.netscape.jsdebugging.tools.depend.Main \ + $(JSLOGGER_CLASS_FILES) $(JSLOGGER_EXPECTED_DEPENDENCIES) + @cd $(FROM_DIST_CLASSES_TO_BUILD) + +jslogger_jar : + @echo building $(JSLOGGER_JARFILE) + @cd $(FROM_BUILD_TO_DIST_CLASSES) + @if exist $(JSLOGGER_JARFILE) @del $(JSLOGGER_JARFILE) >NUL + @zip -q -r $(JSLOGGER_JARFILE) $(JSLOGGER_CLASS_FILES) + @cd $(FROM_DIST_CLASSES_TO_BUILD) + @echo copying $(JSLOGGER_JARFILE) to $(JSLOGGER_MAIN_DIR) + @copy $(DIST_CLASSES)\$(JSLOGGER_JARFILE) $(JSLOGGER_MAIN_DIR) >NUL + +########## + +NETSCAPE_JSDEBUG_CLASS_FILES = netscape\jsdebug\*.class + +NETSCAPE_JSDEBUG_EXPECTED_DEPENDENCIES = \ + -i java \ + -i netscape/security \ + -i netscape/util \ + +check_depend_netscape_jsdebug : + @echo checking for unexpected dependencies in netscape.jsdebug + @cd $(FROM_BUILD_TO_DIST_CLASSES) + @jre -cp . com.netscape.jsdebugging.tools.depend.Main \ + $(NETSCAPE_JSDEBUG_CLASS_FILES) $(NETSCAPE_JSDEBUG_EXPECTED_DEPENDENCIES) + @cd $(FROM_DIST_CLASSES_TO_BUILD) + +netscape_jsdebug_jar : + @echo building $(NETSCAPE_JSDEBUG_JARFILE) + @cd $(FROM_BUILD_TO_DIST_CLASSES) + @if exist $(NETSCAPE_JSDEBUG_JARFILE) @del $(NETSCAPE_JSDEBUG_JARFILE) >NUL + @zip -q -r $(NETSCAPE_JSDEBUG_JARFILE) $(NETSCAPE_JSDEBUG_CLASS_FILES) + @cd $(FROM_DIST_CLASSES_TO_BUILD) +# @echo copying $(JSLOGGER_JARFILE) to $(JSLOGGER_MAIN_DIR) +# @copy $(DIST_CLASSES)\$(JSLOGGER_JARFILE) $(JSLOGGER_MAIN_DIR) >NUL + +########## + +IFCUI_CLASS_FILES = \ + com\netscape\jsdebugging\ifcui\*.class \ + com\netscape\jsdebugging\ifcui\palomar\util\*.class \ + com\netscape\jsdebugging\ifcui\palomar\widget\*.class \ + com\netscape\jsdebugging\ifcui\palomar\widget\layout\*.class \ + com\netscape\jsdebugging\ifcui\palomar\widget\layout\math\*.class \ + com\netscape\jsdebugging\ifcui\palomar\widget\toolbar\*.class \ + com\netscape\jsdebugging\ifcui\palomar\widget\toolTip\*.class \ + com\netscape\jsdebugging\api\*.class \ +!IF "$(INCLUDE_SECURITY)" != "" + netscape\security\*.class \ +!ENDIF +!IF "$(INCLUDE_LOCAL_ADAPTER)" != "" + com\netscape\jsdebugging\api\local\*.class \ +!ENDIF +!IF "$(INCLUDE_RHINO_ADAPTER)" != "" + com\netscape\jsdebugging\api\rhino\*.class \ +!ENDIF +!IF "$(INCLUDE_CORBA_ADAPTER)" != "" + com\netscape\jsdebugging\api\corba\*.class \ +!ENDIF +!IF "$(INCLUDE_LOCAL_LAUNCHER)" != "" + com\netscape\jsdebugging\ifcui\launcher\local\*.class \ +!ENDIF +!IF "$(INCLUDE_RHINO_LAUNCHER)" != "" + com\netscape\jsdebugging\ifcui\launcher\rhino\*.class \ +!ENDIF + +IFCUI_OTHER_FILES = \ +!IF "$(INCLUDE_IMAGES)" != "" + images\*.gif \ +!ENDIF +!IF "$(INCLUDE_SOUNDS)" != "" + sounds\*.au \ +!ENDIF + +IFCUI_EXPECTED_DEPENDENCIES = \ + -i java \ + -i netscape/security \ + -i netscape/util \ + -i netscape/application \ + -i netscape/javascript \ +!IF "$(INCLUDE_LOCAL_ADAPTER)" != "" + -i netscape/jsdebug \ +!ENDIF +!IF "$(INCLUDE_RHINO_ADAPTER)" != "" + -i com/netscape/javascript \ +!ENDIF + +check_depend_ifcui : + @echo checking for unexpected dependencies for ifcui + @cd $(FROM_BUILD_TO_DIST_CLASSES) + @jre -cp . com.netscape.jsdebugging.tools.depend.Main \ + $(IFCUI_CLASS_FILES) $(IFCUI_EXPECTED_DEPENDENCIES) + @cd $(FROM_DIST_CLASSES_TO_BUILD) + +ifcui_jar : + @echo building $(IFCUI_JARFILE) + @cd $(FROM_BUILD_TO_DIST_CLASSES) + @if exist $(IFCUI_JARFILE) @del $(IFCUI_JARFILE) >NUL + @zip -q -r $(IFCUI_JARFILE) $(IFCUI_CLASS_FILES) $(IFCUI_OTHER_FILES) + @cd $(FROM_DIST_CLASSES_TO_BUILD) + @echo copying $(IFCUI_JARFILE) to $(IFCUI_RUN_DIR) + @copy $(DIST_CLASSES)\$(IFCUI_JARFILE) $(IFCUI_RUN_DIR) >NUL + + +########## javadoc stuff ################# + +ALL_PACKAGES = \ + netscape.security \ + netscape.jsdebug \ + netscape.javascript \ + netscape.applet \ + com.netscape.jsdebugging.api \ + com.netscape.jsdebugging.api.local \ + com.netscape.jsdebugging.engine \ + com.netscape.jsdebugging.engine.local \ + com.netscape.jsdebugging.jsdb \ + com.netscape.jsdebugging.ifcui \ + com.netscape.jsdebugging.ifcui.palomar.util \ + com.netscape.jsdebugging.ifcui.palomar.widget \ + com.netscape.jsdebugging.ifcui.palomar.widget.layout \ + com.netscape.jsdebugging.ifcui.palomar.widget.layout.math \ + com.netscape.jsdebugging.ifcui.palomar.widget.toolbar \ + com.netscape.jsdebugging.ifcui.palomar.widget.toolTip \ + com.netscape.jsdebugging.ifcui.launcher.local \ + com.netscape.jsdebugging.apitests \ + com.netscape.jsdebugging.apitests.xml \ + com.netscape.jsdebugging.apitests.testing \ + com.netscape.jsdebugging.apitests.testing.desc \ + com.netscape.jsdebugging.apitests.testing.tests \ + com.netscape.jsdebugging.apitests.analyzing.analyzers \ + com.netscape.jsdebugging.apitests.analyzing.data \ + com.netscape.jsdebugging.apitests.analyzing.tree \ + com.netscape.jsdebugging.jslogger \ + com.netscape.jsdebugging.tools.depend \ + com.netscape.nativejsengine \ +!IF "$(NO_RHINO)" == "" + com.netscape.jsdebugging.api.rhino \ + com.netscape.jsdebugging.engine.rhino \ + com.netscape.jsdebugging.ifcui.launcher.rhino \ +!ENDIF +!IF "$(NO_CORBA)" == "" + com.netscape.jsdebugging.api.corba \ + com.netscape.jsdebugging.remote.corba \ + com.netscape.jsdebugging.remote.corba.ISourceTextProviderPackage \ + com.netscape.jsdebugging.remote.corba.TestInterfacePackage \ +!ENDIF + +javadoc_all : initial_state + @echo cleaning up old stuff in javadoc directory + @if exist $(DIST)\javadocs\*.html @del $(DIST)\javadocs\*.html > NUL + @echo copying javadoc images to the dist dir + @copy $(BUILD_DIR)\images\*.gif $(DIST)\javadocs\images > NUL + @echo building javadoc for EVERYTHING + @javadoc -sourcepath $(JAVADOC_CLASSPATH);$(CLASS_SRC);$(BUILD_DIR)\..\stub_classes -d $(DIST)\javadocs $(ALL_PACKAGES) + + +########## before anything can happen... ################# + +initial_state : MK_DIST_CLASSES_DIRS $(IFC_DIST_FILE) + +$(IFC_DIST_FILE) : + @echo getting ifc11.jar -- if this fails you need to copy it to dist/classes yourself + copy ..\..\..\nav-java\stubs\classes\ifc11.jar $(DIST_CLASSES) > NUL + +########## directory stuff ################# + +# +# This list got too long so I split it in two. If you need to add more items +# then add them to the second list... +# +DIST_CLASSES_DIRS_0 = \ + $(DIST) \ + $(DIST_CLASSES) \ + $(DIST_CLASSES)\images \ + $(DIST_CLASSES)\sounds \ + $(DIST_CLASSES)\netscape \ + $(DIST_CLASSES)\netscape\security \ + $(DIST_CLASSES)\netscape\jsdebug \ + $(DIST_CLASSES)\netscape\javascript \ + $(DIST_CLASSES)\netscape\applet \ + $(DIST_CLASSES)\com \ + $(DIST_CLASSES)\com\netscape \ + $(DIST_CLASSES)\com\netscape\jsdebugging \ + $(DIST_CLASSES)\com\netscape\jsdebugging\api \ + $(DIST_CLASSES)\com\netscape\jsdebugging\api\local \ + $(DIST_CLASSES)\com\netscape\jsdebugging\api\rhino \ + $(DIST_CLASSES)\com\netscape\jsdebugging\api\corba \ + $(DIST_CLASSES)\com\netscape\jsdebugging\engine \ + $(DIST_CLASSES)\com\netscape\jsdebugging\engine\local \ + $(DIST_CLASSES)\com\netscape\jsdebugging\engine\rhino \ + $(DIST_CLASSES)\com\netscape\jsdebugging\jsdb \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\util \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\layout \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\layout\math \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\toolbar \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\palomar\widget\toolTip \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher\local \ + $(DIST_CLASSES)\com\netscape\jsdebugging\ifcui\launcher\rhino \ + $(DIST_CLASSES)\com\netscape\jsdebugging\apitests \ + $(DIST_CLASSES)\com\netscape\jsdebugging\apitests\xml \ + +DIST_CLASSES_DIRS_1 = \ + $(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing \ + $(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing\desc \ + $(DIST_CLASSES)\com\netscape\jsdebugging\apitests\testing\tests \ + $(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing \ + $(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\analyzers \ + $(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\data \ + $(DIST_CLASSES)\com\netscape\jsdebugging\apitests\analyzing\tree \ + $(DIST_CLASSES)\com\netscape\jsdebugging\jslogger \ + $(DIST_CLASSES)\com\netscape\jsdebugging\tools \ + $(DIST_CLASSES)\com\netscape\jsdebugging\tools\depend \ + $(DIST_CLASSES)\com\netscape\nativejsengine \ + $(DIST)\javadocs \ + $(DIST)\javadocs\images \ + $(DIST_CLASSES)\com\netscape\jsdebugging\remote \ + $(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba \ + $(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba\ISourceTextProviderPackage \ + $(DIST_CLASSES)\com\netscape\jsdebugging\remote\corba\TestInterfacePackage \ + + +MK_DIST_CLASSES_DIRS : + @echo making any non existent classfile output directories + @for %i in ($(DIST_CLASSES_DIRS_0)) do @if not exist %i\NUL mkdir %i > NUL + @for %i in ($(DIST_CLASSES_DIRS_1)) do @if not exist %i\NUL mkdir %i > NUL + +CP_DIST_CLASSES_RESOURCES : initial_state + @echo copying images and sounds to dist directory + @xcopy $(BUILD_DIR)\..\ifcui\run\images\*.* $(DIST_CLASSES)\images > NUL + @xcopy $(BUILD_DIR)\..\ifcui\run\sounds\*.* $(DIST_CLASSES)\sounds > NUL + +clean: + @echo deleting built classes + @for %i in ($(DIST_CLASSES_DIRS_0)) do @if exist %i\*.class @del %i\*.class > NUL + @for %i in ($(DIST_CLASSES_DIRS_1)) do @if exist %i\*.class @del %i\*.class > NUL + @echo deleting ifcui image and sound resources + @if exist $(DIST_CLASSES)\images\*.gif @del $(DIST_CLASSES)\images\*.gif > NUL + @if exist $(DIST_CLASSES)\sounds\*.au @del $(DIST_CLASSES)\sounds\*.au > NUL diff --git a/mozilla/js/jsdj/build/mk.bat b/mozilla/js/jsdj/build/mk.bat new file mode 100755 index 00000000000..1ec7e07ac4c --- /dev/null +++ b/mozilla/js/jsdj/build/mk.bat @@ -0,0 +1 @@ +nmake -f jsdj.mak %1 %2 %3 %4 %5 %6 %7 %8 %9 \ No newline at end of file diff --git a/mozilla/js/jsdj/build/mk_ifcui_std.bat b/mozilla/js/jsdj/build/mk_ifcui_std.bat new file mode 100755 index 00000000000..3ae832c1d12 --- /dev/null +++ b/mozilla/js/jsdj/build/mk_ifcui_std.bat @@ -0,0 +1,2 @@ +nmake -f jsdj.mak INCLUDE_SECURITY=1 INCLUDE_LOCAL_ADAPTER=1 INCLUDE_LOCAL_LAUNCHER=1 INCLUDE_IMAGES=1 INCLUDE_SOUNDS=1 %1 %2 %3 %4 %5 %6 %7 %8 %9 + diff --git a/mozilla/js/jsdj/build/mk_ifcui_std_fast_jar.bat b/mozilla/js/jsdj/build/mk_ifcui_std_fast_jar.bat new file mode 100755 index 00000000000..4c805778ef3 --- /dev/null +++ b/mozilla/js/jsdj/build/mk_ifcui_std_fast_jar.bat @@ -0,0 +1 @@ +call mk_ifcui_std.bat ifcui_fast ifcui_jar \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/README b/mozilla/js/jsdj/classes/README new file mode 100644 index 00000000000..e10e91a291a --- /dev/null +++ b/mozilla/js/jsdj/classes/README @@ -0,0 +1,7 @@ +/* jband - 09/14/98 - */ + +The 'classes' directory is the root of the JavaScript debugging pacakage space. +Older pacakages begin with 'netscape' (e.g. netscape.jsdebug which shipped - in +eariler form - with Navigator 4.x). Newer packages all start with +'com.netscape'. + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/AdapterLoader.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/AdapterLoader.java new file mode 100644 index 00000000000..c8ddfc7f144 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/AdapterLoader.java @@ -0,0 +1,29 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +import netscape.security.ForbiddenTargetException; + +public interface AdapterLoader +{ + public void setHost(String host); + public boolean isDebuggingSupported() throws ForbiddenTargetException; + public DebugController getDebugController() throws ForbiddenTargetException; + public SourceTextProvider getSourceTextProvider(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/DebugBreakHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/DebugBreakHook.java new file mode 100644 index 00000000000..492db9b7d7c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/DebugBreakHook.java @@ -0,0 +1,35 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +/** + * DebugBreakHook must be subclassed to respond to hooks + * at a particular program instruction. + */ +public class DebugBreakHook extends Hook { + + /** + * Override this method to respond just before a thread + * reaches a particular instruction. + */ + /* jband - 03/31/97 - I made this public to allow chaining */ + public void aboutToExecute(ThreadStateBase debug, PC pc) { + // defaults to no action + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/DebugController.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/DebugController.java new file mode 100644 index 00000000000..65b752c8881 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/DebugController.java @@ -0,0 +1,138 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +import netscape.security.ForbiddenTargetException; + +/** + * This is the master control panel for observing events in the VM. + * Each method setXHook() must be passed an object that extends + * the interface XHook. When an event of the specified type + * occurs, a well-known method on XHook will be called (see the + * various XHook interfacees for details). The method call takes place + * on the same thread that triggered the event in the first place, + * so that any monitors held by the thread which triggered the hook + * will still be owned in the hook method. + */ +public interface DebugController +{ + public static final long SUPPORTS_EXEC_TO_VALUE = 1L << 0; + public static final long SUPPORTS_CATCH_EXEC_ERRORS = 1L << 1; + public static final long SUPPORTS_FRAME_CALL_SCOPE_THIS = 1L << 2; + + /** + * Return flags which indicate what 'extended' capabilities are supported + * by the implementing api + * + * NOTE: this function is only available for version 1.1 and above + * i.e. if(getMajorVersion() > 1 || getMinorVersion() >= 1) + * + */ + public long getSupportsFlags(); + + + /** + * Request notification of Script loading events. Whenever a Script + * is loaded into or unloaded from the VM the appropriate method of + * the ScriptHook argument will be called. + * returns the previous hook object. + */ + public ScriptHook setScriptHook(ScriptHook h) + throws ForbiddenTargetException; + + /** + * Find the current observer of Script events, or return null if there + * is none. + */ + public ScriptHook getScriptHook() + throws ForbiddenTargetException; + + /** + * Set a hook at the given program counter value. When + * a thread reaches that instruction, a ThreadState object will be + * created and the appropriate method of the hook object + * will be called. + * returns the previous hook object. + */ + + public InstructionHook setInstructionHook( + PC pc, + InstructionHook h) + throws ForbiddenTargetException; + + /** + * Get the hook at the given program counter value, or return + * null if there is none. + */ + public InstructionHook getInstructionHook(PC pc) + throws ForbiddenTargetException; + + + public InterruptHook setInterruptHook( InterruptHook h ) + throws ForbiddenTargetException; + + public InterruptHook getInterruptHook() + throws ForbiddenTargetException; + + public void sendInterrupt() + throws ForbiddenTargetException; + + public void sendInterruptStepInto(ThreadStateBase debug) + throws ForbiddenTargetException; + + public void sendInterruptStepOver(ThreadStateBase debug) + throws ForbiddenTargetException; + + public void sendInterruptStepOut(ThreadStateBase debug) + throws ForbiddenTargetException; + + public void reinstateStepper(ThreadStateBase debug) + throws ForbiddenTargetException; + + + public DebugBreakHook setDebugBreakHook( DebugBreakHook h ) + throws ForbiddenTargetException; + + public DebugBreakHook getDebugBreakHook() + throws ForbiddenTargetException; + + public ExecResult executeScriptInStackFrame( JSStackFrameInfo frame, + String text, + String filename, + int lineno ) + throws ForbiddenTargetException; + + public ExecResult executeScriptInStackFrameValue( JSStackFrameInfo frame, + String text, + String filename, + int lineno ) + throws ForbiddenTargetException; + + public JSErrorReporter getErrorReporter() + throws ForbiddenTargetException; + + public JSErrorReporter setErrorReporter(JSErrorReporter er) + throws ForbiddenTargetException; + + public void iterateScripts(ScriptHook h) + throws ForbiddenTargetException; + + public int getMajorVersion(); + public int getMinorVersion(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ExecResult.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ExecResult.java new file mode 100644 index 00000000000..ff322c4a4fb --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ExecResult.java @@ -0,0 +1,33 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public interface ExecResult +{ + public String getResult(); + public boolean getErrorOccured(); + public String getErrorMessage(); + public String getErrorFilename(); + public int getErrorLineNumber(); + public String getErrorLineBuffer(); + public int getErrorTokenOffset(); + + public Value getResultValue(); +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Hook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Hook.java new file mode 100644 index 00000000000..1c322b1d814 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Hook.java @@ -0,0 +1,27 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + + +/** + * An instance of this class is returned for each hook set by + * the debugger as a handle for removing the hook later. + */ +public abstract class Hook { +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InstructionHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InstructionHook.java new file mode 100644 index 00000000000..99dd64e7935 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InstructionHook.java @@ -0,0 +1,50 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +/** + * InstructionHook must be subclassed to respond to hooks + * at a particular program instruction. + */ +public class InstructionHook extends Hook { + private PC pc; + + /** + * Create an InstructionHook at the given PC value. + */ + public InstructionHook(PC pc) { + this.pc = pc; + } + + /** + * Get the instruction that the hook is set at. + */ + public PC getPC() { + return pc; + } + + /** + * Override this method to respond just before a thread + * reaches a particular instruction. + */ + /* jband - 03/31/97 - I made this public to allow chaining */ + public void aboutToExecute(ThreadStateBase debug) { + // defaults to no action + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InterruptHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InterruptHook.java new file mode 100644 index 00000000000..3eeedf5f966 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InterruptHook.java @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +/** + * InterruptHook must be subclassed to respond to hooks + * at a particular program instruction. + */ +public class InterruptHook extends Hook { + + /** + * Override this method to respond just before a thread + * reaches a particular instruction. + */ + /* jband - 03/31/97 - I made this public to allow chaining */ + public void aboutToExecute(ThreadStateBase debug, PC pc) { +// System.out.println( "called the wrong hook..." ); + // defaults to no action + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InvalidInfoException.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InvalidInfoException.java new file mode 100644 index 00000000000..87262c52226 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/InvalidInfoException.java @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public class InvalidInfoException extends Exception +{ + /** + * Constructs a InvalidInfoException without a detail message. + * A detail message is a String that describes this particular exception. + */ + public InvalidInfoException() { + super(); + } + + /** + * Constructs a InvalidInfoException with a detail message. + * A detail message is a String that describes this particular exception. + * @param s the detail message + */ + public InvalidInfoException(String s) { + super(s); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSErrorReporter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSErrorReporter.java new file mode 100644 index 00000000000..32235d428c3 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSErrorReporter.java @@ -0,0 +1,33 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public interface JSErrorReporter +{ + /* keep these in sync with the numbers in jsdebug.h */ + public int PASS_ALONG = 0; + public int RETURN = 1; + public int DEBUG = 2; + + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSPC.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSPC.java new file mode 100644 index 00000000000..f5d55c2faaf --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSPC.java @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +/** + * This subinterface of PC provides JavaScript-specific information. + */ +public interface JSPC extends PC +{ + public Script getScript(); + public int getPC(); + public boolean isValid(); + + /** + * Get the SourceLocation associated with this PC value. + * returns null if the source location is unavailable. + */ + public SourceLocation getSourceLocation(); + + + // XXX need to implement these... + public boolean equals(Object obj); + public int hashCode(); + public String toString(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSSourceLocation.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSSourceLocation.java new file mode 100644 index 00000000000..a2593e60f52 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSSourceLocation.java @@ -0,0 +1,43 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public interface JSSourceLocation extends SourceLocation +{ + /** + * Gets the first line number associated with this SourceLocation. + * This is the lowest common denominator information that will be + * available: some implementations may choose to include more + * specific location information in a subinterface of SourceLocation. + */ + public int getLine(); + + public String getURL(); + + /** + * Get the first PC associated with a given SourceLocation. + * This is the place to set a breakpoint at that location. + * returns null if there is no code corresponding to that source + * location. + */ + public PC getPC(); + + // XXX + public String toString(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSStackFrameInfo.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSStackFrameInfo.java new file mode 100644 index 00000000000..125ceaa171a --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSStackFrameInfo.java @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + + +/** + * This interface provides access to the execution stack of a thread. + * It has several subinterfacees to distinguish between different kinds of + * stack frames: these currently include activations of Java methods + * or JavaScript functions. + * It is possible that synchronize blocks and try blocks deserve their own + * stack frames - to allow for later extensions a debugger should skip over + * stack frames it doesn't understand. + * Note that this appears very Java-specific. However, multiple threads and + * exceptions are relevant to JavaScript as well because of its + * interoperation with Java. + */ +public interface JSStackFrameInfo extends StackFrameInfo +{ + public Value getCallObject() + throws InvalidInfoException; + + public Value getScopeChain() + throws InvalidInfoException; + + public Value getThis() + throws InvalidInfoException; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSThreadState.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSThreadState.java new file mode 100644 index 00000000000..3d0256e7f18 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/JSThreadState.java @@ -0,0 +1,23 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public interface JSThreadState extends ThreadStateBase +{ +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/PC.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/PC.java new file mode 100644 index 00000000000..6cdd6351115 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/PC.java @@ -0,0 +1,37 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +/** + * The PC interface is an opaque representation of a program counter. It + * may have different implementations for interpreted Java methods, + * methods compiled by the JIT, JavaScript methods, etc. + */ +public interface PC { + /** + * Get the SourceLocation associated with this PC value. + * returns null if the source location is unavailable. + */ + public SourceLocation getSourceLocation(); + + /** + * Ask whether two program counter values are equal. + */ + public boolean equals(Object obj); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Property.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Property.java new file mode 100644 index 00000000000..eb348a27ef4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Property.java @@ -0,0 +1,53 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public interface Property +{ + // these must stay the same as the flags in netscape.jsdebug.Property.java + + public static int ENUMERATE = 0x01; /* visible to for/in loop */ + public static int READONLY = 0x02; /* assignment is error */ + public static int PERMANENT = 0x04; /* property cannot be deleted */ + public static int ALIAS = 0x08; /* property has an alias id */ + public static int ARGUMENT = 0x10; /* argument to function */ + public static int VARIABLE = 0x20; /* local variable in function */ + public static int HINTED = 0x800; /* found via explicit lookup */ + + public boolean isNameString(); + public boolean isAliasString(); + + public String getNameString(); + public int getNameInt(); + + public String getAliasString(); + public int getAliasInt(); + + public Value getValue(); + public int getVarArgSlot(); + + public int getFlags(); + public boolean canEnumerate(); + public boolean isReadOnly(); + public boolean isPermanent(); + public boolean hasAlias(); + public boolean isArgument(); + public boolean isVariable(); + public boolean isHinted(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/README b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/README new file mode 100644 index 00000000000..57d840ec832 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/README @@ -0,0 +1,9 @@ +/* jband - 09/14/98 - */ + +com.netscape.jsdebugging.api is the package which defines the interface used by +debugger(s) to access the debugging support in the JavaScript engine. It exists +to allow the very same debugger to be used with either the C based engine, the +Java based engine (Rhino), of with a remote engine accessed via Corba/iiop +(additional 'adapter' implementations might be added in the future). This +package presents the generic JS debug interface against which the debugger +compiles and runs. diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Script.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Script.java new file mode 100644 index 00000000000..c4e240df1d1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Script.java @@ -0,0 +1,35 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public interface Script +{ + public String getURL(); + public String getFunction(); + public int getBaseLineNumber(); + public int getLineExtent(); + public boolean isValid(); + public JSPC getClosestPC(int line); + public ScriptSection[] getSections(); + + // XXX + public String toString(); + public int hashCode(); + public boolean equals(Object obj); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ScriptHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ScriptHook.java new file mode 100644 index 00000000000..1dd4b7c63d4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ScriptHook.java @@ -0,0 +1,49 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +/** + * ScriptHook must be subclassed to respond to significant events + * in the virtual machine. + */ +public class ScriptHook extends Hook +{ + /** + * Create a ScriptHook for current the current VM. + */ + public ScriptHook() {} + + /** + * Override this method to respond when a new script is + * loaded into the VM. + */ + /* jband - 03/31/97 - I made this public to allow chaining */ + public void justLoadedScript(Script script) { + // defaults to no action + } + + /** + * Override this method to respond when a class is + * about to be unloaded from the VM. + */ + /* jband - 03/31/97 - I made this public to allow chaining */ + public void aboutToUnloadScript(Script script) { + // defaults to no action + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ScriptSection.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ScriptSection.java new file mode 100644 index 00000000000..b8f59a97eb9 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ScriptSection.java @@ -0,0 +1,26 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public interface ScriptSection +{ + public int getBaseLineNumber(); + public int getLineExtent(); +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceLocation.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceLocation.java new file mode 100644 index 00000000000..58dc81768a0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceLocation.java @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +/** + * An implementation of the SourceLocation interface is used to represent + * a location in a source file. Java interfacefiles only make source locations + * available at the line-by-line granularity, but other languages may + * include finer-grain information. At this time only line number + * information is included. + * XXX must source locations be contiguous? + */ +public interface SourceLocation { + /** + * Gets the first line number associated with this SourceLocation. + * This is the lowest common denominator information that will be + * available: some implementations may choose to include more + * specific location information in a subinterface of SourceLocation. + */ + public int getLine(); + + /** + * Get the first PC associated with a given SourceLocation. + * This is the place to set a breakpoint at that location. + * returns null if there is no code corresponding to that source + * location. + */ + public PC getPC(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceTextItem.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceTextItem.java new file mode 100644 index 00000000000..09433d36321 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceTextItem.java @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public interface SourceTextItem +{ + /* these coorespond to jsdebug.h values - change in both places if anywhere */ + public static final int INITED = 0; + public static final int FULL = 1; + public static final int PARTIAL = 2; + public static final int ABORTED = 3; + public static final int FAILED = 4; + public static final int CLEARED = 5; + + public String getURL(); + public String getText(); + public int getStatus(); + public int getAlterCount(); + + // these are not supported in Livewire version (simulated locally) + public boolean getDirty(); + public void setDirty(boolean b); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceTextProvider.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceTextProvider.java new file mode 100644 index 00000000000..e8ce9ec97a3 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/SourceTextProvider.java @@ -0,0 +1,27 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public interface SourceTextProvider +{ + public SourceTextItem[] getItems(); + public void refreshAll(); + public SourceTextItem findItem(String url); + public SourceTextItem loadItem(String url); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/StackFrameInfo.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/StackFrameInfo.java new file mode 100644 index 00000000000..55584649a15 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/StackFrameInfo.java @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + + +/** + * This interface provides access to the execution stack of a thread. + * It has several subinterfacees to distinguish between different kinds of + * stack frames: these currently include activations of Java methods + * or JavaScript functions. + * It is possible that synchronize blocks and try blocks deserve their own + * stack frames - to allow for later extensions a debugger should skip over + * stack frames it doesn't understand. + * Note that this appears very Java-specific. However, multiple threads and + * exceptions are relevant to JavaScript as well because of its + * interoperation with Java. + */ +public interface StackFrameInfo +{ + public boolean isValid(); +// public StackFrameInfo getCaller() throws InvalidInfoException; +// public Thread getThread(); + public ThreadStateBase getThreadState(); + public PC getPC() throws InvalidInfoException; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ThreadStateBase.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ThreadStateBase.java new file mode 100644 index 00000000000..18b77700719 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/ThreadStateBase.java @@ -0,0 +1,134 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +/** + * When a hook is hit, the debugger records the state of the + * thread before the hook in a ThreadState object. This object + * is then passed to any hook methods that are called, and can + * be used to change the state of the thread when it resumes from the + * hook. + */ +public interface ThreadStateBase +{ + /** + * Return true if the Thread hasn't been resumed since this ThreadState + * was made. + */ + public boolean isValid(); + + /** + * partial list of thread states from sun.debug.ThreadInfo. + * XXX some of these don't apply. + */ + public int THR_STATUS_UNKNOWN = 0x01; + public int THR_STATUS_ZOMBIE = 0x02; + public int THR_STATUS_RUNNING = 0x03; + public int THR_STATUS_SLEEPING = 0x04; + public int THR_STATUS_MONWAIT = 0x05; + public int THR_STATUS_CONDWAIT = 0x06; + public int THR_STATUS_SUSPENDED = 0x07; + public int THR_STATUS_BREAK = 0x08; + + /** + * Get the state of the thread at the time it entered debug mode. + * This can't be modified directly. + */ + public int getStatus(); + + public int countStackFrames() + throws InvalidInfoException; + + public StackFrameInfo getCurrentFrame() + throws InvalidInfoException; + + /** + * Get the thread's stack as an array. stack[stack.length-1] is the + * current frame, and stack[0] is the beginning of the stack. + */ + public StackFrameInfo[] getStack() + throws InvalidInfoException; + + /** + * Return true if the thread is currently running a hook + * for this ThreadState + */ + public boolean isRunningHook(); + + /** + * Return true if the hook on this thread has already completed + * and we are waiting for a call to resume() + */ + public boolean isWaitingForResume(); + + + /** + * Leave the thread in a suspended state when the hook method(s) + * finish. This can be undone by calling resume(). + */ + public void leaveSuspended(); + + /** + * Resume the thread. + * Two cases: + * 1) Hook is still running, this will undo the leaveSuspended + * and the thread will still be waiting for the hook to + * return. + * 2) Hook has already returned and we are in an event loop + * waiting to contine the suspended thread, this will + * force completion of events pending on the suspended + * thread and resume it. + */ + public void resume(); + + /** + * if the continueState is DEAD, the thread cannot + * be restarted. + */ + public int DEBUG_STATE_DEAD = 0x01; + + /** + * if the continueState is RUN, the thread will + * proceed to the next program counter value when it resumes. + */ + public int DEBUG_STATE_RUN = 0x02; + + /** + * if the continueState is RETURN, the thread will + * return from the current method with the value in getReturnValue() + * when it resumes. + */ + public int DEBUG_STATE_RETURN = 0x03; + + /** + * if the continueState is THROW, the thread will + * throw an exception (accessible with getException()) when it + * resumes. + */ + public int DEBUG_STATE_THROW = 0x04; + + /** + * This gets the current continue state of the debug frame, which + * will be one of the DEBUG_STATE_* values above. + */ + public int getContinueState(); + + public int setContinueState(int state); +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Value.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Value.java new file mode 100644 index 00000000000..f88eb67a832 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/Value.java @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api; + +public interface Value +{ + public boolean isObject(); + public boolean isNumber(); + public boolean isInt(); + public boolean isDouble(); + public boolean isString(); + public boolean isBoolean(); + public boolean isNull(); + public boolean isVoid(); + public boolean isPrimitive(); + public boolean isFunction(); + public boolean isNative(); + + public boolean getBoolean(); + public int getInt(); + public double getDouble(); + /** + * does a JavaScript toString conversion if value is not already a string + */ + public String getString(); + + public String getFunctionName(); + public String getClassName(); + + public Value getPrototype(); + public Value getParent(); + public Value getConstructor(); + + public Property[] getProperties(); + public Property getProperty(String name); + public String[] getPropertyHints(); + public void setPropertyHints(String[] hints); + + public void refresh(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/AdapterLoaderCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/AdapterLoaderCorba.java new file mode 100644 index 00000000000..ff826528c58 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/AdapterLoaderCorba.java @@ -0,0 +1,54 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import netscape.security.ForbiddenTargetException; +import com.netscape.jsdebugging.api.DebugController; +import com.netscape.jsdebugging.api.SourceTextProvider; + +public class AdapterLoaderCorba + implements com.netscape.jsdebugging.api.AdapterLoader +{ + public void setHost(String host) {_host = host;} + public boolean isDebuggingSupported() throws ForbiddenTargetException + { + return null != getDebugController(); + } + public com.netscape.jsdebugging.api.DebugController getDebugController() throws ForbiddenTargetException + { + if(null == _controller) + _controller = DebugControllerCorba.getDebugController(_host); + return _controller; + } + public com.netscape.jsdebugging.api.SourceTextProvider getSourceTextProvider() + { + try { + DebugControllerCorba controller = + (DebugControllerCorba) getDebugController(); + return SourceTextProviderCorba.getSourceTextProvider(controller); + } + catch(ForbiddenTargetException e) { + // eat it + } + return null; + } + + private DebugControllerCorba _controller; + private String _host; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/DebugBreakHookCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/DebugBreakHookCorba.java new file mode 100644 index 00000000000..4390f1acfe4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/DebugBreakHookCorba.java @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +/** + * DebugBreakHook must be subclassed to respond to hooks + * at a particular program instruction. + */ +public class DebugBreakHookCorba + extends com.netscape.jsdebugging.remote.corba._sk_IJSExecutionHook +{ + private static int _objectCounter = 0; + + public DebugBreakHookCorba(DebugControllerCorba controller, + DebugBreakHook hook) + { + super( "DebugBreakHookCorba_"+_objectCounter++); + _controller = controller; + _hook = hook; + } + + public void aboutToExecute(com.netscape.jsdebugging.remote.corba.IJSThreadState debug, + com.netscape.jsdebugging.remote.corba.IJSPC pc) + { + try + { + JSThreadStateCorba ts = new JSThreadStateCorba(_controller, debug); + JSPCCorba jspc = (JSPCCorba) ts.getCurrentFrame().getPC(); + _hook.aboutToExecute( ts, jspc ); + } + catch( Exception e ) + { + e.printStackTrace(); + // eat it. + } + } + + public DebugBreakHook getWrappedHook() {return _hook;} + + private DebugControllerCorba _controller; + private DebugBreakHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/DebugControllerCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/DebugControllerCorba.java new file mode 100644 index 00000000000..8049d7629c3 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/DebugControllerCorba.java @@ -0,0 +1,559 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; +import com.netscape.jsdebugging.ifcui.Log; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; + +/** + * This is the master control panel for observing events in the VM. + * Each method setXHook() must be passed an object that extends + * the interface XHook. When an event of the specified type + * occurs, a well-known method on XHook will be called (see the + * various XHook interfacees for details). The method call takes place + * on the same thread that triggered the event in the first place, + * so that any monitors held by the thread which triggered the hook + * will still be owned in the hook method. + */ +public class DebugControllerCorba implements DebugController +{ + public long getSupportsFlags() + { + return 0; + } + + public static synchronized DebugControllerCorba getDebugController(String host) + throws ForbiddenTargetException + { + if( null == _controllerCorba ) + _controllerCorba = new DebugControllerCorba(host); + if( null == _controllerCorba || null == _controllerCorba._remoteController ) + { + _controllerCorba = null; + throw new ForbiddenTargetException(); + } + return _controllerCorba; + } + + private DebugControllerCorba(String host) + { + _host = host; + try + { + _orb = org.omg.CORBA.ORB.init(); + _boa = _orb.BOA_init(); + + PrivilegeManager.enablePrivilege("UniversalConnect"); + +// String name = _host+"/NameService/"+wai_name; +// org.omg.CORBA.Object o = netscape.WAI.Naming.resolve(name); + org.omg.CORBA.Object o = MyNaming.resolve(_host, wai_name); + // if(ASS)System.err.println("o = " + o ); + if( null == o ) + { + // eat it; + System.err.println("DebugControllerCorba.ctor (null returned by resolve)"); + return; + } + + _remoteController = com.netscape.jsdebugging.remote.corba.IDebugControllerHelper.narrow(o); + // if(ASS)System.err.println("_remoteController = " + _remoteController ); + if( null == _remoteController ) + { + // eat it; + System.err.println("DebugControllerCorba.ctor (null returned by narrow)"); + return; + } + + } + catch( Exception e ) + { + // eat it + _printException(e, "ctor"); + _remoteController = null; + return; + } + + // Do a real call to the remote controller. If communication + // is not going to work, then we want to know it now. + try + { + _remoteController.getMajorVersion(); + } + catch( Exception e ) + { + // eat it + System.err.println("/************************************************************"); + System.err.println("* JSD connected to server, but failed when making remote call"); + System.err.println("* Server has probably been stopped or restarted"); + System.err.println("* You should verify server is running and restart Navigator"); + System.err.println("************************************************************/"); + _printException(e, "ctor"); + _remoteController = null; + return; + } + } + + public String getHostName() {return _host;} + public com.netscape.jsdebugging.remote.corba.IDebugController getRemoteController() + {return _remoteController;} + public org.omg.CORBA.ORB getORB() {return _orb;} + public org.omg.CORBA.BOA getBOA() {return _boa;} + + /** + * Request notification of Script loading events. Whenever a Script + * is loaded into or unloaded from the VM the appropriate method of + * the ScriptHook argument will be called. + * returns the previous hook object. + */ + public ScriptHook setScriptHook(ScriptHook h) + { + try + { + ScriptHookCorba newWrapper = null; + if( null != h ) + { + PrivilegeManager.enablePrivilege("UniversalConnect"); + newWrapper = new ScriptHookCorba(this, h); + _boa.obj_is_ready(newWrapper); + } + com.netscape.jsdebugging.remote.corba.IScriptHook oldHook = + _remoteController.setScriptHook(newWrapper); + if( null != oldHook && oldHook instanceof ScriptHookCorba ) + return ((ScriptHookCorba)oldHook).getWrappedHook(); + } + catch( Exception e ) + { + // eat it + _printException(e, "setScriptHook"); + } + return null; + } + + /** + * Find the current observer of Script events, or return null if there + * is none. + */ + public ScriptHook getScriptHook() + { + try + { + com.netscape.jsdebugging.remote.corba.IScriptHook oldHook = + _remoteController.getScriptHook(); + if( null != oldHook && oldHook instanceof ScriptHookCorba ) + return ((ScriptHookCorba)oldHook).getWrappedHook(); + } + catch( Exception e ) + { + // eat it + _printException(e, "getScriptHook"); + } + return null; + } + + /** + * Set a hook at the given program counter value. When + * a thread reaches that instruction, a ThreadState object will be + * created and the appropriate method of the hook object + * will be called. + * returns the previous hook object. + */ + + public InstructionHook setInstructionHook( + PC pc, + InstructionHook h) + { + try + { + com.netscape.jsdebugging.remote.corba.IJSPC newWrappedPC = null; + if( null != pc ) + newWrappedPC = ((JSPCCorba)pc).getWrappedJSPC(); + + InstructionHookCorba newWrapper = null; + if( null != h ) + { + PrivilegeManager.enablePrivilege("UniversalConnect"); + newWrapper = new InstructionHookCorba(this, h); + _boa.obj_is_ready(newWrapper); + } + com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook = + _remoteController.setInstructionHook(newWrapper, newWrappedPC); + if( null != oldHook && oldHook instanceof InstructionHookCorba ) + return ((InstructionHookCorba)oldHook).getWrappedHook(); + } + catch( Exception e ) + { + // eat it + _printException(e, "setInstructionHook"); + } + return null; + } + + /** + * Get the hook at the given program counter value, or return + * null if there is none. + */ + public InstructionHook getInstructionHook(PC pc) + { + if( null == pc ) + return null; + try + { + com.netscape.jsdebugging.remote.corba.IJSPC newWrappedPC = ((JSPCCorba)pc).getWrappedJSPC(); + + com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook = + _remoteController.getInstructionHook(newWrappedPC); + if( null != oldHook && oldHook instanceof InstructionHookCorba ) + return ((InstructionHookCorba)oldHook).getWrappedHook(); + } + catch( Exception e ) + { + // eat it + _printException(e, "getInstructionHook"); + } + return null; + } + + public InterruptHook setInterruptHook( InterruptHook h ) + { + try + { + InterruptHookCorba newWrapper = null; + if( null != h ) + { + PrivilegeManager.enablePrivilege("UniversalConnect"); + newWrapper = new InterruptHookCorba(this, h); + _boa.obj_is_ready(newWrapper); + } + com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook = + _remoteController.setInterruptHook(newWrapper); + if( null != oldHook && oldHook instanceof InterruptHookCorba ) + return ((InterruptHookCorba)oldHook).getWrappedHook(); + } + catch( Exception e ) + { + // eat it + _printException(e, "setInterruptHook"); + } + return null; + } + + public InterruptHook getInterruptHook() + { + try + { + com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook = + _remoteController.getInterruptHook(); + if( null != oldHook && oldHook instanceof InterruptHookCorba ) + return ((InterruptHookCorba)oldHook).getWrappedHook(); + } + catch( Exception e ) + { + // eat it + _printException(e, "getInterruptHook"); + } + return null; + } + + public void sendInterrupt() + { + try + { + if(ASS)Log.trace("_remoteController.sendInterrupt()", "+++"); + _remoteController.sendInterrupt(); + if(ASS)Log.trace("_remoteController.sendInterrupt()", "---"); + } + catch( Exception e ) + { + // eat it + _printException(e, "sendInterrupt"); + } + } + + public void sendInterruptStepInto(ThreadStateBase debug) + { + try + { + _remoteController.sendInterruptStepInto( + ((JSThreadStateCorba)debug).getWrappedThreadState().id); + } + catch( Exception e ) + { + // eat it + _printException(e, "sendInterruptStepInto"); + } + } + + public void sendInterruptStepOver(ThreadStateBase debug) + { + try + { + _remoteController.sendInterruptStepOver( + ((JSThreadStateCorba)debug).getWrappedThreadState().id); + } + catch( Exception e ) + { + // eat it + _printException(e, "sendInterruptStepOver"); + } + } + + public void sendInterruptStepOut(ThreadStateBase debug) + { + try + { + _remoteController.sendInterruptStepOut( + ((JSThreadStateCorba)debug).getWrappedThreadState().id); + } + catch( Exception e ) + { + // eat it + _printException(e, "sendInterruptStepOut"); + } + } + + public void reinstateStepper(ThreadStateBase debug) + { + try + { + _remoteController.reinstateStepper( + ((JSThreadStateCorba)debug).getWrappedThreadState().id); + } + catch( Exception e ) + { + // eat it + _printException(e, "reinstateStepper"); + } + } + + public DebugBreakHook setDebugBreakHook( DebugBreakHook h ) + { + try + { + DebugBreakHookCorba newWrapper = null; + if( null != h ) + { + PrivilegeManager.enablePrivilege("UniversalConnect"); + newWrapper = new DebugBreakHookCorba(this, h); + _boa.obj_is_ready(newWrapper); + } + com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook = + _remoteController.setDebugBreakHook(newWrapper); + if( null != oldHook && oldHook instanceof DebugBreakHookCorba ) + return ((DebugBreakHookCorba)oldHook).getWrappedHook(); + } + catch( Exception e ) + { + // eat it + _printException(e, "setDebugBreakHook"); + } + return null; + } + + public DebugBreakHook getDebugBreakHook() + { + try + { + com.netscape.jsdebugging.remote.corba.IJSExecutionHook oldHook = + _remoteController.getDebugBreakHook(); + if( null != oldHook && oldHook instanceof DebugBreakHookCorba ) + return ((DebugBreakHookCorba)oldHook).getWrappedHook(); + } + catch( Exception e ) + { + // eat it + _printException(e, "getDebugBreakHook"); + } + return null; + } + + public ExecResult executeScriptInStackFrame( JSStackFrameInfo frame, + String text, + String filename, + int lineno ) + { + JSStackFrameInfoCorba framec = (JSStackFrameInfoCorba) frame; + JSThreadStateCorba ts = (JSThreadStateCorba) framec.getThreadState(); + int id = ts.getWrappedThreadState().id; + + try + { + return new ExecResultCorba(_remoteController.executeScriptInStackFrame( + id, framec.getWrappedInfo(), + text, filename, lineno)); + } + catch(Exception e) + { + e.printStackTrace(); + System.out.println("exeception while calling remote controler to do exec"); + return null; + } + } + + public ExecResult executeScriptInStackFrameValue( JSStackFrameInfo frame, + String text, + String filename, + int lineno ) + throws ForbiddenTargetException + { + return null; // XXX implement this... + } + + public JSErrorReporter setErrorReporter(JSErrorReporter h) + { + try + { + JSErrorReporterCorba newWrapper = null; + if( null != h ) + { + PrivilegeManager.enablePrivilege("UniversalConnect"); + newWrapper = new JSErrorReporterCorba(h); + _boa.obj_is_ready(newWrapper); + } + com.netscape.jsdebugging.remote.corba.IJSErrorReporter oldHook = + _remoteController.setErrorReporter(newWrapper); + if( null != oldHook && oldHook instanceof JSErrorReporterCorba ) + return ((JSErrorReporterCorba)oldHook).getWrappedHook(); + } + catch( Exception e ) + { + // eat it + _printException(e, "setErrorReporter"); + } + return null; + } + + public JSErrorReporter getErrorReporter() + { + try + { + com.netscape.jsdebugging.remote.corba.IJSErrorReporter oldHook = + _remoteController.getErrorReporter(); + if( null != oldHook && oldHook instanceof JSErrorReporterCorba ) + return ((JSErrorReporterCorba)oldHook).getWrappedHook(); + } + catch( Exception e ) + { + // eat it + _printException(e, "getErrorReporter"); + } + return null; + } + + public void iterateScripts(ScriptHook h) + { + try + { + PrivilegeManager.enablePrivilege("UniversalConnect"); + ScriptHookCorba newWrapper = new ScriptHookCorba(this, h); + _boa.obj_is_ready(newWrapper); + _remoteController.iterateScripts(newWrapper); + } + catch( Exception e ) + { + // eat it + _printException(e, "iterateScripts"); + } + } + + public int getMajorVersion() + { + try + { + return _remoteController.getMajorVersion(); + } + catch( Exception e ) + { + // eat it + _printException(e, "getMajorVersion"); + } + return 0; + } + public int getMinorVersion() + { + try + { + return _remoteController.getMinorVersion(); + } + catch( Exception e ) + { + // eat it + _printException(e, "getMinorVersion"); + } + return 0; + } + + private void _printException(Exception e, String funname) + { + e.printStackTrace(); + System.out.println("error in DebugControllerCorba." + funname ); + } + +// private int _callsToRemote = 0; +// private int _callbacksFromRemote = 0; +// +// private boolean _callsToRemoteAllowed = true; +// +// public synchronized void beginCallbackFromRemote() +// { +// _callbacksFromRemote++ ; +// } +// public synchronized void endCallbackFromRemote() +// { +// _callbacksFromRemote-- ; +// } +// +// public synchronized void beginCallToRemote() +// { +// if(ASS)ER.T(_callsToRemoteAllowed,"beginCallToRemote() when ! _callsToRemoteAllowed",this); +// _callsToRemote++ ; +// if(ASS)ER.T(_callsToRemote >= 0,"_callsToRemote >= 0 failed in beginCallToRemote()",this); +// } +// +// public synchronized void endCallToRemote() +// { +// if(ASS)ER.T(_callsToRemoteAllowed,"endCallToRemote() when ! _callsToRemoteAllowed",this); +// _callsToRemote-- ; +// if(ASS)ER.T(_callsToRemote >= 0,"_callsToRemote >= 0 failed in endCallToRemote()",this); +// } +// +// public synchronized void setCallsToRemoteAllowed(boolean b) +// { +// if(ASS)ER.T(_callsToRemoteAllowed != b,"setNoCallToRemoteAllowed() called with bad arg",this); +// _callsToRemoteAllowed = b; +// } + + + // data... + + private com.netscape.jsdebugging.remote.corba.IDebugController _remoteController = null; + private org.omg.CORBA.ORB _orb; + private org.omg.CORBA.BOA _boa; + private String _host; + + private static DebugControllerCorba _controllerCorba = null; + + private static final String wai_name = "JSDebugController"; + private static final boolean ASS = true; // enable ASSERT support? +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ExecResultCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ExecResultCorba.java new file mode 100644 index 00000000000..7ad48ff1c7b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ExecResultCorba.java @@ -0,0 +1,43 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +public class ExecResultCorba + implements com.netscape.jsdebugging.api.ExecResult +{ + ExecResultCorba( com.netscape.jsdebugging.remote.corba.IExecResult result ) + { + _result = result; + } + + public String getResult() {return _result.result;} + public boolean getErrorOccured() {return _result.errorOccured;} + public String getErrorMessage() {return _result.errorMessage;} + public String getErrorFilename() {return _result.errorFilename;} + public int getErrorLineNumber() {return _result.errorLineNumber;} + public String getErrorLineBuffer() {return _result.errorLineBuffer;} + public int getErrorTokenOffset() {return _result.errorTokenOffset;} + + public com.netscape.jsdebugging.api.Value getResultValue() + {return null;} // XXX implement this + + private com.netscape.jsdebugging.remote.corba.IExecResult _result; +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/InstructionHookCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/InstructionHookCorba.java new file mode 100644 index 00000000000..0c7ec39863e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/InstructionHookCorba.java @@ -0,0 +1,50 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +/** + * InstructionHook must be subinterfaceed to respond to hooks + * at a particular program instruction. + */ +public class InstructionHookCorba + extends com.netscape.jsdebugging.remote.corba._sk_IJSExecutionHook +{ + private static int _objectCounter = 0; + + InstructionHookCorba(DebugControllerCorba controller, + InstructionHook hook) + { + super( "InstructionHookCorba_"+_objectCounter++); + _controller = controller; + _hook = hook; + } + + public void aboutToExecute(com.netscape.jsdebugging.remote.corba.IJSThreadState debug, + com.netscape.jsdebugging.remote.corba.IJSPC pc) + { + _hook.aboutToExecute( new JSThreadStateCorba(_controller, debug) ); + } + + public InstructionHook getWrappedHook() {return _hook;} + + private DebugControllerCorba _controller; + private InstructionHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/InterruptHookCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/InterruptHookCorba.java new file mode 100644 index 00000000000..e96312f1254 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/InterruptHookCorba.java @@ -0,0 +1,66 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; +import com.netscape.jsdebugging.ifcui.Log; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; + +/** + * InterruptHook must be subinterfaceed to respond to hooks + * at a particular program instruction. + */ +public class InterruptHookCorba + extends com.netscape.jsdebugging.remote.corba._sk_IJSExecutionHook +{ + private static int _objectCounter = 0; + public InterruptHookCorba(DebugControllerCorba controller, + InterruptHook hook) + { + super( "InterruptHookCorba_"+_objectCounter++); + _controller = controller; + _hook = hook; + } + + public void aboutToExecute(com.netscape.jsdebugging.remote.corba.IJSThreadState debug, + com.netscape.jsdebugging.remote.corba.IJSPC pc) + { + if(ASS)Log.trace("com.netscape.jsdebugging.api.corba.InterruptHookCorba.aboutToExecute", "in -> , JSThreadID: "+debug.id); +// System.out.println( "InterruptHookCorba called..." ); + try + { + JSThreadStateCorba ts = new JSThreadStateCorba(_controller,debug); + JSPCCorba jspc = (JSPCCorba) ts.getCurrentFrame().getPC(); + _hook.aboutToExecute( ts, jspc ); + } + catch( Exception e ) + { + e.printStackTrace(); + // eat it. + } + if(ASS)Log.trace("com.netscape.jsdebugging.api.corba.InterruptHookCorba.aboutToExecute", "out <- , JSThreadID: "+debug.id); + } + + public InterruptHook getWrappedHook() {return _hook;} + + private DebugControllerCorba _controller; + private InterruptHook _hook; + + private static final boolean ASS = true; // enable ASSERT support? +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSErrorReporterCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSErrorReporterCorba.java new file mode 100644 index 00000000000..12d0b0f1e33 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSErrorReporterCorba.java @@ -0,0 +1,46 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +public class JSErrorReporterCorba + extends com.netscape.jsdebugging.remote.corba._sk_IJSErrorReporter +{ + private static int _objectCounter = 0; + + public JSErrorReporterCorba(JSErrorReporter er) + { + super( "JSErrorReporterCorba_"+_objectCounter++); + _er = er; + } + + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + return _er.reportError(msg, filename, lineno, linebuf, tokenOffset); + } + + public JSErrorReporter getWrappedHook() {return _er;} + + private JSErrorReporter _er; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSPCCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSPCCorba.java new file mode 100644 index 00000000000..053aa250918 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSPCCorba.java @@ -0,0 +1,91 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +/** + * This subinterface of PC provides JavaScript-specific information. + */ +public class JSPCCorba implements JSPC +{ + public JSPCCorba(DebugControllerCorba controller, + com.netscape.jsdebugging.remote.corba.IJSPC pc) + { + this( controller, pc, new ScriptCorba(controller, pc.script) ); + } + + public JSPCCorba(DebugControllerCorba controller, + com.netscape.jsdebugging.remote.corba.IJSPC pc, + ScriptCorba script) + { + _controller = controller; + _pc = pc; + _script = script; + _sourceLocation = null; + + + } + + public Script getScript() {return _script;} + public int getPC() {return _pc.offset;} + // XXX currently no way to track invalidity!!! + public boolean isValid() {return true;} + public SourceLocation getSourceLocation() + { + if( null == _sourceLocation ) + { + try + { + _sourceLocation = new JSSourceLocationCorba(this, + _controller.getRemoteController().getSourceLocation(_pc)); + } + catch (Exception e) + { + // eat it; + e.printStackTrace(); + System.err.println("error in JSPCCorba.getSourceLocation()"); + } + } + return _sourceLocation; + } + + public boolean equals(Object obj) + { + try + { + JSPCCorba other = (JSPCCorba) obj; + return other._script.equals(_script) && + other._pc.offset == _pc.offset; + } + catch( ClassCastException e ) + { + return false; + } + } + public int hashCode() {return _script.hashCode()+_pc.offset*7;} + public String toString() {return _pc.toString();} + + public com.netscape.jsdebugging.remote.corba.IJSPC getWrappedJSPC() {return _pc;} + + private DebugControllerCorba _controller; + private com.netscape.jsdebugging.remote.corba.IJSPC _pc; + private ScriptCorba _script; + private JSSourceLocationCorba _sourceLocation; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSSourceLocationCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSSourceLocationCorba.java new file mode 100644 index 00000000000..bf2858541a1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSSourceLocationCorba.java @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +public class JSSourceLocationCorba implements JSSourceLocation +{ + public JSSourceLocationCorba( JSPCCorba pc, + com.netscape.jsdebugging.remote.corba.IJSSourceLocation sl ) + { + _pc = pc; + _sl = sl; + } + public int getLine() {return _sl.line;} + public String getURL() {return _pc.getScript().getURL();} + public PC getPC() {return _pc;} + public String toString() + { + return ""; + } + + public boolean equals(Object obj) + { + try + { + JSSourceLocationCorba other = (JSSourceLocationCorba) obj; + return getLine() == other.getLine() && + getURL().equals(other.getURL()); + } + catch( ClassCastException e ) + { + return false; + } + } + public int hashCode() {return getURL().hashCode() + 17*getLine();} + + private JSPCCorba _pc; + private com.netscape.jsdebugging.remote.corba.IJSSourceLocation _sl; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSStackFrameInfoCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSStackFrameInfoCorba.java new file mode 100644 index 00000000000..fd1eec53658 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSStackFrameInfoCorba.java @@ -0,0 +1,77 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +/** + * This interface provides access to the execution stack of a thread. + * It has several subinterfacees to distinguish between different kinds of + * stack frames: these currently include activations of Java methods + * or JavaScript functions. + * It is possible that synchronize blocks and try blocks deserve their own + * stack frames - to allow for later extensions a debugger should skip over + * stack frames it doesn't understand. + * Note that this appears very Java-specific. However, multiple threads and + * exceptions are relevant to JavaScript as well because of its + * interoperation with Java. + */ +public class JSStackFrameInfoCorba implements JSStackFrameInfo +{ + public JSStackFrameInfoCorba( DebugControllerCorba controller, + com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo info, + JSThreadStateCorba ts ) + { + _info = info; + _ts = ts; + _pc = new JSPCCorba(controller, info.pc); + } + + // XXX currently no way to track invalidity!!! + public boolean isValid() {return true;} + public ThreadStateBase getThreadState() {return _ts;} + public PC getPC() throws InvalidInfoException + { + if( null == _pc ) + throw new InvalidInfoException(); + return _pc; + } + + public Value getCallObject() throws InvalidInfoException + { + throw new InvalidInfoException("not implemented"); + } + + public Value getScopeChain() throws InvalidInfoException + { + throw new InvalidInfoException("not implemented"); + } + + public Value getThis() throws InvalidInfoException + { + throw new InvalidInfoException("not implemented"); + } + + public com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo getWrappedInfo() {return _info;} + + private com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo _info; + private JSThreadStateCorba _ts; + private JSPCCorba _pc; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSThreadStateCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSThreadStateCorba.java new file mode 100644 index 00000000000..018fba3d0ee --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/JSThreadStateCorba.java @@ -0,0 +1,179 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +public class JSThreadStateCorba implements JSThreadState +{ + public JSThreadStateCorba(DebugControllerCorba controller, + com.netscape.jsdebugging.remote.corba.IJSThreadState ts) + { + _controller = controller; + _ts = ts; + if( null != _ts.stack && 0 != _ts.stack.length ) + { + _stack = new JSStackFrameInfoCorba[_ts.stack.length]; + for( int i = 0; i < _ts.stack.length; i++ ) + _stack[i] = new JSStackFrameInfoCorba(_controller, _ts.stack[i], this); + } + } + + // XXX currently no way to track invalidity!!! + public boolean isValid() {return true;} + public int getStatus() {return _ts.status;} + + public int countStackFrames() + throws InvalidInfoException + { + if( null == _stack ) + throw new InvalidInfoException(); + return _stack.length; + } + + public StackFrameInfo getCurrentFrame() + throws InvalidInfoException + { + if( null == _stack ) + throw new InvalidInfoException(); + return _stack[_stack.length-1]; + } + + /** + * Get the thread's stack as an array. stack[stack.length-1] is the + * current frame, and stack[0] is the beginning of the stack. + */ + public StackFrameInfo[] getStack() + throws InvalidInfoException + { + if( null == _stack ) + throw new InvalidInfoException(); + return _stack; + } + + /** + * Return true if the thread is currently running a hook + * for this ThreadState + */ + public boolean isRunningHook() + { + try + { + return _controller.getRemoteController().isRunningHook(_ts.id); + } + catch (Exception e) + { + // eat it; + e.printStackTrace(); + System.err.println("error in JSThreadStateCorba.isRunningHook"); + return false; + } + } + + /** + * Return true if the hook on this thread has already completed + * and we are waiting for a call to resume() + */ + public boolean isWaitingForResume() + { + try + { + return _controller.getRemoteController().isWaitingForResume(_ts.id); + } + catch (Exception e) + { + // eat it; + e.printStackTrace(); + System.err.println("error in JSThreadStateCorba.isWaitingForResume"); + return false; + } + } + + /** + * Leave the thread in a suspended state when the hook method(s) + * finish. This can be undone by calling resume(). + */ + public synchronized void leaveSuspended() + { + try + { + _controller.getRemoteController().leaveThreadSuspended(_ts.id); + } + catch (Exception e) + { + // eat it; + e.printStackTrace(); + System.err.println("error in JSThreadStateCorba.isWaitingForResume"); + } + } + + /** + * Resume the thread. + * Two cases: + * 1) Hook is still running, this will undo the leaveSuspended + * and the thread will still be waiting for the hook to + * return. + * 2) Hook has already returned and we are in an event loop + * waiting to contine the suspended thread, this will + * force completion of events pending on the suspended + * thread and resume it. + */ + public synchronized void resume() + { + try + { + _controller.getRemoteController().resumeThread(_ts.id); + } + catch (Exception e) + { + // eat it; + e.printStackTrace(); + System.err.println("error in JSThreadStateCorba.resume"); + } + } + + /** + * This gets the current continue state of the debug frame, which + * will be one of the DEBUG_STATE_* values above. + */ + public int getContinueState() {return _ts.continueState;} + + public synchronized int setContinueState(int state) + { + int old = _ts.continueState; + try + { + _controller.getRemoteController().setThreadContinueState(_ts.id, state); + _ts.continueState = state; + } + catch (Exception e) + { + // eat it; + e.printStackTrace(); + System.err.println("error in JSThreadStateCorba.setContinueState"); + } + return old; + } + + public com.netscape.jsdebugging.remote.corba.IJSThreadState getWrappedThreadState() {return _ts;} + + private DebugControllerCorba _controller; + private com.netscape.jsdebugging.remote.corba.IJSThreadState _ts; + private JSStackFrameInfoCorba[] _stack; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/MyNaming.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/MyNaming.java new file mode 100644 index 00000000000..eef3dd21392 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/MyNaming.java @@ -0,0 +1,71 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import java.net.URL; +import java.net.Socket; +import java.io.DataInputStream; +import java.io.DataOutputStream; + +public class MyNaming +{ + /* + * host is in the form: http://server[:port] e.g. http://warp + * name is just the name of the object (without "/NameService/") + */ + public static String resolveToIOR(String host, String name) + { + try + { + URL url = new URL(host); + int port = url.getPort(); + if( port == -1 ) + port = 80; + Socket socket = new Socket(url.getHost(), port); + + DataOutputStream dos = new DataOutputStream(socket.getOutputStream()); + dos.writeBytes("GET "+"/NameService/"+name+" HTTP/1.0\n\n"); + + DataInputStream dis = new DataInputStream(socket.getInputStream()); + String line; + while(null != (line = dis.readLine())) + { + // System.out.println("line: "+ line); + if( line.startsWith("IOR:") ) + return line; + } + } + catch(Exception e) + { + // eat it... + } + return null; + } + + public static org.omg.CORBA.Object resolve(String host, String name) + { + String IOR = resolveToIOR(host, name); + if( null == IOR ) + return null; + org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(); + if( null == orb ) + return null; + return orb.string_to_object(IOR); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptCorba.java new file mode 100644 index 00000000000..23f0032cde7 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptCorba.java @@ -0,0 +1,91 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +public class ScriptCorba implements Script +{ + ScriptCorba(DebugControllerCorba controller, + com.netscape.jsdebugging.remote.corba.IScript script) + { + _controller = controller; + _script = script; + + int count = _script.sections.length; + if( 0 != count ) + { + _sections = new ScriptSectionCorba[count]; + for( int i = 0; i < count; i++ ) + _sections[i] = new ScriptSectionCorba(_script.sections[i].base, + _script.sections[i].extent); + } + else + { + // make one big section + _sections = new ScriptSectionCorba[1]; + _sections[0] = new ScriptSectionCorba(_script.base, _script.extent); + } + } + + public String getURL() {return _script.url;} + public String getFunction() {return _script.funname;} + public int getBaseLineNumber() {return _script.base;} + public int getLineExtent() {return _script.extent;} + + // XXX right now we have no scheme for tracking destruction of scripts + public boolean isValid() {return true;} + public JSPC getClosestPC(int line) + { + try + { + return new + JSPCCorba(_controller, + _controller.getRemoteController().getClosestPC(_script, line)); + } + catch (Exception e) + { + // eat it; + e.printStackTrace(); + System.err.println("error in ScriptCorba.getClosestPC"); + return null; + } + } + public ScriptSection[] getSections() {return _sections;} + + public String toString() {return _script.toString();} + public int hashCode() {return _script.jsdscript;} + public boolean equals(Object obj) + { + try + { + return ((ScriptCorba)obj)._script.jsdscript == _script.jsdscript; + } + catch( ClassCastException e ) + { + return false; + } + } + + public com.netscape.jsdebugging.remote.corba.IScript getRealScript() {return _script;} + + private ScriptSectionCorba[] _sections; + private DebugControllerCorba _controller; + private com.netscape.jsdebugging.remote.corba.IScript _script; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptHookCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptHookCorba.java new file mode 100644 index 00000000000..6d6d008c66b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptHookCorba.java @@ -0,0 +1,54 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +/** + * ScriptHook must be subinterfaceed to respond to significant events + * in the virtual machine. + */ +public class ScriptHookCorba + extends com.netscape.jsdebugging.remote.corba._sk_IScriptHook +{ + private static int _objectCounter = 0; + + public ScriptHookCorba(DebugControllerCorba controller, + ScriptHook hook) + { + super( "ScriptHookCorba_"+_objectCounter++); + _controller = controller; + _hook = hook; + } + + public void justLoadedScript(com.netscape.jsdebugging.remote.corba.IScript script) + { + _hook.justLoadedScript( new ScriptCorba(_controller, script) ); + } + + public void aboutToUnloadScript(com.netscape.jsdebugging.remote.corba.IScript script) + { + _hook.aboutToUnloadScript( new ScriptCorba(_controller, script) ); + } + + public ScriptHook getWrappedHook() {return _hook;} + + private DebugControllerCorba _controller; + private ScriptHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptSectionCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptSectionCorba.java new file mode 100644 index 00000000000..6c3702188ba --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/ScriptSectionCorba.java @@ -0,0 +1,37 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +public class ScriptSectionCorba implements ScriptSection +{ + public ScriptSectionCorba( int base, int extent ) + { + _base = base; + _extent = extent; + } + + public int getBaseLineNumber() {return _base;} + public int getLineExtent() {return _extent;} + + private int _base; + private int _extent; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/SourceTextItemCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/SourceTextItemCorba.java new file mode 100644 index 00000000000..43d1e219ec5 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/SourceTextItemCorba.java @@ -0,0 +1,114 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; + +public class SourceTextItemCorba + implements SourceTextItem +{ + /* + * The 'array' param is an ugly hack. iiop doesn't really refcount the + * items, but rather the whole array. As long as this item lives, a + * ref to the array it camme from must be held. So, we hold it... + */ + public SourceTextItemCorba(com.netscape.jsdebugging.remote.corba.ISourceTextProvider pro, + String url ) + { + _pro = pro; + _url = url; + } + + // implements SourceTextItem + public String getURL() {return _url;} + + public String getText() + { + try + { + return _pro.getPageText(_url); + } + catch( Exception e ) + { + // eat it; + _printException(e, "getText"); + return null; + } + } + public int getStatus() + { + try + { + return _pro.getPageStatus(_url); + } + catch( Exception e ) + { + // eat it; + _printException(e, "getPageStatus"); + return INITED; + } + } + public int getAlterCount() + { + try + { + return _pro.getPageAlterCount(_url); + } + catch( Exception e ) + { + // eat it; + _printException(e, "getAlterCount"); + return 0; + } + } + + public boolean getDirty() {return _lastAlterCount < getAlterCount();} + public void setDirty(boolean b) + { + if(b) + _lastAlterCount-- ; + else + _lastAlterCount = getAlterCount(); + } + + private void _printException(Exception e, String funname) + { + e.printStackTrace(); + System.out.println("error occured in SourceTextItemCorba." + funname ); + } + + public int hashCode() {return _url.hashCode();} + public boolean equals(Object obj) + { + try + { + return ((SourceTextItemCorba)obj)._url.equals(_url); + } + catch( ClassCastException e ) + { + return false; + } + } + + // data + + private com.netscape.jsdebugging.remote.corba.ISourceTextProvider _pro; + private String _url; + private int _lastAlterCount = 0; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/SourceTextProviderCorba.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/SourceTextProviderCorba.java new file mode 100644 index 00000000000..bce7c9c275a --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/corba/SourceTextProviderCorba.java @@ -0,0 +1,171 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.corba; + +import com.netscape.jsdebugging.api.*; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; + +public class SourceTextProviderCorba + implements SourceTextProvider +{ + // allow for possible singleton-ness enforcement + public static synchronized SourceTextProvider + getSourceTextProvider(DebugControllerCorba controller) + { + return new SourceTextProviderCorba(controller); + } + + private SourceTextProviderCorba(DebugControllerCorba controller) + { + _controller = controller; + try + { + PrivilegeManager.enablePrivilege("UniversalConnect"); + +// String name = _controller.getHostName()+"/NameService/"+wai_name; +// org.omg.CORBA.Object o = netscape.WAI.Naming.resolve(name); + org.omg.CORBA.Object o = MyNaming.resolve(_controller.getHostName(),wai_name); + if( null == o ) + { + // eat it; + System.err.println("SourceTextProviderCorba.ctor (null returned by resolve)"); + return; + } + + _pro = com.netscape.jsdebugging.remote.corba.ISourceTextProviderHelper.narrow(o); + if( null == _pro ) + { + // eat it; + System.err.println("SourceTextProviderCorba.ctor (null returned by narrow)"); + return; + } + } + catch (Exception e) + { + // eat it; + _printException(e, "ctor"); + return; + } + } + + // implement com.netscape.jsdebugging.ifcui.SourceTextProvider + + public SourceTextItem[] getItems() + { + if( null == _pro ) + return null; + + if( null == _items ) + _rebuildItemsArray(); + return _items; + } + public void refreshAll() + { + if( null == _pro ) + return; + try + { + _pro.refreshAllPages(); + } + catch( Exception e ) + { + // eat it; + _printException(e, "refreshAll"); + } + _rebuildItemsArray(); + } + public SourceTextItem findItem(String url) + { + if( null == _pro ) + return null; + if( null == _items ) + _rebuildItemsArray(); + + if( null == _items ) + return null; + + for( int i = 0; i < _items.length; i++ ) + { + if( url.equals(_items[i].getURL()) ) + return _items[i]; + } + return null; + } + public SourceTextItem loadItem(String url) + { + // XXX not implemented... + return null; + } + + private synchronized void _rebuildItemsArray() + { + SourceTextItemCorba[] olditems = _items; + _items = null; + + if( null == _pro ) + return; + try + { + String[] urls = _pro.getAllPages(); + if( null == urls || 0 == urls.length ) + return; + SourceTextItemCorba[] newitems = new SourceTextItemCorba[urls.length]; + next_item: for( int i = 0; i < urls.length; i++ ) + { + String url = urls[i]; + if( null != olditems && 0 != olditems.length ) + { + for( int k = 0; k < olditems.length; k++ ) + { + SourceTextItemCorba item = olditems[k]; + if( item.getURL().equals(url) ) + { +// System.out.println( "reusing " + url ); + newitems[i] = item; + continue next_item; + } + } + } +// System.out.println( "+++ new item generated for " + url ); + newitems[i] = new SourceTextItemCorba(_pro,url); + } + _items = newitems; + } + catch( Exception e ) + { + // eat it; + _printException(e, "_rebuildItemsArray"); + } + } + + private void _printException(Exception e, String funname) + { + e.printStackTrace(); + System.out.println("error occured in SourceTextProviderCorba." + funname ); + } + + // data + + private com.netscape.jsdebugging.remote.corba.ISourceTextProvider _pro = null; + private SourceTextItemCorba[] _items = null; + + private DebugControllerCorba _controller; + private static final String wai_name = "JSSourceTextProvider"; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/AdapterLoaderLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/AdapterLoaderLocal.java new file mode 100644 index 00000000000..44b74d10c04 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/AdapterLoaderLocal.java @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import netscape.security.ForbiddenTargetException; +import com.netscape.jsdebugging.api.DebugController; +import com.netscape.jsdebugging.api.SourceTextProvider; + +public class AdapterLoaderLocal + implements com.netscape.jsdebugging.api.AdapterLoader +{ + public void setHost(String host) {} // ignored + public boolean isDebuggingSupported() throws ForbiddenTargetException + { + return null != DebugControllerLocal.getDebugController(); + } + public DebugController getDebugController() throws ForbiddenTargetException + { + return DebugControllerLocal.getDebugController(); + } + public SourceTextProvider getSourceTextProvider() + { + return SourceTextProviderLocal.getSourceTextProvider(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/Callback.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/Callback.java new file mode 100644 index 00000000000..863fba2f95e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/Callback.java @@ -0,0 +1,24 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +public interface Callback +{ + public void call(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/DebugBreakHookLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/DebugBreakHookLocal.java new file mode 100644 index 00000000000..8684e63dd25 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/DebugBreakHookLocal.java @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +/** + * DebugBreakHook must be subclassed to respond to hooks + * at a particular program instruction. + */ +public class DebugBreakHookLocal extends netscape.jsdebug.DebugBreakHook +{ + public DebugBreakHookLocal( DebugBreakHook hook ) + { + _hook = hook; + } + + public void aboutToExecute(netscape.jsdebug.ThreadStateBase debug, + netscape.jsdebug.PC pc) + { + try + { + JSThreadStateLocal ts = new JSThreadStateLocal(debug); + JSPCLocal jspc = (JSPCLocal) ts.getCurrentFrame().getPC(); + ts.aboutToCallHook(); + _hook.aboutToExecute(ts, jspc); + ts.returnedFromCallHook(); + } + catch( Exception e ) + { + e.printStackTrace(); + // eat it. + } + } + + public DebugBreakHook getWrappedHook() {return _hook;} + + private DebugBreakHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/DebugControllerLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/DebugControllerLocal.java new file mode 100644 index 00000000000..b397a735df2 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/DebugControllerLocal.java @@ -0,0 +1,449 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; +import netscape.security.ForbiddenTargetException; +import netscape.security.PrivilegeManager; + +/** + * This is the master control panel for observing events in the VM. + * Each method setXHook() must be passed an object that extends + * the interface XHook. When an event of the specified type + * occurs, a well-known method on XHook will be called (see the + * various XHook interfacees for details). The method call takes place + * on the same thread that triggered the event in the first place, + * so that any monitors held by the thread which triggered the hook + * will still be owned in the hook method. + */ +public class DebugControllerLocal implements DebugController +{ + public long getSupportsFlags() + { + return SUPPORTS_EXEC_TO_VALUE | + SUPPORTS_CATCH_EXEC_ERRORS | + SUPPORTS_FRAME_CALL_SCOPE_THIS ; + } + + public static DebugControllerLocal getDebugController() + throws ForbiddenTargetException + { + if( null == _controllerLocal ) + _controllerLocal = new DebugControllerLocal(); + if( null == _controllerLocal || null == _controllerLocal._controller ) + throw new ForbiddenTargetException(); + return _controllerLocal; + } + + private DebugControllerLocal() + { + try + { + PrivilegeManager.enablePrivilege("Debugger"); + _controller = netscape.jsdebug.DebugController.getDebugController(); + if( null != _controller && 0 == _controller.getNativeContext() ) + { + _controller = null; + System.err.println("Unable to load natives"); + } + } + catch( ForbiddenTargetException e ) + { + System.out.println(e); + _controller = null; + } + } + + /** + * Request notification of Script loading events. Whenever a Script + * is loaded into or unloaded from the VM the appropriate method of + * the ScriptHook argument will be called. + * returns the previous hook object. + */ + public ScriptHook setScriptHook(ScriptHook h) + throws ForbiddenTargetException + { + ScriptHookLocal newWrapper = null; + if( null != h ) + newWrapper = new ScriptHookLocal(h); + + netscape.jsdebug.ScriptHook oldWrapper = + _controller.setScriptHook(newWrapper); + + if( null != oldWrapper && oldWrapper instanceof ScriptHookLocal ) + return ((ScriptHookLocal)oldWrapper).getWrappedHook(); + return null; + } + + /** + * Find the current observer of Script events, or return null if there + * is none. + */ + public ScriptHook getScriptHook() + { + netscape.jsdebug.ScriptHook oldWrapper = + _controller.getScriptHook(); + if( null != oldWrapper && oldWrapper instanceof ScriptHookLocal ) + return ((ScriptHookLocal)oldWrapper).getWrappedHook(); + return null; + } + + /** + * Set a hook at the given program counter value. When + * a thread reaches that instruction, a ThreadState object will be + * created and the appropriate method of the hook object + * will be called. + * returns the previous hook object. + */ + + public InstructionHook setInstructionHook( + PC pc, + InstructionHook h) + throws ForbiddenTargetException + { + // XXX this is hack to deal with fact that the native v1.0 JSD + // for Navigator can't handle a null instruction hook. + if( null == h ) + return null; + + netscape.jsdebug.JSPC newWrappedPC = null; + if( null != pc ) + newWrappedPC = ((JSPCLocal)pc).getWrappedJSPC(); + + InstructionHookLocal newWrapper = null; + if( null != h ) + newWrapper = new InstructionHookLocal(h, newWrappedPC); + + netscape.jsdebug.InstructionHook oldWrapper = + _controller.setInstructionHook(newWrappedPC, newWrapper); + + if( null != oldWrapper && oldWrapper instanceof InstructionHookLocal ) + return ((InstructionHookLocal)oldWrapper).getWrappedHook(); + return null; + } + + /** + * Get the hook at the given program counter value, or return + * null if there is none. + */ + public InstructionHook getInstructionHook(PC pc) + throws ForbiddenTargetException + { + if( null == pc ) + return null; + netscape.jsdebug.JSPC newWrappedPC = ((JSPCLocal)pc).getWrappedJSPC(); + + netscape.jsdebug.InstructionHook oldWrapper = + _controller.getInstructionHook(newWrappedPC); + + if( null != oldWrapper && oldWrapper instanceof InstructionHookLocal ) + return ((InstructionHookLocal)oldWrapper).getWrappedHook(); + return null; + } + + public InterruptHook setInterruptHook( InterruptHook h ) + throws ForbiddenTargetException + { + InterruptHookLocal newWrapper = null; + if( null != h ) + newWrapper = new InterruptHookLocal(h); + + netscape.jsdebug.InterruptHook oldWrapper = + _controller.setInterruptHook(newWrapper); + + if( null != oldWrapper && oldWrapper instanceof InterruptHookLocal ) + return ((InterruptHookLocal)oldWrapper).getWrappedHook(); + return null; + } + + public InterruptHook getInterruptHook() + throws ForbiddenTargetException + { + netscape.jsdebug.InterruptHook oldWrapper = + _controller.getInterruptHook(); + if( null != oldWrapper && oldWrapper instanceof InterruptHookLocal ) + return ((InterruptHookLocal)oldWrapper).getWrappedHook(); + return null; + } + + public void sendInterrupt() + throws ForbiddenTargetException + { + _controller.sendInterrupt(); + } + + public void sendInterruptStepInto(ThreadStateBase debug) + { + System.err.println("call to unimplemented function sendInterruptStepInto() failed"); + } + + public void sendInterruptStepOver(ThreadStateBase debug) + { + System.err.println("call to unimplemented function sendInterruptStepOver() failed"); + } + + public void sendInterruptStepOut(ThreadStateBase debug) + { + System.err.println("call to unimplemented function sendInterruptStepOut() failed"); + } + + public void reinstateStepper(ThreadStateBase debug) + { + System.err.println("call to unimplemented function reinstateStepper() failed"); + } + + public DebugBreakHook setDebugBreakHook( DebugBreakHook h ) + throws ForbiddenTargetException + { + DebugBreakHookLocal newWrapper = null; + if( null != h ) + newWrapper = new DebugBreakHookLocal(h); + + netscape.jsdebug.DebugBreakHook oldWrapper = + _controller.setDebugBreakHook(newWrapper); + + if( null != oldWrapper && oldWrapper instanceof DebugBreakHookLocal ) + return ((DebugBreakHookLocal)oldWrapper).getWrappedHook(); + return null; + } + + public DebugBreakHook getDebugBreakHook() + throws ForbiddenTargetException + { + netscape.jsdebug.DebugBreakHook oldWrapper = + _controller.getDebugBreakHook(); + + if( null != oldWrapper && oldWrapper instanceof DebugBreakHookLocal ) + return ((DebugBreakHookLocal)oldWrapper).getWrappedHook(); + return null; + } + + public ExecResult executeScriptInStackFrame( JSStackFrameInfo frame, + String text, + String filename, + int lineno ) + throws ForbiddenTargetException + { + JSThreadStateLocal ts = (JSThreadStateLocal)frame.getThreadState(); + Evaluator e = new Evaluator(this,ts,frame,text,filename,lineno); + return e.eval(Evaluator.TO_STRING); + } + + public ExecResult executeScriptInStackFrameValue( JSStackFrameInfo frame, + String text, + String filename, + int lineno ) + throws ForbiddenTargetException + { + JSThreadStateLocal ts = (JSThreadStateLocal)frame.getThreadState(); + Evaluator e = new Evaluator(this,ts,frame,text,filename,lineno); + return e.eval(Evaluator.TO_VALUE); + } + + + public JSErrorReporter setErrorReporter(JSErrorReporter h) + throws ForbiddenTargetException + { + JSErrorReporterLocal newWrapper = null; + if( null != h ) + newWrapper = new JSErrorReporterLocal(h); + + netscape.jsdebug.JSErrorReporter oldWrapper = + _controller.setErrorReporter(newWrapper); + + if( null != oldWrapper && oldWrapper instanceof JSErrorReporterLocal) + return ((JSErrorReporterLocal)oldWrapper).getWrappedHook(); + return null; + } + + public JSErrorReporter getErrorReporter() + throws ForbiddenTargetException + { + netscape.jsdebug.JSErrorReporter oldWrapper = + _controller.getErrorReporter(); + + if( null != oldWrapper && oldWrapper instanceof JSErrorReporterLocal) + return ((JSErrorReporterLocal)oldWrapper).getWrappedHook(); + return null; + } + + public void iterateScripts(ScriptHook h) + { + // XXX does nothing at present... + } + + public int getMajorVersion() + { + return _controller.getMajorVersion(); + } + public int getMinorVersion() + { + return _controller.getMinorVersion(); + } + + public netscape.jsdebug.DebugController getWrappedController() + { + return _controller; + } + + // data... + + private netscape.jsdebug.DebugController _controller = null; + + private static DebugControllerLocal _controllerLocal = null; +} + +class Evaluator + implements Callback, JSErrorReporter +{ + static final boolean TO_STRING = false; + static final boolean TO_VALUE = true; + + Evaluator(DebugControllerLocal dc, + JSThreadStateLocal ts, + JSStackFrameInfo frame, + String text, + String filename, + int lineno) + { + _dc = dc ; + _ts = ts ; + _frame = frame ; + _text = text ; + _filename = filename; + _lineno = lineno ; + } + + ExecResultLocal eval(boolean toValue) + { + _evalToValue = toValue; + + if( !_ts.isWaitingForResume() ) + { + call(); // just call directly on this thread. + } + else + { + if( ! _completed && _ts.addCallbackEvent(this) ) + { + synchronized(this) + { + while( ! _completed ) + { + try + { + wait(); + } + catch(Exception e) + { + // eat it... + e.printStackTrace(); + System.out.println(e); + break; + } + } + } + } + } + return _execResult; + } + + // implement Callback + public synchronized void call() + { + JSErrorReporter oldER = null; + boolean setER = false; + try + { + PrivilegeManager.enablePrivilege("Debugger"); + oldER = _dc.setErrorReporter(this); + setER = true; + + if(_evalToValue) + { + // we break this out as a seperate method because + // netscape.jsdebug 1.0 had no Value class and we need to + // avoid any unnecessary references to netscape.jsdebug.Value. + _doEvalToValue(); + } + else + { + String result = + _dc.getWrappedController().executeScriptInStackFrame( + ((JSStackFrameInfoLocal)_frame).getWrappedInfo(), + _text, + _filename, + _lineno); + if(null == _execResult) + _execResult = new ExecResultLocal(result); + } + + } + catch(Exception e) + { + // eat it... + e.printStackTrace(); + System.out.println(e); + } + + if(setER) + _dc.setErrorReporter(oldER); + _completed = true; + notify(); + } + + private void _doEvalToValue() throws Exception + { + netscape.jsdebug.Value result = + _dc.getWrappedController().executeScriptInStackFrameValue( + ((JSStackFrameInfoLocal)_frame).getWrappedInfo(), + _text, + _filename, + _lineno); + + if(null == _execResult) + _execResult = new ExecResultLocal(new ValueLocal(result)); + } + + + // implements JSErrorReporter + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + _execResult = new ExecResultLocal(msg, filename, lineno, + linebuf, tokenOffset); + return netscape.jsdebug.JSErrorReporter.RETURN; + } + + private DebugControllerLocal _dc; + private JSThreadStateLocal _ts; + private JSStackFrameInfo _frame; + private String _text; + private String _filename; + private int _lineno; + private boolean _completed; + private boolean _evalToValue; + private ExecResultLocal _execResult; +} + + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ExecResultLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ExecResultLocal.java new file mode 100644 index 00000000000..50334af2b4c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ExecResultLocal.java @@ -0,0 +1,62 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +public class ExecResultLocal + implements com.netscape.jsdebugging.api.ExecResult +{ + ExecResultLocal(String str) {_str = str;} + ExecResultLocal(ValueLocal val) {_val = val;} + ExecResultLocal(String errorMessage, + String errorFilename, + int errorLineNumber, + String errorLineBuffer, + int errorTokenOffset) + + { + _errorOccured = true; + _errorMessage = errorMessage; + _errorFilename = errorFilename; + _errorLineNumber = errorLineNumber; + _errorLineBuffer = errorLineBuffer; + _errorTokenOffset= errorTokenOffset; + } + + public String getResult() {return _str;} + public boolean getErrorOccured() {return _errorOccured;} + public String getErrorMessage() {return _errorMessage;} + public String getErrorFilename() {return _errorFilename;} + public int getErrorLineNumber() {return _errorLineNumber;} + public String getErrorLineBuffer() {return _errorLineBuffer;} + public int getErrorTokenOffset() {return _errorTokenOffset;} + + public com.netscape.jsdebugging.api.Value getResultValue() {return _val;} + + private String _str; + private ValueLocal _val; + + private boolean _errorOccured; + private String _errorMessage; + private String _errorFilename; + private int _errorLineNumber; + private String _errorLineBuffer; + private int _errorTokenOffset; +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/InstructionHookLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/InstructionHookLocal.java new file mode 100644 index 00000000000..f824325f3c7 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/InstructionHookLocal.java @@ -0,0 +1,47 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +/** + * InstructionHook must be subinterfaceed to respond to hooks + * at a particular program instruction. + */ +public class InstructionHookLocal extends netscape.jsdebug.InstructionHook +{ + InstructionHookLocal( InstructionHook hook, + netscape.jsdebug.JSPC pc ) + { + super(pc); + _hook = hook; + } + + public void aboutToExecute(netscape.jsdebug.ThreadStateBase debug) + { + JSThreadStateLocal ts = new JSThreadStateLocal(debug); + ts.aboutToCallHook(); + _hook.aboutToExecute(ts); + ts.returnedFromCallHook(); + } + + public InstructionHook getWrappedHook() {return _hook;} + + private InstructionHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/InterruptHookLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/InterruptHookLocal.java new file mode 100644 index 00000000000..346341385df --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/InterruptHookLocal.java @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +/** + * InterruptHook must be subinterfaceed to respond to hooks + * at a particular program instruction. + */ +public class InterruptHookLocal extends netscape.jsdebug.InterruptHook +{ + public InterruptHookLocal( InterruptHook hook ) + { + _hook = hook; + } + + public void aboutToExecute(netscape.jsdebug.ThreadStateBase debug, + netscape.jsdebug.PC pc) + { +// System.out.println( "InterruptHookLocal called..." ); + try + { + JSThreadStateLocal ts = new JSThreadStateLocal(debug); + JSPCLocal jspc = (JSPCLocal) ts.getCurrentFrame().getPC(); + ts.aboutToCallHook(); + _hook.aboutToExecute(ts, jspc); + ts.returnedFromCallHook(); + } + catch( Exception e ) + { + e.printStackTrace(); + // eat it. + } + } + + public InterruptHook getWrappedHook() {return _hook;} + + private InterruptHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSErrorReporterLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSErrorReporterLocal.java new file mode 100644 index 00000000000..4215856c20f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSErrorReporterLocal.java @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +public class JSErrorReporterLocal implements netscape.jsdebug.JSErrorReporter +{ + public JSErrorReporterLocal(JSErrorReporter er) + { + _er = er; + } + + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + return _er.reportError(msg, filename, lineno, linebuf, tokenOffset); + } + + public JSErrorReporter getWrappedHook() {return _er;} + + private JSErrorReporter _er; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSPCLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSPCLocal.java new file mode 100644 index 00000000000..e24040974a7 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSPCLocal.java @@ -0,0 +1,68 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +/** + * This subinterface of PC provides JavaScript-specific information. + */ +public class JSPCLocal implements JSPC +{ + public JSPCLocal(netscape.jsdebug.JSPC pc) + { + this( pc, new ScriptLocal(pc.getScript()) ); + } + + public JSPCLocal(netscape.jsdebug.JSPC pc, ScriptLocal script) + { + _pc = pc; + _script = script; + _sourceLocation = + new JSSourceLocationLocal(this, + (netscape.jsdebug.JSSourceLocation)_pc.getSourceLocation()); + } + + public Script getScript() {return _script;} + public int getPC() {return _pc.getPC();} + public boolean isValid() {return _pc.isValid();} + public SourceLocation getSourceLocation() {return _sourceLocation;} + + public boolean equals(Object obj) + { + try + { + JSPCLocal other = (JSPCLocal) obj; + return other._pc.getScript() == _pc.getScript() && + other._pc.getPC() == _pc.getPC(); + } + catch( ClassCastException e ) + { + return false; + } + } + public int hashCode() {return _pc.hashCode();} + public String toString() {return _pc.toString();} + + public netscape.jsdebug.JSPC getWrappedJSPC() {return _pc;} + + private netscape.jsdebug.JSPC _pc; + private ScriptLocal _script; + private JSSourceLocationLocal _sourceLocation; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSSourceLocationLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSSourceLocationLocal.java new file mode 100644 index 00000000000..a46bebd448b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSSourceLocationLocal.java @@ -0,0 +1,53 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +public class JSSourceLocationLocal implements JSSourceLocation +{ + public JSSourceLocationLocal( JSPCLocal pc, + netscape.jsdebug.JSSourceLocation sl ) + { + _pc = pc; + _sl = sl; + } + public int getLine() {return _sl.getLine();} + public String getURL() {return _sl.getURL();} + public PC getPC() {return _pc;} + public String toString() {return _sl.toString();} + + public boolean equals(Object obj) + { + try + { + JSSourceLocationLocal other = (JSSourceLocationLocal) obj; + return getLine() == other.getLine() && + getURL().equals(other.getURL()); + } + catch( ClassCastException e ) + { + return false; + } + } + public int hashCode() {return getURL().hashCode() + 17*getLine();} + + private JSPCLocal _pc; + private netscape.jsdebug.JSSourceLocation _sl; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSStackFrameInfoLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSStackFrameInfoLocal.java new file mode 100644 index 00000000000..3a7401d500c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSStackFrameInfoLocal.java @@ -0,0 +1,110 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +/** + * This interface provides access to the execution stack of a thread. + * It has several subinterfacees to distinguish between different kinds of + * stack frames: these currently include activations of Java methods + * or JavaScript functions. + * It is possible that synchronize blocks and try blocks deserve their own + * stack frames - to allow for later extensions a debugger should skip over + * stack frames it doesn't understand. + * Note that this appears very Java-specific. However, multiple threads and + * exceptions are relevant to JavaScript as well because of its + * interoperation with Java. + */ +public class JSStackFrameInfoLocal implements JSStackFrameInfo +{ + public JSStackFrameInfoLocal( netscape.jsdebug.JSStackFrameInfo info, + JSThreadStateLocal ts ) + { + _info = info; + _ts = ts; + try + { + _pc = new JSPCLocal((netscape.jsdebug.JSPC)_info.getPC()); + } + catch( netscape.jsdebug.InvalidInfoException e ) + { + _pc = null; + } + + } + + public boolean isValid() {return _info.isValid();} + public ThreadStateBase getThreadState() {return _ts;} + public PC getPC() throws InvalidInfoException + { + if( null == _pc ) + throw new InvalidInfoException(); + return _pc; + } + + public Value getCallObject() throws InvalidInfoException + { + if( ! _info.isValid() ) + throw new InvalidInfoException(); + try + { + return new ValueLocal(_info.getCallObject()); + } + catch(netscape.jsdebug.InvalidInfoException e) + { + throw new InvalidInfoException(); + } + } + + public Value getScopeChain() throws InvalidInfoException + { + if( ! _info.isValid() ) + throw new InvalidInfoException(); + try + { + return new ValueLocal(_info.getScopeChain()); + } + catch(netscape.jsdebug.InvalidInfoException e) + { + throw new InvalidInfoException(); + } + } + + public Value getThis() throws InvalidInfoException + { + if( ! _info.isValid() ) + throw new InvalidInfoException(); + try + { + return new ValueLocal(_info.getThis()); + } + catch(netscape.jsdebug.InvalidInfoException e) + { + throw new InvalidInfoException(); + } + } + + public netscape.jsdebug.JSStackFrameInfo getWrappedInfo() {return _info;} + + private netscape.jsdebug.JSStackFrameInfo _info; + private JSThreadStateLocal _ts; + private JSPCLocal _pc; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSThreadStateLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSThreadStateLocal.java new file mode 100644 index 00000000000..df29d080e2e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/JSThreadStateLocal.java @@ -0,0 +1,226 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +public class JSThreadStateLocal implements JSThreadState +{ + public JSThreadStateLocal( netscape.jsdebug.ThreadStateBase ts ) + { + _ts = ts; + try + { + netscape.jsdebug.StackFrameInfo[] stack = _ts.getStack(); + + if( null != stack && 0 != stack.length ) + { + _stack = new JSStackFrameInfoLocal[stack.length]; + for( int i = 0; i < stack.length; i++ ) + _stack[i] = new JSStackFrameInfoLocal( + (netscape.jsdebug.JSStackFrameInfo)stack[i], + this); + } + } + catch( netscape.jsdebug.InvalidInfoException e ) + { + _stack = null; + } + } + + public boolean isValid() {return null != _stack && _ts.isValid();} + public int getStatus() {return _ts.getStatus();} + + public int countStackFrames() + throws InvalidInfoException + { + if( null == _stack ) + throw new InvalidInfoException(); + return _stack.length; + } + + public StackFrameInfo getCurrentFrame() + throws InvalidInfoException + { + if( null == _stack ) + throw new InvalidInfoException(); + return _stack[_stack.length-1]; + } + + /** + * Get the thread's stack as an array. stack[stack.length-1] is the + * current frame, and stack[0] is the beginning of the stack. + */ + public StackFrameInfo[] getStack() + throws InvalidInfoException + { + if( null == _stack ) + throw new InvalidInfoException(); + return _stack; + } + + /** + * Return true if the thread is currently running a hook + * for this ThreadState + */ + public boolean isRunningHook() + { + return _runningHook; + } + + /** + * Return true if the hook on this thread has already completed + * and we are waiting for a call to resume() + */ + public boolean isWaitingForResume() + { + return _runningEventQueue; + } + + + /** + * Leave the thread in a suspended state when the hook method(s) + * finish. This can be undone by calling resume(). + */ + public synchronized void leaveSuspended() + { + if( _runningHook && ! _runningEventQueue ) + _leaveSuspended = true; + } + + /** + * Resume the thread. + * Two cases: + * 1) Hook is still running, this will undo the leaveSuspended + * and the thread will still be waiting for the hook to + * return. + * 2) Hook has already returned and we are in an event loop + * waiting to contine the suspended thread, this will + * force completion of events pending on the suspended + * thread and resume it. + */ + public synchronized void resume() + { + if( ! _runningHook ) + return; + + _leaveSuspended = false; + + // signal stopped thread + if( _runningEventQueue ) + notifyAll(); + } + + /** + * This gets the current continue state of the debug frame, which + * will be one of the DEBUG_STATE_* values above. + */ + public int getContinueState() {return _ts.getContinueState();} + + public int setContinueState(int state) {return _ts.setContinueState(state);} + + public synchronized void aboutToCallHook() + { + _runningHook = true; + + } + public synchronized void returnedFromCallHook() + { + if(_leaveSuspended) + { + _runningEventQueue = true; + while( _leaveSuspended ) + { + try + { + wait(); + } + catch(Exception e) + { + e.printStackTrace(); + System.out.println(e); + _leaveSuspended = false; + } + processAllEvents(); + } + _runningEventQueue = false; + } + _runningHook = false; + } + + public synchronized boolean addCallbackEvent(Callback cb) + { + if( _runningEventQueue ) + { + addEvent(cb); + notify(); + return true; + } + return false; + } + + private synchronized void addEvent(Callback cb) + { + Event e = new Event(); + e.cb = cb; + if( null != _lastEvent ) + _lastEvent.next = e; + _lastEvent = e; + if( null == _firstEvent ) + _firstEvent = e; + } + + private synchronized Event getEvent() + { + Event e = _firstEvent; + if( null != e ) + { + _firstEvent = e.next; + if( _lastEvent == e ) + _lastEvent = null; + e.next = null; + } + return e; + } + + private synchronized void processAllEvents() + { + Event e; + while( null != (e = getEvent()) ) + { + if( null != e.cb ) + e.cb.call(); + } + } + + private netscape.jsdebug.ThreadStateBase _ts; + private JSStackFrameInfoLocal[] _stack; + private boolean _runningHook = false; + private boolean _leaveSuspended = false; + private boolean _runningEventQueue = false; + private Event _firstEvent = null; + private Event _lastEvent = null; +} + + +class Event +{ + public Event next = null; + public Callback cb = null; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/PropertyLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/PropertyLocal.java new file mode 100644 index 00000000000..0164a5999a2 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/PropertyLocal.java @@ -0,0 +1,58 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +public class PropertyLocal + implements com.netscape.jsdebugging.api.Property +{ + PropertyLocal(netscape.jsdebug.Property prop) {_prop = prop;} + + public boolean isNameString() {return _prop.isNameString();} + public boolean isAliasString() {return _prop.isAliasString();} + + public String getNameString() {return _prop.getNameString();} + public int getNameInt() {return _prop.getNameInt();} + + public String getAliasString() {return _prop.getAliasString();} + public int getAliasInt() {return _prop.getAliasInt();} + + public com.netscape.jsdebugging.api.Value getValue() + { + if(null == _val) + _val = new ValueLocal(_prop.getValue()); + return _val; + } + + public int getVarArgSlot() {return _prop.getVarArgSlot();} + + public int getFlags() {return _prop.getFlags();} + public boolean canEnumerate() {return _prop.canEnumerate();} + public boolean isReadOnly() {return _prop.isReadOnly();} + public boolean isPermanent() {return _prop.isPermanent();} + public boolean hasAlias() {return _prop.hasAlias();} + public boolean isArgument() {return _prop.isArgument();} + public boolean isVariable() {return _prop.isVariable();} + public boolean isHinted() {return _prop.isHinted();} + + // override Object + public String toString() {return _prop.toString();} + + private netscape.jsdebug.Property _prop; + private com.netscape.jsdebugging.api.Value _val; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/README b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/README new file mode 100644 index 00000000000..a616b70cc48 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/README @@ -0,0 +1,5 @@ +/* jband - 09/14/98 - */ + +com.netscape.jsdebugging.api.local implements the interfaces defined in +com.netscape.jsdebugging.api. It supports adapting the debugger(s) to the +netscape.jsdebug api used in mozilla (and the stand-alone C based JS engine). \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptHookLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptHookLocal.java new file mode 100644 index 00000000000..1ed38d75073 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptHookLocal.java @@ -0,0 +1,47 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +/** + * ScriptHook must be subinterfaceed to respond to significant events + * in the virtual machine. + */ +public class ScriptHookLocal extends netscape.jsdebug.ScriptHook +{ + public ScriptHookLocal( ScriptHook hook ) + { + _hook = hook; + } + + public void justLoadedScript(netscape.jsdebug.Script script) + { + _hook.justLoadedScript( new ScriptLocal(script) ); + } + + public void aboutToUnloadScript(netscape.jsdebug.Script script) + { + _hook.aboutToUnloadScript( new ScriptLocal(script) ); + } + + public ScriptHook getWrappedHook() {return _hook;} + + private ScriptHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptLocal.java new file mode 100644 index 00000000000..c148b7b9bcf --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptLocal.java @@ -0,0 +1,63 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +public class ScriptLocal implements Script +{ + ScriptLocal(netscape.jsdebug.Script script) + { + _script = script; + _sections = new ScriptSectionLocal[1]; + _sections[0] = new ScriptSectionLocal(_script.getBaseLineNumber(), + _script.getLineExtent()); + } + + public String getURL() {return _script.getURL();} + public String getFunction() {return _script.getFunction();} + public int getBaseLineNumber() {return _script.getBaseLineNumber();} + public int getLineExtent() {return _script.getLineExtent();} + public boolean isValid() {return _script.isValid();} + public JSPC getClosestPC(int line) + { + return new JSPCLocal(_script.getClosestPC(line), this); + } + + public ScriptSection[] getSections() {return _sections;} + + public String toString() {return _script.toString();} + public int hashCode() {return _script.hashCode();} + public boolean equals(Object obj) + { + try + { + return ((ScriptLocal)obj)._script == _script; + } + catch( ClassCastException e ) + { + return false; + } + } + + public netscape.jsdebug.Script getRealScript() {return _script;} + + private ScriptSectionLocal[] _sections; + private netscape.jsdebug.Script _script; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptSectionLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptSectionLocal.java new file mode 100644 index 00000000000..da413304793 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ScriptSectionLocal.java @@ -0,0 +1,37 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +public class ScriptSectionLocal implements ScriptSection +{ + public ScriptSectionLocal( int base, int extent ) + { + _base = base; + _extent = extent; + } + + public int getBaseLineNumber() {return _base;} + public int getLineExtent() {return _extent;} + + private int _base; + private int _extent; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/SourceTextItemLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/SourceTextItemLocal.java new file mode 100644 index 00000000000..715ff25381e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/SourceTextItemLocal.java @@ -0,0 +1,80 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; + +public class SourceTextItemLocal + implements SourceTextItem +{ + public SourceTextItemLocal(netscape.jsdebug.SourceTextItem sti) + { + _sti = sti; + // + // XXX Hack to deal with the fact that JSScript 'filenames' for + // urls containing query parts are truncated at '?', while sources + // contain the full URL. (do the same for '#') + + int index; + String url = _sti.getURL(); + if( -1 != (index = url.indexOf('?')) || + -1 != (index = url.indexOf('#')) ) + _url = url.substring(0,index); + else + _url = url; + } + + // implements SourceTextItem + public String getURL() {return _url;} + public String getText() {return _sti.getText();} + public int getStatus() {return _sti.getStatus();} + public int getAlterCount() + { + if( _sti.getDirty() ) + { + _sti.setDirty(false); + _lastAlterCount++; + } + return _lastAlterCount; + } + + public boolean getDirty() {return _sti.getDirty();} + public void setDirty(boolean b) {_sti.setDirty(b);} + + public int hashCode() {return _sti.getURL().hashCode();} + public boolean equals(Object obj) + { + try + { + return ((SourceTextItemLocal)obj)._sti == _sti; + } + catch( ClassCastException e ) + { + return false; + } + } + + public netscape.jsdebug.SourceTextItem getWrappedItem() {return _sti;} + + // data + + private String _url; + private netscape.jsdebug.SourceTextItem _sti = null; + private int _lastAlterCount = 0; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/SourceTextProviderLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/SourceTextProviderLocal.java new file mode 100644 index 00000000000..8cf48a9d0b0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/SourceTextProviderLocal.java @@ -0,0 +1,138 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +import com.netscape.jsdebugging.api.*; +import netscape.util.Vector; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; + +public class SourceTextProviderLocal + implements SourceTextProvider +{ + // allow for possible singleton-ness enforcement + public static SourceTextProvider getSourceTextProvider() + { + return new SourceTextProviderLocal(); + } + + private SourceTextProviderLocal() + { + try + { + PrivilegeManager.enablePrivilege("Debugger"); + _pro = (netscape.jsdebug.JSSourceTextProvider) + netscape.jsdebug.JSSourceTextProvider.getSourceTextProvider(); + } + catch( ForbiddenTargetException e ) + { + // eat it; + } + } + + // implement netscape.jsdebugger.SourceTextProvider + + public SourceTextItem[] getItems() + { + if( null == _pro ) + return null; + + if( null == _items ) + _rebuildItemsArray(); + return _items; + } + public void refreshAll() + { + if( null == _pro ) + return; + _pro.refreshSourceTextVector(); + _rebuildItemsArray(); + } + public SourceTextItem findItem(String url) + { + if( null == _pro ) + return null; + if( null == _items ) + _rebuildItemsArray(); + + if( null == _items ) + return null; + + for( int i = 0; i < _items.length; i++ ) + { + if( url.equals(_items[i].getURL()) ) + return _items[i]; + } + return null; + } + public SourceTextItem loadItem(String url) + { + // XXX not implemented... + return null; + } + + // this goes through some gyrations to try to reuse existing item wrappers + private void _rebuildItemsArray() + { + SourceTextItemLocal[] olditems = _items; + _items = null; + + if( null == _pro ) + return; + try + { + int count; + PrivilegeManager.enablePrivilege("Debugger"); + Vector v = _pro.getSourceTextVector(); + if( null == v || 0 == (count = v.size()) ) + return; + SourceTextItemLocal[] newitems = new SourceTextItemLocal[count]; + next_item: for( int i = 0; i < count; i++ ) + { + netscape.jsdebug.SourceTextItem rawItem = + (netscape.jsdebug.SourceTextItem) v.elementAt(i); + if( null != olditems && 0 != olditems.length ) + { + + for( int k = 0; k < olditems.length; k++ ) + { + SourceTextItemLocal item = olditems[k]; + if( item.getWrappedItem() == rawItem ) + { + newitems[i] = item; + continue next_item; + } + } + } + newitems[i] = new SourceTextItemLocal(rawItem); + } + _items = newitems; + } + catch( ForbiddenTargetException e ) + { + // eat it; + } + } + + + // data + + private netscape.jsdebug.JSSourceTextProvider _pro = null; + private SourceTextItemLocal[] _items = null; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ValueLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ValueLocal.java new file mode 100644 index 00000000000..3852fb6e3ff --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/local/ValueLocal.java @@ -0,0 +1,160 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.local; + +public class ValueLocal + implements com.netscape.jsdebugging.api.Value +{ + ValueLocal(netscape.jsdebug.Value val) {_val = val;} + + public boolean isObject() {return _val.isObject();} + public boolean isNumber() {return _val.isNumber();} + public boolean isInt() {return _val.isInt();} + public boolean isDouble() {return _val.isDouble();} + public boolean isString() {return _val.isString();} + public boolean isBoolean() {return _val.isBoolean();} + public boolean isNull() {return _val.isNull();} + public boolean isVoid() {return _val.isVoid();} + public boolean isPrimitive() {return _val.isPrimitive();} + public boolean isFunction() {return _val.isFunction();} + public boolean isNative() {return _val.isNative();} + + public boolean getBoolean() {return _val.getBoolean();} + public int getInt() {return _val.getInt();} + public double getDouble() {return _val.getDouble();} + + public String getString() {return _val.getString();} + public String getFunctionName() {return _val.getFunctionName();} + public String getClassName() {return _val.getClassName();} + + public com.netscape.jsdebugging.api.Value getPrototype() + { + if(null == _proto && !_getFlag(GOT_PROTO)) + { + netscape.jsdebug.Value p = _val.getPrototype(); + if(null != p) + _proto = new ValueLocal(p); + _setFlag(GOT_PROTO); + } + return _proto; + } + + public com.netscape.jsdebugging.api.Value getParent() + { + if(null == _parent && !_getFlag(GOT_PARENT)) + { + netscape.jsdebug.Value p = _val.getParent(); + if(null != p) + _parent = new ValueLocal(p); + _setFlag(GOT_PARENT); + } + return _parent; + } + + public com.netscape.jsdebugging.api.Value getConstructor() + { + if(null == _ctor && !_getFlag(GOT_CTOR)) + { + netscape.jsdebug.Value c = _val.getConstructor(); + if(null != c) + _ctor = new ValueLocal(c); + _setFlag(GOT_CTOR); + } + return _ctor; + } + + public com.netscape.jsdebugging.api.Property[] getProperties() + { + if(null == _props && !_getFlag(GOT_PROPS)) + { + netscape.jsdebug.Property[] p = _val.getProperties(); + if(null != p && 0 != p.length) + { + _props = new PropertyLocal[p.length]; + for( int i = 0; i < p.length; i++) + _props[i] = new PropertyLocal(p[i]); + } + _setFlag(GOT_PROPS); + } + return _props; + } + + public com.netscape.jsdebugging.api.Property getProperty(String name) + { + if(null == name) + return null; + com.netscape.jsdebugging.api.Property[] props = getProperties(); + if(null == props) + return null; + for(int i = 0; i < props.length; i++) + if(name.equals(props[i].getNameString())) + return props[i]; + netscape.jsdebug.Property wprop = _val.getProperty(name); + if(null == wprop) + return null; + com.netscape.jsdebugging.api.Property prop = new PropertyLocal(wprop); + if(null != prop) { + com.netscape.jsdebugging.api.Property[] newProps = + new com.netscape.jsdebugging.api.Property[props.length+1]; + System.arraycopy(props, 0, newProps, 0, props.length); + newProps[props.length] = prop; + _props = newProps; + } + return prop; + } + + public String[] getPropertyHints() {return _val.getPropertyHints();} + public void setPropertyHints(String[] hints) {_val.setPropertyHints(hints);} + + public void refresh() { + _val.refresh(); + _flags = 0; + _props = null; + _proto = null; + _parent = null; + _ctor = null; + } + + public netscape.jsdebug.Value getWrappedValue() {return _val;} + + // override Object + public String toString() {return _val.toString();} + public int hashCode() {return _val.hashCode();} + + // private flagage... + + private static final short GOT_PROTO = (short) (1 << 0); + private static final short GOT_PROPS = (short) (1 << 1); + private static final short GOT_PARENT = (short) (1 << 2); + private static final short GOT_CTOR = (short) (1 << 3); + + private final boolean _getFlag(short b) {return 0 != (_flags & b);} + private final void _setFlag(short b) {_flags |= b;} + private final void _clearFlag(short b) {_flags &= ~b;} + private short _flags; + + // private data... + + private netscape.jsdebug.Value _val; + + private com.netscape.jsdebugging.api.Property[] _props; + private com.netscape.jsdebugging.api.Value _proto; + private com.netscape.jsdebugging.api.Value _parent; + private com.netscape.jsdebugging.api.Value _ctor; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/AdapterLoaderRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/AdapterLoaderRhino.java new file mode 100644 index 00000000000..2716dfa3828 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/AdapterLoaderRhino.java @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import netscape.security.ForbiddenTargetException; +import com.netscape.jsdebugging.api.DebugController; +import com.netscape.jsdebugging.api.SourceTextProvider; + +public class AdapterLoaderRhino + implements com.netscape.jsdebugging.api.AdapterLoader +{ + public void setHost(String host) {} // ignored + public boolean isDebuggingSupported() throws ForbiddenTargetException + { + return null != DebugControllerRhino.getDebugController(); + } + public DebugController getDebugController() throws ForbiddenTargetException + { + return DebugControllerRhino.getDebugController(); + } + public SourceTextProvider getSourceTextProvider() + { + return SourceTextProviderRhino.getSourceTextProvider(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/Callback.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/Callback.java new file mode 100644 index 00000000000..6b1f1d2fd5d --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/Callback.java @@ -0,0 +1,24 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +public interface Callback +{ + public void call(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/DebugBreakHookRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/DebugBreakHookRhino.java new file mode 100644 index 00000000000..de0252c84f5 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/DebugBreakHookRhino.java @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +/** + * DebugBreakHook must be subclassed to respond to hooks + * at a particular program instruction. + */ +public class DebugBreakHookRhino implements com.netscape.javascript.debug.IDebugBreakHook +{ + public DebugBreakHookRhino( DebugBreakHook hook ) + { + _hook = hook; + } + + public void aboutToExecute(com.netscape.javascript.debug.IThreadState debug, + com.netscape.javascript.debug.IPC pc) + { + try + { + JSThreadStateRhino ts = new JSThreadStateRhino(debug); + JSPCRhino jspc = (JSPCRhino) ts.getCurrentFrame().getPC(); + ts.aboutToCallHook(); + _hook.aboutToExecute(ts, jspc); + ts.returnedFromCallHook(); + } + catch( Exception e ) + { + e.printStackTrace(); + // eat it. + } + } + + public DebugBreakHook getWrappedHook() {return _hook;} + + private DebugBreakHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/DebugControllerRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/DebugControllerRhino.java new file mode 100644 index 00000000000..9bfaa997165 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/DebugControllerRhino.java @@ -0,0 +1,396 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; +import netscape.security.ForbiddenTargetException; +import netscape.security.PrivilegeManager; + +/** + * This is the master control panel for observing events in the VM. + * Each method setXHook() must be passed an object that extends + * the interface XHook. When an event of the specified type + * occurs, a well-known method on XHook will be called (see the + * various XHook interfacees for details). The method call takes place + * on the same thread that triggered the event in the first place, + * so that any monitors held by the thread which triggered the hook + * will still be owned in the hook method. + */ +public class DebugControllerRhino implements DebugController +{ + public long getSupportsFlags() + { + return 0; + } + + public static boolean setGlobalDebugManager(com.netscape.javascript.debug.IDebugManager manager) + { + if(null != _controller) + return false; + _controller = manager; + return true; + } + + public static DebugControllerRhino getDebugController() + throws ForbiddenTargetException + { + if( null == _controllerRhino ) + _controllerRhino = new DebugControllerRhino(); + if( null == _controllerRhino ) + throw new ForbiddenTargetException(); + if( null == _controllerRhino._controller ) + { + _controllerRhino = null; + throw new ForbiddenTargetException(); + } + return _controllerRhino; + } + + private DebugControllerRhino() + { + } + + /** + * Request notification of Script loading events. Whenever a Script + * is loaded into or unloaded from the VM the appropriate method of + * the ScriptHook argument will be called. + * returns the previous hook object. + */ + public ScriptHook setScriptHook(ScriptHook h) + throws ForbiddenTargetException + { + ScriptHookRhino newWrapper = null; + if( null != h ) + newWrapper = new ScriptHookRhino(h); + + com.netscape.javascript.debug.IScriptHook oldWrapper = + _controller.setScriptHook(newWrapper); + + if( null != oldWrapper && oldWrapper instanceof ScriptHookRhino ) + return ((ScriptHookRhino)oldWrapper).getWrappedHook(); + return null; + } + + /** + * Find the current observer of Script events, or return null if there + * is none. + */ + public ScriptHook getScriptHook() + { + com.netscape.javascript.debug.IScriptHook oldWrapper = + _controller.getScriptHook(); + if( null != oldWrapper && oldWrapper instanceof ScriptHookRhino ) + return ((ScriptHookRhino)oldWrapper).getWrappedHook(); + return null; + } + + /** + * Set a hook at the given program counter value. When + * a thread reaches that instruction, a ThreadState object will be + * created and the appropriate method of the hook object + * will be called. + * returns the previous hook object. + */ + + public InstructionHook setInstructionHook( + PC pc, + InstructionHook h) + throws ForbiddenTargetException + { + // XXX this is hack to deal with fact that the native v1.0 JSD + // for Navigator can't handle a null instruction hook. + if( null == h ) + return null; + + com.netscape.javascript.debug.IPC newWrappedPC = null; + if( null != pc ) + newWrappedPC = ((JSPCRhino)pc).getWrappedJSPC(); + + InstructionHookRhino newWrapper = null; + if( null != h ) + newWrapper = new InstructionHookRhino(h, newWrappedPC); + + com.netscape.javascript.debug.IInstructionHook oldWrapper = + _controller.setInstructionHook(newWrappedPC, newWrapper); + + if( null != oldWrapper && oldWrapper instanceof InstructionHookRhino ) + return ((InstructionHookRhino)oldWrapper).getWrappedHook(); + return null; + } + + /** + * Get the hook at the given program counter value, or return + * null if there is none. + */ + public InstructionHook getInstructionHook(PC pc) + throws ForbiddenTargetException + { + if( null == pc ) + return null; + com.netscape.javascript.debug.IPC newWrappedPC = ((JSPCRhino)pc).getWrappedJSPC(); + + com.netscape.javascript.debug.IInstructionHook oldWrapper = + _controller.getInstructionHook(newWrappedPC); + + if( null != oldWrapper && oldWrapper instanceof InstructionHookRhino ) + return ((InstructionHookRhino)oldWrapper).getWrappedHook(); + return null; + } + + public InterruptHook setInterruptHook( InterruptHook h ) + throws ForbiddenTargetException + { + InterruptHookRhino newWrapper = null; + if( null != h ) + newWrapper = new InterruptHookRhino(h); + + com.netscape.javascript.debug.IInterruptHook oldWrapper = + _controller.setInterruptHook(newWrapper); + + if( null != oldWrapper && oldWrapper instanceof InterruptHookRhino ) + return ((InterruptHookRhino)oldWrapper).getWrappedHook(); + return null; + } + + public InterruptHook getInterruptHook() + throws ForbiddenTargetException + { + com.netscape.javascript.debug.IInterruptHook oldWrapper = + _controller.getInterruptHook(); + if( null != oldWrapper && oldWrapper instanceof InterruptHookRhino ) + return ((InterruptHookRhino)oldWrapper).getWrappedHook(); + return null; + } + + public void sendInterrupt() + throws ForbiddenTargetException + { + _controller.sendInterrupt(); + } + + public void sendInterruptStepInto(ThreadStateBase debug) + { + System.err.println("call to unimplemented function sendInterruptStepInto() failed"); + } + + public void sendInterruptStepOver(ThreadStateBase debug) + { + System.err.println("call to unimplemented function sendInterruptStepOver() failed"); + } + + public void sendInterruptStepOut(ThreadStateBase debug) + { + System.err.println("call to unimplemented function sendInterruptStepOut() failed"); + } + + public void reinstateStepper(ThreadStateBase debug) + { + System.err.println("call to unimplemented function reinstateStepper() failed"); + } + + public DebugBreakHook setDebugBreakHook( DebugBreakHook h ) + throws ForbiddenTargetException + { + DebugBreakHookRhino newWrapper = null; + if( null != h ) + newWrapper = new DebugBreakHookRhino(h); + + com.netscape.javascript.debug.IDebugBreakHook oldWrapper = + _controller.setDebugBreakHook(newWrapper); + + if( null != oldWrapper && oldWrapper instanceof DebugBreakHookRhino ) + return ((DebugBreakHookRhino)oldWrapper).getWrappedHook(); + return null; + } + + public DebugBreakHook getDebugBreakHook() + throws ForbiddenTargetException + { + com.netscape.javascript.debug.IDebugBreakHook oldWrapper = + _controller.getDebugBreakHook(); + + if( null != oldWrapper && oldWrapper instanceof DebugBreakHookRhino ) + return ((DebugBreakHookRhino)oldWrapper).getWrappedHook(); + return null; + } + + public ExecResult executeScriptInStackFrame( JSStackFrameInfo frame, + String text, + String filename, + int lineno ) + throws ForbiddenTargetException + { + JSThreadStateRhino ts = (JSThreadStateRhino)frame.getThreadState(); + + if( ts.isWaitingForResume() ) + { + Evaluator e = new Evaluator(this,ts,frame,text,filename,lineno); + return new ExecResultRhino( e.eval() ); + } + else + { + return new ExecResultRhino( + _controller.executeScriptInStackFrame( + ((JSStackFrameInfoRhino)frame).getWrappedInfo(), + text, + filename, + lineno) ); + } + } + + public ExecResult executeScriptInStackFrameValue( JSStackFrameInfo frame, + String text, + String filename, + int lineno ) + throws ForbiddenTargetException + { + return null; // XXX implement this... + } + + public JSErrorReporter setErrorReporter(JSErrorReporter h) + throws ForbiddenTargetException + { + JSErrorReporterRhino newWrapper = null; + if( null != h ) + newWrapper = new JSErrorReporterRhino(h); + + com.netscape.javascript.debug.IErrorReporter oldWrapper = + _controller.setErrorReporter(newWrapper); + + if( null != oldWrapper && oldWrapper instanceof JSErrorReporterRhino) + return ((JSErrorReporterRhino)oldWrapper).getWrappedHook(); + return null; + } + + public JSErrorReporter getErrorReporter() + throws ForbiddenTargetException + { + com.netscape.javascript.debug.IErrorReporter oldWrapper = + _controller.getErrorReporter(); + + if( null != oldWrapper && oldWrapper instanceof JSErrorReporterRhino) + return ((JSErrorReporterRhino)oldWrapper).getWrappedHook(); + return null; + } + + public void iterateScripts(ScriptHook h) + { + // XXX does nothing at present... + } + + public int getMajorVersion() + { + return _controller.getMajorVersion(); + } + public int getMinorVersion() + { + return _controller.getMinorVersion(); + } + + public com.netscape.javascript.debug.IDebugManager getWrappedController() + { + return _controller; + } + + // data... + + private static com.netscape.javascript.debug.IDebugManager _controller = null; + + private static DebugControllerRhino _controllerRhino = null; +} + +class Evaluator implements Callback +{ + public Evaluator(DebugControllerRhino dc, + JSThreadStateRhino ts, + JSStackFrameInfo frame, + String text, + String filename, + int lineno) + { + _dc = dc ; + _ts = ts ; + _frame = frame ; + _text = text ; + _filename = filename; + _lineno = lineno ; + _completed = false; + _result = null; + } + + public String eval() + { + if( ! _completed && _ts.addCallbackEvent(this) ) + { + synchronized(this) + { + while( ! _completed ) + { + try + { + wait(); + } + catch(Exception e) + { + // eat it... + e.printStackTrace(); + System.out.println(e); + break; + } + } + } + } + return _result; + } + + // implement Callback + public synchronized void call() + { + try + { + PrivilegeManager.enablePrivilege("Debugger"); + _result = + _dc.getWrappedController().executeScriptInStackFrame( + ((JSStackFrameInfoRhino)_frame).getWrappedInfo(), + _text, + _filename, + _lineno); + } + catch(Exception e) + { + // eat it... + e.printStackTrace(); + System.out.println(e); + } + _completed = true; + notify(); + } + + private DebugControllerRhino _dc; + private JSThreadStateRhino _ts; + private JSStackFrameInfo _frame; + private String _text; + private String _filename; + private int _lineno; + private boolean _completed; + private String _result; +} + + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ExecResultRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ExecResultRhino.java new file mode 100644 index 00000000000..163978f7319 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ExecResultRhino.java @@ -0,0 +1,43 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +public class ExecResultRhino + implements com.netscape.jsdebugging.api.ExecResult +{ + ExecResultRhino( String str ) + { + _str = str; + } + + public String getResult() {return _str;} + public boolean getErrorOccured() {return false;} + public String getErrorMessage() {return null;} + public String getErrorFilename() {return null;} + public int getErrorLineNumber() {return 0;} + public String getErrorLineBuffer() {return null;} + public int getErrorTokenOffset() {return 0;} + + public com.netscape.jsdebugging.api.Value getResultValue() + {return null;} // XXX implement this + + private String _str; +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/InstructionHookRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/InstructionHookRhino.java new file mode 100644 index 00000000000..ae6a344362f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/InstructionHookRhino.java @@ -0,0 +1,47 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +/** + * InstructionHook must be subinterfaceed to respond to hooks + * at a particular program instruction. + */ +public class InstructionHookRhino implements com.netscape.javascript.debug.IInstructionHook +{ + InstructionHookRhino( InstructionHook hook, + com.netscape.javascript.debug.IPC pc ) + { +// super(pc); + _hook = hook; + } + + public void aboutToExecute(com.netscape.javascript.debug.IThreadState debug) + { + JSThreadStateRhino ts = new JSThreadStateRhino(debug); + ts.aboutToCallHook(); + _hook.aboutToExecute(ts); + ts.returnedFromCallHook(); + } + + public InstructionHook getWrappedHook() {return _hook;} + + private InstructionHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/InterruptHookRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/InterruptHookRhino.java new file mode 100644 index 00000000000..42a04deadad --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/InterruptHookRhino.java @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +/** + * InterruptHook must be subinterfaceed to respond to hooks + * at a particular program instruction. + */ +public class InterruptHookRhino implements com.netscape.javascript.debug.IInterruptHook +{ + public InterruptHookRhino( InterruptHook hook ) + { + _hook = hook; + } + + public void aboutToExecute(com.netscape.javascript.debug.IThreadState debug, + com.netscape.javascript.debug.IPC pc) + { +// System.out.println( "InterruptHookRhino called..." ); + try + { + JSThreadStateRhino ts = new JSThreadStateRhino(debug); + JSPCRhino jspc = (JSPCRhino) ts.getCurrentFrame().getPC(); + ts.aboutToCallHook(); + _hook.aboutToExecute(ts, jspc); + ts.returnedFromCallHook(); + } + catch( Exception e ) + { + e.printStackTrace(); + // eat it. + } + } + + public InterruptHook getWrappedHook() {return _hook;} + + private InterruptHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSErrorReporterRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSErrorReporterRhino.java new file mode 100644 index 00000000000..e487dcbd697 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSErrorReporterRhino.java @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +public class JSErrorReporterRhino implements com.netscape.javascript.debug.IErrorReporter +{ + public JSErrorReporterRhino(JSErrorReporter er) + { + _er = er; + } + + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + return _er.reportError(msg, filename, lineno, linebuf, tokenOffset); + } + + public JSErrorReporter getWrappedHook() {return _er;} + + private JSErrorReporter _er; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSPCRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSPCRhino.java new file mode 100644 index 00000000000..10f3747289b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSPCRhino.java @@ -0,0 +1,68 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +/** + * This subinterface of PC provides JavaScript-specific information. + */ +public class JSPCRhino implements JSPC +{ + public JSPCRhino(com.netscape.javascript.debug.IPC pc) + { + this( pc, new ScriptRhino(pc.getScript()) ); + } + + public JSPCRhino(com.netscape.javascript.debug.IPC pc, ScriptRhino script) + { + _pc = pc; + _script = script; + _sourceLocation = + new JSSourceLocationRhino(this, + (com.netscape.javascript.debug.ISourceLocation)_pc.getSourceLocation()); + } + + public Script getScript() {return _script;} + public int getPC() {return _pc.getPC();} + public boolean isValid() {return _pc.isValid();} + public SourceLocation getSourceLocation() {return _sourceLocation;} + + public boolean equals(Object obj) + { + try + { + JSPCRhino other = (JSPCRhino) obj; + return other._pc.getScript() == _pc.getScript() && + other._pc.getPC() == _pc.getPC(); + } + catch( ClassCastException e ) + { + return false; + } + } + public int hashCode() {return _pc.hashCode();} + public String toString() {return _pc.toString();} + + public com.netscape.javascript.debug.IPC getWrappedJSPC() {return _pc;} + + private com.netscape.javascript.debug.IPC _pc; + private ScriptRhino _script; + private JSSourceLocationRhino _sourceLocation; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSSourceLocationRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSSourceLocationRhino.java new file mode 100644 index 00000000000..e8386266ba4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSSourceLocationRhino.java @@ -0,0 +1,53 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +public class JSSourceLocationRhino implements JSSourceLocation +{ + public JSSourceLocationRhino( JSPCRhino pc, + com.netscape.javascript.debug.ISourceLocation sl ) + { + _pc = pc; + _sl = sl; + } + public int getLine() {return _sl.getLine();} + public String getURL() {return _sl.getURL();} + public PC getPC() {return _pc;} + public String toString() {return _sl.toString();} + + public boolean equals(Object obj) + { + try + { + JSSourceLocationRhino other = (JSSourceLocationRhino) obj; + return getLine() == other.getLine() && + getURL().equals(other.getURL()); + } + catch( ClassCastException e ) + { + return false; + } + } + public int hashCode() {return getURL().hashCode() + 17*getLine();} + + private JSPCRhino _pc; + private com.netscape.javascript.debug.ISourceLocation _sl; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSStackFrameInfoRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSStackFrameInfoRhino.java new file mode 100644 index 00000000000..a25b5e4d350 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSStackFrameInfoRhino.java @@ -0,0 +1,83 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +/** + * This interface provides access to the execution stack of a thread. + * It has several subinterfacees to distinguish between different kinds of + * stack frames: these currently include activations of Java methods + * or JavaScript functions. + * It is possible that synchronize blocks and try blocks deserve their own + * stack frames - to allow for later extensions a debugger should skip over + * stack frames it doesn't understand. + * Note that this appears very Java-specific. However, multiple threads and + * exceptions are relevant to JavaScript as well because of its + * interoperation with Java. + */ +public class JSStackFrameInfoRhino implements JSStackFrameInfo +{ + public JSStackFrameInfoRhino( com.netscape.javascript.debug.IStackFrame info, + JSThreadStateRhino ts ) + { + _info = info; + _ts = ts; +// try +// { + _pc = new JSPCRhino((com.netscape.javascript.debug.IPC)_info.getPC()); +// } +// catch( com.netscape.javascript.debug.InvalidInfoException e ) +// { +// _pc = null; +// } + + } + + public boolean isValid() {return _info.isValid();} + public ThreadStateBase getThreadState() {return _ts;} + public PC getPC() throws InvalidInfoException + { + if( null == _pc ) + throw new InvalidInfoException(); + return _pc; + } + + public Value getCallObject() throws InvalidInfoException + { + throw new InvalidInfoException("not implemented"); + } + + public Value getScopeChain() throws InvalidInfoException + { + throw new InvalidInfoException("not implemented"); + } + + public Value getThis() throws InvalidInfoException + { + throw new InvalidInfoException("not implemented"); + } + + public com.netscape.javascript.debug.IStackFrame getWrappedInfo() {return _info;} + + private com.netscape.javascript.debug.IStackFrame _info; + private JSThreadStateRhino _ts; + private JSPCRhino _pc; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSThreadStateRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSThreadStateRhino.java new file mode 100644 index 00000000000..d1dedd83a27 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/JSThreadStateRhino.java @@ -0,0 +1,244 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +public class JSThreadStateRhino implements JSThreadState +{ + public JSThreadStateRhino( com.netscape.javascript.debug.IThreadState ts ) + { + _ts = ts; +// try +// { + com.netscape.javascript.debug.IStackFrame[] stack = _ts.getStack(); + + if( null != stack && 0 != stack.length ) + { + _stack = new JSStackFrameInfoRhino[stack.length]; + for( int i = 0; i < stack.length; i++ ) + _stack[i] = new JSStackFrameInfoRhino( + (com.netscape.javascript.debug.IStackFrame)stack[i], + this); + } +// } +// catch( com.netscape.javascript.debug.InvalidInfoException e ) +// { +// _stack = null; +// } + } + + public boolean isValid() {return null != _stack && _ts.isValid();} + public int getStatus() {return THR_STATUS_UNKNOWN;} + + public int countStackFrames() + throws InvalidInfoException + { + if( null == _stack ) + throw new InvalidInfoException(); + return _stack.length; + } + + public StackFrameInfo getCurrentFrame() + throws InvalidInfoException + { + if( null == _stack ) + throw new InvalidInfoException(); + return _stack[_stack.length-1]; + } + + /** + * Get the thread's stack as an array. stack[stack.length-1] is the + * current frame, and stack[0] is the beginning of the stack. + */ + public StackFrameInfo[] getStack() + throws InvalidInfoException + { + if( null == _stack ) + throw new InvalidInfoException(); + return _stack; + } + + /** + * Return true if the thread is currently running a hook + * for this ThreadState + */ + public boolean isRunningHook() + { + return _runningHook; + } + + /** + * Return true if the hook on this thread has already completed + * and we are waiting for a call to resume() + */ + public boolean isWaitingForResume() + { + return _runningEventQueue; + } + + + /** + * Leave the thread in a suspended state when the hook method(s) + * finish. This can be undone by calling resume(). + */ + public synchronized void leaveSuspended() + { + if( _runningHook && ! _runningEventQueue ) + _leaveSuspended = true; + } + + /** + * Resume the thread. + * Two cases: + * 1) Hook is still running, this will undo the leaveSuspended + * and the thread will still be waiting for the hook to + * return. + * 2) Hook has already returned and we are in an event loop + * waiting to contine the suspended thread, this will + * force completion of events pending on the suspended + * thread and resume it. + */ + public synchronized void resume() + { + if( ! _runningHook ) + return; + + _leaveSuspended = false; + + // signal stopped thread + if( _runningEventQueue ) + notifyAll(); + } + + /** + * This gets the current continue state of the debug frame, which + * will be one of the DEBUG_STATE_* values above. + */ + public int getContinueState() {return _ts.getContinueState();} + + public int setContinueState(int state) + { + // XXX this is a hack to deal with the fact that the current debugger + // uses 'DEBUG_STATE_THROW' to mean 'abort' - i.e. return null. + // So, we remap it. + switch(state) + { + default: + case DEBUG_STATE_DEAD: + case DEBUG_STATE_RUN: + case DEBUG_STATE_RETURN: + break; + case DEBUG_STATE_THROW: + state = DEBUG_STATE_RETURN; + _ts.setReturnValue(null); + break; + } + return _ts.setContinueState(state); + } + + public synchronized void aboutToCallHook() + { + _runningHook = true; + + } + public synchronized void returnedFromCallHook() + { + if(_leaveSuspended) + { + _runningEventQueue = true; + while( _leaveSuspended ) + { + try + { + wait(); + } + catch(Exception e) + { + e.printStackTrace(); + System.out.println(e); + _leaveSuspended = false; + } + processAllEvents(); + } + _runningEventQueue = false; + } + _runningHook = false; + } + + public synchronized boolean addCallbackEvent(Callback cb) + { + if( _runningEventQueue ) + { + addEvent(cb); + notify(); + return true; + } + return false; + } + + private synchronized void addEvent(Callback cb) + { + Event e = new Event(); + e.cb = cb; + if( null != _lastEvent ) + _lastEvent.next = e; + _lastEvent = e; + if( null == _firstEvent ) + _firstEvent = e; + } + + private synchronized Event getEvent() + { + Event e = _firstEvent; + if( null != e ) + { + _firstEvent = e.next; + if( _lastEvent == e ) + _lastEvent = null; + e.next = null; + } + return e; + } + + private synchronized void processAllEvents() + { + Event e; + while( null != (e = getEvent()) ) + { + if( null != e.cb ) + e.cb.call(); + } + } + + private com.netscape.javascript.debug.IThreadState _ts; + private JSStackFrameInfoRhino[] _stack; + private boolean _runningHook = false; + private boolean _leaveSuspended = false; + private boolean _runningEventQueue = false; + private Event _firstEvent = null; + private Event _lastEvent = null; +} + + +class Event +{ + public Event next = null; + public Callback cb = null; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/README b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/README new file mode 100644 index 00000000000..ed751817174 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/README @@ -0,0 +1,5 @@ +/* jband - 09/14/98 - */ + +com.netscape.jsdebugging.api.rhino implements the interfaces defined in +com.netscape.jsdebugging.api. It supports adapting the debugger(s) to the +debug api used in in the Netscape's JavaScript in Java (Rhino) engine. diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptHookRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptHookRhino.java new file mode 100644 index 00000000000..aa38b6e1605 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptHookRhino.java @@ -0,0 +1,47 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +/** + * ScriptHook must be subinterfaceed to respond to significant events + * in the virtual machine. + */ +public class ScriptHookRhino implements com.netscape.javascript.debug.IScriptHook +{ + public ScriptHookRhino( ScriptHook hook ) + { + _hook = hook; + } + + public void justLoadedScript(com.netscape.javascript.debug.IScript script) + { + _hook.justLoadedScript( new ScriptRhino(script) ); + } + + public void aboutToUnloadScript(com.netscape.javascript.debug.IScript script) + { + _hook.aboutToUnloadScript( new ScriptRhino(script) ); + } + + public ScriptHook getWrappedHook() {return _hook;} + + private ScriptHook _hook; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptRhino.java new file mode 100644 index 00000000000..c4d456770e8 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptRhino.java @@ -0,0 +1,69 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; +//import netscape.palomar.util.ER; + +public class ScriptRhino implements Script +{ + ScriptRhino(com.netscape.javascript.debug.IScript script) + { +// if(ASS)ER.T(null != script,"script was null",this); + _script = script; + _sections = new ScriptSectionRhino[1]; + _sections[0] = new ScriptSectionRhino(_script.getBaseLineNumber(), + _script.getLineExtent()); + } + + public String getURL() {return _script.getURL();} + public String getFunction() {return _script.getFunction();} + public int getBaseLineNumber() {return _script.getBaseLineNumber();} + public int getLineExtent() {return _script.getLineExtent();} + public boolean isValid() {return _script.isValid();} + public JSPC getClosestPC(int line) + { + com.netscape.javascript.debug.IPC pc = _script.getClosestPC(line); + if(null == pc) + return null; + return new JSPCRhino(pc, this); + } + + public ScriptSection[] getSections() {return _sections;} + + public String toString() {return _script.toString();} + public int hashCode() {return _script.hashCode();} + public boolean equals(Object obj) + { + try + { + return ((ScriptRhino)obj)._script == _script; + } + catch( ClassCastException e ) + { + return false; + } + } + + public com.netscape.javascript.debug.IScript getRealScript() {return _script;} + + private ScriptSectionRhino[] _sections; + private com.netscape.javascript.debug.IScript _script; +// private static final boolean ASS = true; // enable ASSERT support? +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptSectionRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptSectionRhino.java new file mode 100644 index 00000000000..d5926d14965 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/ScriptSectionRhino.java @@ -0,0 +1,37 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +public class ScriptSectionRhino implements ScriptSection +{ + public ScriptSectionRhino( int base, int extent ) + { + _base = base; + _extent = extent; + } + + public int getBaseLineNumber() {return _base;} + public int getLineExtent() {return _extent;} + + private int _base; + private int _extent; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/SourceTextItemRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/SourceTextItemRhino.java new file mode 100644 index 00000000000..f4eb3b95e18 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/SourceTextItemRhino.java @@ -0,0 +1,79 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; + +public class SourceTextItemRhino + implements SourceTextItem +{ + public SourceTextItemRhino(com.netscape.javascript.SourceTextItem sti) + { + _sti = sti; + // + // XXX Hack to deal with the fact that JSScript 'filenames' for + // urls containing query parts are truncated at '?', while sources + // contain the full URL. (do the same for '#') + + int index; + String url = _sti.getName(); + if( -1 != (index = url.indexOf('?')) || + -1 != (index = url.indexOf('#')) ) + _url = url.substring(0,index); + else + _url = url; + } + + // implements SourceTextItem + public String getURL() {return _url;} + public String getText() {return _sti.getText();} + public int getStatus() {return _sti.getStatus();} + public int getAlterCount() {return _sti.getAlterCount();} + + public boolean getDirty() {return _lastAlterCount < getAlterCount();} + public void setDirty(boolean b) + { + if(b) + _lastAlterCount-- ; + else + _lastAlterCount = getAlterCount(); + } + + public int hashCode() {return _sti.getName().hashCode();} + public boolean equals(Object obj) + { + try + { + return ((SourceTextItemRhino)obj)._sti == _sti; + } + catch( ClassCastException e ) + { + return false; + } + } + + com.netscape.javascript.SourceTextItem getWrappedItem() {return _sti;} + void setWrappedItem(com.netscape.javascript.SourceTextItem sti) {_sti = sti;} + + // data + + private String _url; + private com.netscape.javascript.SourceTextItem _sti = null; + private int _lastAlterCount = 0; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/SourceTextProviderRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/SourceTextProviderRhino.java new file mode 100644 index 00000000000..f57e9892f36 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/api/rhino/SourceTextProviderRhino.java @@ -0,0 +1,147 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.api.rhino; + +import com.netscape.jsdebugging.api.*; +import netscape.util.Vector; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; +import java.util.Enumeration; + +public class SourceTextProviderRhino + implements SourceTextProvider +{ + public static boolean setGlobalSourceTextManager(com.netscape.javascript.SourceTextManager manager) + { + if(null != _pro) + return false; + _pro = manager; + return true; + } + + // allow for possible singleton-ness enforcement + public static SourceTextProvider getSourceTextProvider() + { + return new SourceTextProviderRhino(); + } + + private SourceTextProviderRhino() + { + } + + // implement netscape.jsdebugger.SourceTextProvider + + public SourceTextItem[] getItems() + { + if( null == _pro ) + return null; + + if( null == _items ) + _rebuildItemsArray(); + return _items; + } + public void refreshAll() + { + if( null == _pro ) + return; +// _pro.refreshSourceTextVector(); + _rebuildItemsArray(); + } + public SourceTextItem findItem(String url) + { + if( null == _pro ) + return null; + if( null == _items ) + _rebuildItemsArray(); + + if( null == _items ) + return null; + + for( int i = 0; i < _items.length; i++ ) + { + if( url.equals(_items[i].getURL()) ) + return _items[i]; + } + return null; + } + public SourceTextItem loadItem(String url) + { + // XXX not implemented... + return null; + } + + // this goes through some gyrations to try to reuse existing item wrappers + private void _rebuildItemsArray() + { + SourceTextItemRhino[] olditems = _items; + _items = null; + + if( null == _pro ) + return; + try + { + int count; + PrivilegeManager.enablePrivilege("Debugger"); + + // XXX this is ugly, but for now we build a Vecter from the + // Enumeration so that we can reuse the old code below + Vector v = new Vector(); + Enumeration e = _pro.getAllItems(); + + while(e.hasMoreElements()) + v.addElement(e.nextElement()); + + if( null == v || 0 == (count = v.size()) ) + return; + SourceTextItemRhino[] newitems = new SourceTextItemRhino[count]; + next_item: for( int i = 0; i < count; i++ ) + { + com.netscape.javascript.SourceTextItem rawItem = + (com.netscape.javascript.SourceTextItem) v.elementAt(i); + if( null != olditems && 0 != olditems.length ) + { + + for( int k = 0; k < olditems.length; k++ ) + { + SourceTextItemRhino item = olditems[k]; + if( item.getWrappedItem().equals(rawItem) ) + { + if( item.getWrappedItem() != rawItem ) + item.setWrappedItem(rawItem); + newitems[i] = item; + continue next_item; + } + } + } + newitems[i] = new SourceTextItemRhino(rawItem); + } + _items = newitems; + } + catch( ForbiddenTargetException e ) + { + // eat it; + } + } + + + // data + + private static com.netscape.javascript.SourceTextManager _pro = null; + private SourceTextItemRhino[] _items = null; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Analyzer.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Analyzer.java new file mode 100644 index 00000000000..9ac0e20dc2d --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Analyzer.java @@ -0,0 +1,166 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + package com.netscape.jsdebugging.apitests; + + import java.io.*; + import java.util.*; + import com.netscape.jsdebugging.apitests.xml.*; + import com.netscape.jsdebugging.apitests.analyzing.data.*; + import com.netscape.jsdebugging.apitests.analyzing.tree.*; + import com.netscape.jsdebugging.apitests.analyzing.analyzers.*; + +/** + * Analyzes two log files by building and processing trees. + * + * @author Alex Rakhlin + */ + + public class Analyzer { + + public static void main(String args[]){ + + Tags.init(); + if (!_processArguments (args)) return; + + try { + System.setErr (new PrintStream (new FileOutputStream ("error_analyzer.log"))); + } catch (IOException e) { System.out.println ("Error redirecting error stream"); } + try { + System.setOut (new PrintStream (new FileOutputStream ("output_analyzer.log"))); + } catch (IOException e) { System.out.println ("Error redirecting error stream"); } + + HTMLWriter.setBaseDirectory (_base_dir); + + _htmlw = new HTMLWriter (_outfilename); + check_for_error_log (_htmlw, "error_main_RHINO.log"); + check_for_error_log (_htmlw, "error_main_SPIDER_MONKEY.log"); + + Date start = new Date(); + analyze (); + Date finish = new Date(); + + _htmlw.oneCellTablePRE ("ANALYZER \nSTARTED: "+start+"\nENDED: "+finish, "", "yellow", "blue"); + + check_for_error_log (_htmlw, "error_analyzer.log"); + _htmlw.close(); + + } + + private static boolean _processArguments (String args[]){ + if (args.length < 6) { + usage(); + return false; + } + for (int i=0; i < args.length; i++) { + String arg = args[i]; + if (arg.equals("-f1")) _filename1 = args [i+1]; + if (arg.equals("-f2")) _filename2 = args [i+1]; + if (arg.equals("-out")) _outfilename = args [i+1]; + if (arg.equals("-outdir")) _base_dir = args [i+1]; + } + return true; + } + + + public static void analyze (){ + /* parse first file */ + _parser = new XMLParser (); + _parser.parse (_filename1); + _head1 = _parser.getTree (); + /* parse second file */ + _parser = new XMLParser (); + _parser.parse (_filename2); + _head2 = _parser.getTree (); + /* get descriptions */ + _dpm1 = new DataPoolManager(); + _dpm1.getDataFromTree (_head1); + /* get descriptions */ + _dpm2 = new DataPoolManager(); + _dpm2.getDataFromTree (_head2); + /* get test information */ + DTestInfo dtinf1 = new DTestInfo (TreeUtils.searchDepthFirst (_head1, Tags.doc_tag), _dpm1); + DTestInfo dtinf2 = new DTestInfo (TreeUtils.searchDepthFirst (_head2, Tags.doc_tag), _dpm2); + /* set test information field of the DataPoolManager */ + _dpm1.setTestInfo (dtinf1); + _dpm2.setTestInfo (dtinf2); + + _htmlw.oneCellTablePRE (dtinf1.toString(), "", "yellow", "black"); + _htmlw.oneCellTablePRE (dtinf2.toString(), "", "yellow", "black"); + + /* remove duplicate descriptions and redirect tree pointers to new data */ + _dpm1.removeDuplicatesAndFixTree (_head1); + _dpm2.removeDuplicatesAndFixTree (_head2); + + /* intersect two pool managers */ + DataPoolManager _intersect = DataPoolManager.intersectPools (_dpm1, _dpm2); + + + /* NEED TO DO THIS BEFORE OTHER TESTS: create html files from .js with anchors */ + AnalyzeScriptPools.makeHTMLFilesFromScripts (_dpm1.getPool (Tags.script_tag)); + AnalyzeScriptPools.makeHTMLFilesFromScripts (_dpm2.getPool (Tags.script_tag)); + AnalyzeScriptPools.makeHTMLFilesFromScripts (_intersect.getPool (Tags.script_tag)); + + AnalyzeScriptPools ascr = new AnalyzeScriptPools (_htmlw, _dpm1, _dpm2, _intersect); + ascr.analyze(); + + AnalyzeSourceLocations asl = new AnalyzeSourceLocations (_htmlw, _dpm1, _dpm2, _intersect); + asl.analyze(); + + // !!!!! check if actually doing interrupt test !!! + // better do interrupt test after analyzing pc's, evals, errors + AnalyzeInterrupts ai = new AnalyzeInterrupts (_htmlw, _head1, _head2, _dpm1, _dpm2); + ai.analyze (); + + AnalyzeEvals ae = new AnalyzeEvals (_htmlw, _dpm1, _dpm2, _intersect); + ae.analyze (); + + AnalyzeErrorReports aerr = new AnalyzeErrorReports (_htmlw, _dpm1, _dpm2, _intersect); + aerr.analyze (); + } + + public static void check_for_error_log (HTMLWriter htmlw, String filename){ + try { + BufferedInputStream f = new BufferedInputStream (new FileInputStream (filename)); + int b = f.read (); + if (b != -1) htmlw.oneCellTablePRE ("Error log: "+filename, filename, "red", "white"); + } + catch (FileNotFoundException e) {} + catch (IOException ee) {} + } + + public static void usage () { + System.out.println ("Usage: Analyzer -f1 [filename1] -f2 [filename2] -out [filename_out] -outdir [dir]"); + System.out.println (" -f1 = first log to analyze "); + System.out.println (" -f2 = second log to analyze "); + System.out.println (" -out = output html file "); + System.out.println (" -outdir = base directory for the output "); + } + + private static XMLParser _parser; + private static String _filename1; + private static String _filename2; + private static String _outfilename; + private static String _base_dir; + private static HTMLWriter _htmlw; + + private static TreeNode _head1; + private static TreeNode _head2; + private static DataPoolManager _dpm1; + private static DataPoolManager _dpm2; + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Harness.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Harness.java new file mode 100644 index 00000000000..c9e5f77b2e4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Harness.java @@ -0,0 +1,127 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests; + +import com.netscape.jsdebugging.apitests.xml.*; +import java.io.*; +import java.util.*; +import java.lang.*; + +/** + * Runs tests and analyzer. + * + * @author Alex Rakhlin + */ + +public class Harness { + + public static String start_vm = "cmd /c jre -mx10000000000 -nojit -cp c:/src/ns/js/rhino/;c:/src/ns/js/jsdj/dist/classes/;c:/src/ns/js/jsdj/dist/classes/ifc11.jar;c:/src/ns/js/jsdj/classes/;c:/src/ns/js/jsdj/dist/bin/Debug/;%CLASSPATH% "; + + public static void main(String args[]) { + + Tags.init(); + + _processArguments (args); + + String whichTests = "com.netscape.jsdebugging.apitests.testing.tests.TestScriptLoading "+ + "com.netscape.jsdebugging.apitests.testing.tests.TestStepping "+ + "com.netscape.jsdebugging.apitests.testing.tests.TestEvalInStackFrame "+ + "com.netscape.jsdebugging.apitests.testing.tests.TestErrorReporter "; + + runTest ("out_local.xml", whichTests, "local", _filenames, "temp_local.xml"); + runTest ("out_rhino.xml", whichTests, "rhino", _filenames, "temp_rhino.xml"); + + Date d = new Date (); + String output_dir = d.getMonth()+"."+d.getDay()+"."+d.getYear()+"_"+d.getHours()+"."+d.getMinutes(); + runAnalyzer ("out_local.xml", "out_rhino.xml", "index.html", output_dir); + } + + public static void runAnalyzer (String file1, String file2, String output, String base_dir){ + new File (base_dir).mkdir(); + String command = start_vm+"com.netscape.jsdebugging.apitests.Analyzer "; + String arguments = " -f1 "+file1+" -f2 "+file2+" -out "+output+" -outdir "+base_dir; + runProgram (command + arguments); + } + + public static void runTest (String fileout, String whichTests, String engine, String jsfiles, String tempfile){ + String time_stamp = new Date().toString(); + String command = start_vm+"com.netscape.jsdebugging.apitests.Main "; + String arguments = " -f "+jsfiles+" -o "+tempfile+" -t "+whichTests+" -e "+engine; + runProgram (command + arguments); + + _makeXMLDocument (tempfile, fileout, time_stamp); + } + + /** + * run a program and wait for it to finish execution. + */ + public static void runProgram (String command){ + try { + Runtime rm = java.lang.Runtime.getRuntime(); + Process p = rm.exec (command); + p.waitFor (); + } + catch (IOException e) { System.out.println ("ERROR EXECUTING PROGRAM "+e.getMessage()); } + catch (InterruptedException e){ System.out.println ("Interrupted exception"); } + } + + private static void _makeXMLDocument (String filein, String fileout, String time_stamp){ + _xmlw = new XMLWriter (fileout, 0); + /* write header */ + _xmlw.prDTDInit(); + _xmlw.startTag (Tags.doc_tag); + _xmlw.startTag (Tags.header_tag); + _xmlw.tag (Tags.date_start_tag, time_stamp); + _xmlw.tag (Tags.date_finish_tag, (new Date()).toString()); + _xmlw.tag (Tags.version_tag, "1.0"); + _xmlw.endTag (Tags.header_tag); + _xmlw.startTag (Tags.main_tag); + /* end write header */ + // copy stuff from the generated temp file + try { + DataInputStream d = new DataInputStream (new FileInputStream (filein)); + byte[] bytes = new byte[d.available()]; + d.readFully (bytes); + _xmlw.write (new String (bytes)); + } catch (FileNotFoundException e) { System.out.println ("File not found"); } + catch (IOException e) { System.out.println ("oops"); } + /* write footer */ + _xmlw.endTag (Tags.main_tag); + _xmlw.endTag(Tags.doc_tag); + _xmlw.close(); + /* end write footer */ + } + + + private static void _processArguments (String args[]){ + _filenames = ""; + for (int i=0; i < args.length; i++) { + String arg = args[i]; + if (arg.equals("-f")) { + for (int j=i+1; j < args.length; j++) + if (!args[j].startsWith ("-")) _filenames=_filenames+args[j]+" "; + else break; + } + } + } + + + private static XMLWriter _xmlw = null; + private static String _filenames; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Main.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Main.java new file mode 100644 index 00000000000..75051de68de --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/Main.java @@ -0,0 +1,202 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests; + +import java.io.*; +import java.util.*; +import com.netscape.jsdebugging.engine.*; +import com.netscape.jsdebugging.api.*; +import com.netscape.jsdebugging.apitests.xml.*; +import com.netscape.jsdebugging.apitests.testing.*; + +/** + * This class runs a set of tests on the given engine. + * + * @author Alex Rakhlin + */ + +public class Main { + + public static final String LOCAL_CREATOR_NAME = + "com.netscape.jsdebugging.engine.local.RuntimeCreatorLocal"; + public static final String RHINO_CREATOR_NAME = + "com.netscape.jsdebugging.engine.rhino.RuntimeCreatorRhino"; + + + public static void main(String args[]) { + new Main(args); + } + + private Main (String args[]) { + + Tags.init(); + _processArguments (args); + + _engine_name = ""; + if (_creatorName.equals (LOCAL_CREATOR_NAME)) _engine_name = "SPIDER_MONKEY"; + if (_creatorName.equals (RHINO_CREATOR_NAME)) _engine_name = "RHINO"; + try { + System.setErr (new PrintStream (new FileOutputStream ("error_main_"+_engine_name+".log"))); + } catch (IOException e) { System.out.println ("Error redirecting error stream"); } + + try { + System.setOut (new PrintStream (new FileOutputStream ("output_main_"+_engine_name+".log"))); + } catch (IOException e) { System.out.println ("Error redirecting error stream"); } + + + if ( null == _xmlw ){ + System.out.println ("FAILED to Init Output"); + return; + } + + try { + Class clazz = Class.forName(_creatorName); + IRuntimeCreator creator = (IRuntimeCreator) clazz.newInstance(); + _runtime = creator.newRuntime(IRuntimeCreator.ENABLE_DEBUGGING, null); + _context = _runtime.newContext(null); + _controller = _runtime.getDebugController(); + _sourceTextProvider = _runtime.getSourceTextProvider(); + LocalSink sink = new LocalSink(); + _context.setPrintSink(sink); + _context.setErrorSink(sink); + + if( null == _controller ) + { + System.out.println ("FAILED to Init DebugController"); + return; + } + + _xmlw.startTag ("TESTS"); + _tests = new TestSuite (_xmlw, _controller); + for (int i = 0; i < _test_names.size(); i++){ + Test t = null; + try { + t = (Test) java.lang.Class.forName ((String)_test_names.elementAt(i)).newInstance(); + } + catch (ClassNotFoundException e) { System.err.println ("CLASS "+(String)_test_names.elementAt(i)+" not found");} + _xmlw.tag ("TEST", (String)_test_names.elementAt(i)); + t.setXMLWriter (_xmlw); + _tests.addTest (t); + } + _xmlw.endTag ("TESTS"); + _xmlw.startTag ("SCRIPT_FILES"); + for (int i = 0; i < _filenames.size(); i++){ + _xmlw.tag ("FILE", (String) _filenames.elementAt (i)); + } + _xmlw.endTag ("SCRIPT_FILES"); + _controller.setScriptHook (new MyScriptHook (_tests)); + _controller.setInterruptHook(new MyInterruptHook(_tests)); + _controller.setErrorReporter(new MyErrorReporter(_tests)); + _controller.sendInterrupt(); + + } + catch(Throwable t) + { + System.err.println("execption thrown " + t ); + } + + _xmlw.tag ("ENGINE", _engine_name); + + //-------------------- LOOP ----------------- + for (int i = 0; i < _filenames.size(); i++){ + _context.loadFile((String) _filenames.elementAt (i)); + } + //--------------------- END ----------------- + + _xmlw.close(); + /* + try { + DataInputStream d = new DataInputStream (System.in); + d.readLine(); + } + catch (IOException e) {} + */ + } + + + public String getClassName() { + return "global"; + } + + + private void _processArguments (String args[]){ + _filenames = new Vector(); + _test_names = new Vector(); + _creatorName = null; + + /* Process command line arguments + */ + for (int i=0; i < args.length; i++) { + String arg = args[i]; + + if (arg.equals("-f")) { + for (int j=i+1; j < args.length; j++) + if (!args[j].startsWith ("-")) _filenames.addElement(args[j]); + else break; + } + if (arg.equals("-o")){ + _xmlw = new XMLWriter (args[i+1], 2); //second arg is the starting indent + } + if (arg.equals("-t")){ + for (int j=i+1; j < args.length; j++) + if (!args[j].startsWith ("-")) _test_names.addElement(args[j]); + else break; + } + if (arg.equals ("-e")){ + if (args[i+1].equalsIgnoreCase ("Rhino")) _creatorName = RHINO_CREATOR_NAME; + if (args[i+1].equalsIgnoreCase ("Local")) _creatorName = LOCAL_CREATOR_NAME; + } + } + } + + public DebugController getController() {return _controller;} + public SourceTextProvider getSourceTextProvider() {return _sourceTextProvider;} + + private DebugController _controller; + private IRuntime _runtime; + private IContext _context; + private SourceTextProvider _sourceTextProvider; + + private Vector _filenames; + private XMLWriter _xmlw; + private TestSuite _tests; + private Vector _test_names; + private String _creatorName;; + private String _engine_name; +} + +class LocalSink implements IPrintSink, IErrorSink +{ + public void print(String s) { + System.out.print(s); + } + public void error(String msg, String filename, int lineno, + String lineBuf, int offset) + { + System.out.println(""); + System.out.println("-------------------------------------"); + System.out.println(msg); + System.out.println(filename); + System.out.println(lineno); + System.out.println(lineBuf); + System.out.println(offset); + System.out.println("-------------------------------------"); + System.out.println(""); + } +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/README b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/README new file mode 100644 index 00000000000..1a13ab9c711 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/README @@ -0,0 +1,5 @@ +/* jband - 09/14/98 - */ + +com.netscape.jsdebugging.apitests is a debugger api testing system which is +based on the strategy of comparing the behavior of the C engine to that of the +Java engine and detecting unexpected differences. \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeErrorReports.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeErrorReports.java new file mode 100644 index 00000000000..f67c217f3bd --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeErrorReports.java @@ -0,0 +1,44 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + package com.netscape.jsdebugging.apitests.analyzing.analyzers; + + import java.io.*; + import java.util.*; + import com.netscape.jsdebugging.apitests.xml.*; + import com.netscape.jsdebugging.apitests.analyzing.data.*; + +/** + * Analyzes a error data object + * + * @author Alex Rakhlin + */ + + + public class AnalyzeErrorReports extends AnalyzerBase { + + public AnalyzeErrorReports (HTMLWriter h, DataPoolManager dpm1, DataPoolManager dpm2, DataPoolManager common) { + super (h, dpm1, dpm2, common, "ErrorReporter test", "err", Tags.error_tag); + } + + + public boolean check (Data d, DataPoolManager dpm){ + _unknown_htmlw.twoCellTablePRE (d.toFormattedString(), dpm.getTestInfo().getEngine(), "", "", "red", "white"); + return false; + } + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeEvals.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeEvals.java new file mode 100644 index 00000000000..891c839b45b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeEvals.java @@ -0,0 +1,49 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + package com.netscape.jsdebugging.apitests.analyzing.analyzers; + + import java.io.*; + import java.util.*; + import com.netscape.jsdebugging.apitests.xml.*; + import com.netscape.jsdebugging.apitests.analyzing.data.*; + +/** + * Analyzes eval data object + * + * @author Alex Rakhlin + */ + + + public class AnalyzeEvals extends AnalyzerBase { + + public AnalyzeEvals (HTMLWriter h, DataPoolManager dpm1, DataPoolManager dpm2, DataPoolManager common) { + super (h, dpm1, dpm2, common, "Eval test", "eval", Tags.eval_tag); + } + + public boolean check (Data d, DataPoolManager dpm){ + DataSourceLocation sloc = ((DataEval) d).getFrame().getPC().getSourceLocation (); + if (sloc.getIgnore()) { + _known_htmlw.twoCellTablePRE (d.toFormattedString(), dpm.getTestInfo().getEngine(), "", "", "white", "blue"); + return true; + } + + _unknown_htmlw.twoCellTablePRE (d.toFormattedString(), dpm.getTestInfo().getEngine(), "", "", "red", "white"); + return false; + } + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeInterrupts.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeInterrupts.java new file mode 100644 index 00000000000..0f0b5ac0daf --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeInterrupts.java @@ -0,0 +1,393 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + package com.netscape.jsdebugging.apitests.analyzing.analyzers; + + import java.io.*; + import java.util.*; + import com.netscape.jsdebugging.apitests.xml.*; + import com.netscape.jsdebugging.apitests.analyzing.data.*; + import com.netscape.jsdebugging.apitests.analyzing.tree.*; + +/** + * Analyzes interrupts. This requires much more work and doesn't fit AnalyzerBase structure. + * + * @author Alex Rakhlin + */ + + + public class AnalyzeInterrupts { + + + public AnalyzeInterrupts (HTMLWriter h, TreeNode head1, TreeNode head2, DataPoolManager dpm1, DataPoolManager dpm2){ + _pass = true; + + _dtinf1 = dpm1.getTestInfo(); + _dtinf2 = dpm2.getTestInfo(); + + _sloc_pool1 = dpm1.getPool (Tags.source_location_tag); + _sloc_pool2 = dpm2.getPool (Tags.source_location_tag); + + _htmlw_main = h; + + Vector i1 = TreeUtils.findAllTags (head1, Tags.interrupt_tag); + Vector i2 = TreeUtils.findAllTags (head2, Tags.interrupt_tag); + + _dinterrupt_list1 = new Vector (); + _dinterrupt_list2 = new Vector (); + + _unknown_differences = new Vector (); + + for (int i = 0; i < i1.size(); i++) { + DInterrupt d = new DInterrupt ((TreeNode) i1.elementAt (i), dpm1); + d.setTestInfo (dpm1.getTestInfo()); + _dinterrupt_list1.addElement (d); + } + for (int i = 0; i < i2.size(); i++) { + DInterrupt d = new DInterrupt ((TreeNode) i2.elementAt (i), dpm2); + d.setTestInfo (dpm2.getTestInfo()); + _dinterrupt_list2.addElement (d); + } + + } + + public void analyze (){ + + String main_filename = "int_main.html"; + String all_filename = "int_all.html"; + String unknown_filename = "int_unknown.html"; + + HTMLWriter main_htmlw = new HTMLWriter (main_filename); + HTMLWriter all_htmlw = new HTMLWriter (all_filename); + HTMLWriter unknown_htmlw = new HTMLWriter (unknown_filename); + + all_htmlw.twoCellTable ("TESTS ON "+_dtinf1.getEngine(), "TESTS ON "+_dtinf2.getEngine(), "", "", "yellow", "black"); + + if (_remove_invalid && !_output_everything){ + removeInvalid (_dinterrupt_list1, _sloc_pool1); + removeInvalid (_dinterrupt_list2, _sloc_pool2); + } + + if (!_output_everything){ + removeSequences (_dinterrupt_list1); + removeSequences (_dinterrupt_list2); + } + + DataOutputStream d1, d2; + String file1 = "interrupt1.log"; + String file2 = "interrupt2.log"; + String diff = "difference.log"; + try { + d1 = new DataOutputStream (new FileOutputStream (file1)); + d2 = new DataOutputStream (new FileOutputStream (file2)); + + _strings1 = writeOutInterrupts (d1, _dinterrupt_list1, _sloc_pool1); + _strings2 = writeOutInterrupts (d2, _dinterrupt_list2, _sloc_pool2); + + d1.close(); + d2.close(); + + } + catch (IOException e) { System.out.println ("Error initing/writing to files "); } + + _differences = runDiff (file1, file2, diff); + + output_all_interrupts (all_htmlw); + list (unknown_htmlw, _unknown_differences); + + if (!_pass) main_htmlw.oneCellTable ("UNKNOWN DIFFERENCES", unknown_filename, "red", "white"); + main_htmlw.oneCellTable ("ALL INTERRUPTS", all_filename, "white", "black"); + + + main_htmlw.close(); + all_htmlw.close(); + unknown_htmlw.close(); + + _htmlw_main.twoCellTable ("Interrupts test", HTMLWriter.pass_fail (_number_of_known_diffs, _number_of_unknown_diffs), + main_filename, "", "white", "black"); + + } + + + public void outputTableBoth (int start1, int start2, int end1, int end2, String bgcolor, HTMLWriter htmlw){ + htmlw.table (_strings1, _strings2, start1, start2, end1, end2, bgcolor, "black"); + } + + public void outputLeftColumnTable (int start, int end, String bgcolor, HTMLWriter htmlw){ + Vector v = removeKnownDifferences (_strings1, start, end, _dinterrupt_list1, _sloc_pool1); + htmlw.table (v, new Vector(), bgcolor, "black"); + } + + public void outputRightColumnTable (int start, int end, String bgcolor, HTMLWriter htmlw){ + Vector v = removeKnownDifferences (_strings2, start, end, _dinterrupt_list2, _sloc_pool2); + htmlw.table (v, new Vector(), bgcolor, "black"); + } + + public void outputTableBothToNewFile (int start1, int start2, int end1, int end2, String color, HTMLWriter htmlw){ + if (end1 - start1 < 1 && end2 - start2 < 1) return; + _counter ++; + String filename = "common"+_counter+".html"; + htmlw.link ("Common section", filename); + HTMLWriter h = new HTMLWriter (filename); + outputTableBoth (start1, start2, end1, end2, color, h); + h.close(); + } + + public void output_all_interrupts (HTMLWriter htmlw){ + int max; + if (_strings1.size() > _strings2.size()) max = _strings1.size(); + else max = _strings2.size(); + + int index1 = 1, index2 = 1; + + for (int i = 0; i < _differences.size(); i++){ + String diff = (String) _differences.elementAt (i); + int d = diff.indexOf ('d'); + int a = diff.indexOf ('a'); + int c = diff.indexOf ('c'); + int position; + if (d != -1) position = d; + else if (a != -1) position = a; + else if (c != -1) position = c; + else continue; + + String before = new String (diff.substring (0, position)); + String after = new String (diff.substring (position+1)); + int comma1 = before.indexOf (','); + int comma2 = after.indexOf (','); + int from1, to1, from2, to2; + if (comma1 != -1) { + from1 = Integer.valueOf (before.substring (0, comma1)).intValue(); + to1 = Integer.valueOf (before.substring (comma1+1)).intValue(); + } else { + from1 = Integer.valueOf (before).intValue(); + to1 = -1; + } + if (comma2 != -1) { + from2 = Integer.valueOf (after.substring (0, comma2)).intValue(); + to2 = Integer.valueOf (after.substring (comma2+1)).intValue(); + } else { + from2 = Integer.valueOf (after).intValue(); + to2 = -1; + } + int max1 = (int) java.lang.Math.max (from1, to1); + int max2 = (int) java.lang.Math.max (from2, to2); + + if (d != -1) { + outputTableBothToNewFile (index1, index2, from1, from2 + 1, _color_normal, htmlw); + outputLeftColumnTable (from1, max1 + 1, _color_d, htmlw); + } + else + if (a != -1) { + outputTableBothToNewFile (index1, index2, from1 + 1 , from2, _color_normal, htmlw); + outputRightColumnTable (from2, max2 + 1, _color_a, htmlw); + } + else + if (c != -1) { + outputTableBothToNewFile (index1, index2, from1, from2, _color_normal, htmlw); + outputTableBoth (from1, from2, max1 + 1, max2 + 1, _color_c, htmlw); + } + + index1 = max1 + 1; + index2 = max2 + 1; + } + } + + + public Vector runDiff (String file1, String file2, String diff){ + Vector differences = new Vector(); + try { + Runtime rm = java.lang.Runtime.getRuntime(); + Process p = rm.exec ("diff "+file1+" "+file2); + BufferedReader din = new BufferedReader(new InputStreamReader(p.getInputStream())); + + String st = ""; + while (null != (st = din.readLine())) + if (st.charAt (0) != '>' && st.charAt (0) != '<' && st.charAt (0) != '-' ) + differences.addElement (st); + + din.close(); + } + catch (IOException e) { System.out.println ("ERROR EXECUTING PROGRAM "+e.getMessage()); } + + return differences; + } + + public Vector writeOutInterrupts (DataOutputStream out, Vector interrupt, DataPool pool) + throws IOException { + System.out.println ("Size: "+interrupt.size()); + Vector strings = new Vector(); + int i = 0; + while (i < interrupt.size()){ + DInterrupt d = (DInterrupt) interrupt.elementAt (i); + if (_output_everything || ((!_remove_invalid || pool.findFirst (d.getPC()) == null) && !d.getIgnore())) { + String st = d.getPC().getSourceLocation().getURL()+" "+d.getPC().getSourceLocation().getLineno(); + strings.addElement (st); + out.writeBytes (st + "\n"); + i++; + } + else { + interrupt.removeElementAt (i); + System.out.println ("removing "+d.getPC().getSourceLocation().getLineno()); + } + } + return strings; + } + + /** If there are several interrupts with the same pc consequently, remove them, leave only one + */ + public void removeSequences (Vector interrupt){ + if (interrupt.size() == 0) return; + DInterrupt old = (DInterrupt) interrupt.elementAt (0); + int i = 1; + DInterrupt cur; + while (i < interrupt.size()){ + cur = (DInterrupt) interrupt.elementAt (i); + if (cur.getPC().equalsTo (old.getPC())) interrupt.removeElement (cur); + else { + old = cur; + i ++; + } + } + } + + /** + * Remove interrupts with PC which is not in the other pool or was set to be ignored. + */ + public void removeInvalid (Vector interrupt, DataPool pool){ + if (interrupt.size() == 0) return; + int i = 0; + DInterrupt cur; + while (i < interrupt.size()){ + cur = (DInterrupt) interrupt.elementAt (i); + if (cur.getPC().getSourceLocation().getIgnore() || pool.findFirst (cur.getPC().getSourceLocation()) == null) + interrupt.removeElementAt (i); + else i ++; + } + } + + public Vector removeKnownDifferences (Vector strings, int start, int end, Vector interrupts, DataPool pool){ + Vector result = new Vector (); + if (strings.size() == 0) return result; + String old = ""; + boolean known_difference; + if (start <= 0) start = 1; + + for (int i = start - 1; i < end-1; i++) { + DInterrupt d = (DInterrupt) interrupts.elementAt (i); + + String url = d.getPC().getSourceLocation().getURL(); + int lineno = d.getPC().getSourceLocation().getLineno(); + + if (d.getIgnore() || d.getPC().getSourceLocation().getIgnore () || pool.findFirst (d.getPC().getSourceLocation()) == null || + (_remove_single_curly_braces && AnalyzerBase.getSource (url, lineno).trim().equals ("}")) || + (_remove_single_curly_braces && AnalyzerBase.getSource (url, lineno).trim().equals ("{")) || + (_remove_spaces && AnalyzerBase.getSource (url, lineno).trim().equals ("")) || + (_remove_for_loops && AnalyzerBase.getSource (url, lineno).indexOf ("for") != -1)|| + (_remove_function_declarations && AnalyzerBase.getSource (url, lineno).indexOf ("function") != -1)) + + { + known_difference = true; + _number_of_known_diffs ++; + } + else { + _number_of_unknown_diffs ++; + known_difference = false; + } + + if (! known_difference ) { + _pass = false; + Enumeration e = _unknown_differences.elements (); + boolean found = false; + while (e.hasMoreElements () && !found) if (((DInterrupt)e.nextElement()).equalsTo (d)) found = true; + if (!found) _unknown_differences.addElement (d); + + } + if (! known_difference || _output_everything) { + /* make sure we don't add two equal strings one after another */ + String st = (String) strings.elementAt (i); + if (! st.equals (old) || i == start - 1) { + result.addElement (st); + old = st; + } + } + + } + + return result; + } + + public void list (HTMLWriter h, Vector v){ + Vector strings = new Vector (); + Vector info = new Vector (); + for (int i = 0; i < v.size(); i++){ + DInterrupt d = (DInterrupt) v.elementAt (i); + strings.addElement (d.getPC().getSourceLocation().getURL()+" "+d.getPC().getSourceLocation().getLineno()); + info.addElement (d.getTestInfo().getEngine()); + } + + h.table (strings, info, "red", "white"); + } + + private DTestInfo _dtinf1; + private DTestInfo _dtinf2; + private DataPool _sloc_pool1; + private DataPool _sloc_pool2; + private HTMLWriter _htmlw_main; + private Vector _dinterrupt_list1; + private Vector _dinterrupt_list2; + private Vector _strings1; + private Vector _strings2; + private Vector _differences; // strings like "1,7d2" -- results of diff + private Vector _unknown_differences; + + /* pass/fail result of the whole test */ + private boolean _pass; + private int _number_of_known_diffs = 0; + private int _number_of_unknown_diffs = 0; + + private int _counter = 0; + + /* Do we want to output every step of stepping to the file ? */ + private boolean _output_everything = true; + + /* KNWON DIFFERENCES FLAGS. MAX INFORMATION WILL BE OBTAINTED BY SETTING ALL THESE TO FALSE */ + /* should we remove where it stoped at sourcelocations not present in the other engine run ?*/ + private boolean _remove_invalid = true; + /* should ignore all single curly braces ? */ + private boolean _remove_single_curly_braces = true; + /* should ignore spaces ? */ + private boolean _remove_spaces = true; + /* should ignore comments ? */ + private boolean _remove_comments = true; + /* should ignore "for" loops */ + private boolean _remove_for_loops = true; + /* should ignore function declarations */ + private boolean _remove_function_declarations = true; + + + + + + + + private static final String _color_normal = "#FFFFFF"; + private static final String _color_a = "#FFF0F0"; + private static final String _color_d = "#FFF0F0"; + private static final String _color_c = "#FFB0B0"; + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeScriptPools.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeScriptPools.java new file mode 100644 index 00000000000..bf391583e24 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeScriptPools.java @@ -0,0 +1,149 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + package com.netscape.jsdebugging.apitests.analyzing.analyzers; + + import java.io.*; + import java.util.*; + import com.netscape.jsdebugging.apitests.xml.*; + import com.netscape.jsdebugging.apitests.analyzing.data.*; + +/** + * Analyzes two Script Pools + * + * @author Alex Rakhlin + */ + + + public class AnalyzeScriptPools extends AnalyzerBase { + + public AnalyzeScriptPools (HTMLWriter h, DataPoolManager dpm1, DataPoolManager dpm2, DataPoolManager common) { + super (h, dpm1, dpm2, common, "Scripts test", "scr", Tags.script_tag); + } + + /** + * overwrite analyze method. analyzing pools is a bit different: we want to find a "match" + * for the script, not just iterate through the list and print out each difference + */ + public void analyze (){ + analyzePools (); + list (_common_htmlw, _common); + + link_to_files (); + done (); + } + + public void analyzePools (){ + DataPool _script_pool1 = _dpm1.getPool (_tag); + DataPool _script_pool2 = _dpm2.getPool (_tag); + + _check_first_against_second (_script_pool1, _script_pool2); + _check_first_against_second (_script_pool2, _script_pool1); + } + + private void _check_first_against_second (DataPool _script_pool1, DataPool _script_pool2){ + for (int i = 0; i < _script_pool1.getPool().size(); i++){ + + DataScript d1 = (DataScript) _script_pool1.getPool().elementAt (i); + if (d1.getIgnore()) continue; + + String url = d1.getURL(); + String fun = d1.getFunction(); + DataScript d2 = null; //script corresponding to pool1 [i] + int j = 0; + while (j < _script_pool2.getPool().size()){ + DataScript e = (DataScript) _script_pool2.getPool().elementAt (j); + if (e.getIgnore()) { j ++; continue;} + if (e.getURL().equals (url) && e.getFunction().equals (fun)){ + d2 = e; + break; + } + j ++; + } + if ( d2 == null ) { + link (_unknown_htmlw, "No match for script", d1, d2, _dpm1.getTestInfo(), _dpm2.getTestInfo()); + d1.ignore(); + _number_of_unknown_diffs ++; + } + else { + link (_known_htmlw, "scope", d1, d2, _dpm1.getTestInfo(), _dpm2.getTestInfo()); + _number_of_known_diffs ++; + d1.ignore (); + d2.ignore (); + } + } + } + + private void _describe_scripts (String filename, DataScript d1, DataScript d2, DTestInfo dtinf1, DTestInfo dtinf2){ + HTMLWriter h = new HTMLWriter (filename); + int start1 = 0, start2 = 0, end1 = 0, end2 = 0; + String description1 = ""; + String description2 = ""; + String url = ""; + if (d1 != null) { + description1 = d1.toFormattedString(); + start1 = d1.getBaselineno(); + end1 = d1.getBaselineno()+d1.getLineExtent()-1; + url = d1.getURL(); + } + if (d2 != null) { + description2 = d2.toFormattedString(); + start2 = d2.getBaselineno(); + end2 = d2.getBaselineno()+d2.getLineExtent()-1; + } + h.twoCellTablePRE (description1, description2, "", "", "yellow", "black"); + h.twoCellTable ("ENGINE: " + dtinf1.getEngine(), "ENGINE: " + dtinf2.getEngine(), "", "", "white", "black"); + h.highlight (url, start1, start2, end1, end2); + + h.close(); + } + + + public void link (HTMLWriter htmlw, String text, DataScript d1, DataScript d2, DTestInfo dtinf1, DTestInfo dtinf2) + { + String filename = "scr"+getIndex()+".html"; + htmlw.println (""); + htmlw.startTag ("TD"); + htmlw.link (text, filename+"#start1"); + htmlw.endTag ("TD"); + htmlw.endTag ("TABLE"); + + _describe_scripts (filename, d1, d2, dtinf1, dtinf2); + } + + public static void makeHTMLFilesFromScripts (DataPool script_pool) { + for (int i = 0; i < script_pool.getPool().size(); i++){ + + DataScript d = (DataScript) script_pool.getPool().elementAt (i); + if (d.getIgnore()) continue; + + String url = d.getURL(); + String fun = d.getFunction(); + + if (fun.equals ("none")) { + if (! new File (HTMLWriter.getBaseDirectory ()+url+".html").exists()){ + HTMLWriter.makeHTMLFromScript (url); + } + } + + } + + } + + + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeSourceLocations.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeSourceLocations.java new file mode 100644 index 00000000000..9a833e48447 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzeSourceLocations.java @@ -0,0 +1,87 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + package com.netscape.jsdebugging.apitests.analyzing.analyzers; + + import java.io.*; + import java.util.*; + import com.netscape.jsdebugging.apitests.xml.*; + import com.netscape.jsdebugging.apitests.analyzing.data.*; + +/** + * Analyzes a SourceLocation data object + * + * @author Alex Rakhlin + */ + + + public class AnalyzeSourceLocations extends AnalyzerBase { + + public AnalyzeSourceLocations (HTMLWriter h, DataPoolManager dpm1, DataPoolManager dpm2, DataPoolManager common) { + super (h, dpm1, dpm2, common, "SourceLocation test", "sloc", Tags.source_location_tag); + } + + public boolean check (Data d, DataPoolManager dpm){ + DataSourceLocation dsloc = (DataSourceLocation) d; + int lineno = dsloc.getLineno(); + String url = dsloc.getURL(); + + if (dsloc.getSerialNumber() == -1) { + link (_known_htmlw, url+" "+lineno+": serial_number is -1. This is usually due to a result from getClosestPC", dpm.getTestInfo().getEngine(), dsloc, "white", "black"); + return true; + } + + String source = getSource (url, lineno); + + if (source.indexOf ('=') == -1 && source.indexOf ("var ") != -1){ + link (_known_htmlw, url+" "+lineno+": var", dpm.getTestInfo().getEngine(), dsloc, "white", "black"); + return true; + } + if (source.trim().equals ("}")){ + link (_known_htmlw, url+" "+lineno+": }", dpm.getTestInfo().getEngine(), dsloc, "white", "black"); + return true; + } + + link (_unknown_htmlw, url+" "+lineno+": Unknown difference", dpm.getTestInfo().getEngine(), dsloc, "red", "white"); + return false; + } + + + public void link (HTMLWriter htmlw, String text, String engine, DataSourceLocation d, String bgcolor, String fgcolor) + { + String filename = "sloc"+getIndex()+".html"; + htmlw.twoCellTable (text, engine, filename+"#start", "", bgcolor, fgcolor); + + HTMLWriter h = new HTMLWriter (filename); + h.oneCellTablePRE (d.toFormattedString(), "", "yellow", "black"); + h.highlight_line (d.getURL(), d.getLineno()); + h.close(); + } + + public void list (HTMLWriter htmlw, DataPoolManager dpm){ + DTestInfo dtinf = dpm.getTestInfo(); + DataPool pool = dpm.getPool (Tags.source_location_tag); + Vector v = new Vector(); + for (int i = 0; i < pool.getPool().size(); i ++){ + DataSourceLocation d = (DataSourceLocation) pool.getPool().elementAt(i); + if (d.getIgnore ()) continue; + v.addElement (d.getURL()+" "+d.getLineno()); + } + htmlw.table (v, new Vector (), "white", "black"); + } + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzerBase.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzerBase.java new file mode 100644 index 00000000000..b66d44b6784 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/analyzers/AnalyzerBase.java @@ -0,0 +1,169 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + package com.netscape.jsdebugging.apitests.analyzing.analyzers; + + import java.io.*; + import java.util.*; + import com.netscape.jsdebugging.apitests.xml.*; + import com.netscape.jsdebugging.apitests.analyzing.data.*; + import com.netscape.jsdebugging.apitests.analyzing.tree.*; + +/** + * Base class for analyzers + * + * @author Alex Rakhlin + */ + + + public abstract class AnalyzerBase { + + public AnalyzerBase (HTMLWriter h, DataPoolManager dpm1, DataPoolManager dpm2, DataPoolManager common, + String test_name, String prefix, String tag){ + _pass = true; + _htmlw_main = h; + _dpm1 = dpm1; + _dpm2 = dpm2; + _common = common; + _test_name = test_name; + _prefix = prefix; + _tag = tag; + _main_filename = _prefix + "_main.html"; + _known_filename = _prefix + "_known.html"; + _unknown_filename = _prefix + "_unknown.html"; + _common_filename = _prefix + "_intersect.html"; + + _main_htmlw = new HTMLWriter (_main_filename); + _known_htmlw = new HTMLWriter (_known_filename); + _unknown_htmlw = new HTMLWriter (_unknown_filename); + _common_htmlw = new HTMLWriter (_common_filename); + + } + + public void done () { + _main_htmlw.close(); + _known_htmlw.close(); + _unknown_htmlw.close(); + _common_htmlw.close(); + } + + public void analyze (){ + analyzePool (_dpm1); + analyzePool (_dpm2); + list (_common_htmlw, _common); + link_to_files (); + done (); + } + + public void link_to_files (){ + if (_number_of_unknown_diffs > 0) + _main_htmlw.oneCellTable ("UNKNOWN DIFFERENCES", _unknown_filename, "red", "white"); + _main_htmlw.oneCellTable ("KNOWN DIFFERENCES", _known_filename, "white", "black"); + _main_htmlw.oneCellTable ("COMMON", _common_filename, "white", "black"); + + _htmlw_main.twoCellTable (_test_name, HTMLWriter.pass_fail (_number_of_known_diffs, _number_of_unknown_diffs), + _main_filename, "", "white", "black"); + } + + /** + * This function should be implemented by each test. It checks if this data is a known difference. + * This function is also responsible for writing output to known_htmlw, unknown_htmlw, etc. + */ + public boolean check (Data d, DataPoolManager dpm){ + return false; + } + + public void analyzePool (DataPoolManager dpm){ + DTestInfo dtinf = dpm.getTestInfo(); + DataPool pool = dpm.getPool (_tag); + + for (int i = 0; i < pool.getPool().size(); i ++){ + DataSerializable d = (DataSerializable) pool.getPool().elementAt(i); + if (d.getIgnore ()) continue; + + if (check (d, dpm)) { + d.ignore (); + _number_of_known_diffs ++; + continue; + } + else { + _number_of_unknown_diffs ++; + } + } + } + + /** + * This function lists (writes out) a pool corresponding to _tag in the manager + * Overwrite this for specific output. + */ + public void list (HTMLWriter htmlw, DataPoolManager dpm){ + DataPool pool = dpm.getPool (_tag); + for (int i = 0; i < pool.getPool().size(); i ++){ + Data d = (Data) pool.getPool().elementAt(i); + if (d.getIgnore ()) continue; + + htmlw.oneCellTablePRE (d.toFormattedString(), "", "white", "black"); + } + } + + public static String getSource (String url, int line){ + DataInputStream din = null; + String st; + try { + din = new DataInputStream (new FileInputStream (url)); + int i = 1; + while (null != (st = din.readLine())) { + if (i == line) return st; + i ++; + } + } + catch (FileNotFoundException e){ System.out.println ("File not found: "+url); } + catch (IOException e){ System.out.println ("Error reading from file "+url); } + + return ""; + } + + + // index is used for making unique filenames. + public int getIndex () { return _index ++; } + private int _index = 0; + + /* pass/fail result of the whole test */ + protected boolean _pass; + protected int _number_of_known_diffs = 0; + protected int _number_of_unknown_diffs = 0; + + protected DataPoolManager _dpm1; + protected DataPoolManager _dpm2; + protected DataPoolManager _common; + protected HTMLWriter _htmlw_main; + protected String _test_name; + protected String _prefix; + protected String _tag; + + protected String _main_filename; + protected String _known_filename; + protected String _unknown_filename; + protected String _common_filename; + + protected HTMLWriter _main_htmlw; + protected HTMLWriter _known_htmlw; + protected HTMLWriter _unknown_htmlw; + protected HTMLWriter _common_htmlw; + + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DFrame.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DFrame.java new file mode 100644 index 00000000000..81890bb3eb4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DFrame.java @@ -0,0 +1,66 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import com.netscape.jsdebugging.apitests.xml.Tags; + +/** + * Even though Frame is not something you can give a serial number for, we still want to + * represent it by an object. Don't put it into a pool. + * + * @author Alex Rakhlin + */ + +public class DFrame extends Data { + + public DFrame (TreeNode head, DataPoolManager dpm){ + super (dpm); + _is_valid = TreeUtils.getChildBooleanData (head, Tags.is_valid_tag); + TreeNode t = TreeUtils.getFirstTagImmediate (head, Tags.pc_tag); + /* IMPORTANT: confusing part: sometimes DFrame is sitting inside a description (eval) + and sometimes not. If inside description, then getPointer() to a PC is not inited yet, + so we need to get the serial number and look up pc in the table. If it's not inside a + description, then we can refer to getPointer because it was set after all descriptors were + parsed */ + if (t.getPointer() != null) _pc = (DataPC) t.getPointer(); + else { + int _sn_pc = TreeUtils.getChildIntegerData (t, Tags.serial_number_tag).intValue(); + _pc = (DataPC) _dpm.lookup (Tags.pc_tag, _sn_pc); + } + } + + public boolean equalsTo (Data d){ + DFrame df = (DFrame) d; + return (df.getPC().equalsTo (_pc) && df.getIsValid() == _is_valid); + } + + public String toString () { return " Frame object: IS VALID: "+_is_valid+" has "+getPC(); } + public String toFormattedString () { + return "Frame object: \n"+ + "IS VALID: "+_is_valid+"\n"+ + " has \n"+getPC().toFormattedString(); + } + + public DataPC getPC () { return _pc; } + public boolean getIsValid () { return _is_valid; } + + private DataPC _pc; + private boolean _is_valid; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DInterrupt.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DInterrupt.java new file mode 100644 index 00000000000..02ac83e60bc --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DInterrupt.java @@ -0,0 +1,68 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import com.netscape.jsdebugging.apitests.xml.Tags; +import java.util.*; + +/** + * Even though an interrupt is not something you can give a serial number for, we still want to + * represent it by an object. Don't put it into a pool. + * + * @author Alex Rakhlin + */ + +public class DInterrupt extends Data { + + public DInterrupt (TreeNode head, DataPoolManager dpm){ + super (dpm); + _ignore = false; + + TreeNode t = TreeUtils.getFirstTagImmediate (head, Tags.pc_tag); + _pc = (DataPC) t.getPointer(); + + TreeNode s = TreeUtils.getFirstTagImmediate (head, Tags.stack_tag); + _stack = new DStack (s, dpm); + } + + public boolean equalsTo (Data d){ + DInterrupt dint = (DInterrupt) d; + return (dint.getPC().equalsTo (_pc) && dint.getStack().equalsTo (_stack)); + } + + public String toString (){ + return " Interrupt at "+_pc; + } + + public boolean getIgnore () { return _ignore; } + public void ignore () { _ignore = true; } + + public DataPC getPC () { return _pc; } + public DStack getStack () { return _stack; } + + public DTestInfo getTestInfo () { return _dtinf; } + public void setTestInfo (DTestInfo d) { _dtinf = d; } + private DTestInfo _dtinf; + + private DataPC _pc; + private DStack _stack; + + private boolean _ignore; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DStack.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DStack.java new file mode 100644 index 00000000000..442b06c5b9f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DStack.java @@ -0,0 +1,69 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import com.netscape.jsdebugging.apitests.xml.Tags; +import java.util.*; + +/** + * Even though Stack is not something you can give a serial number for, we still want to + * represent it by an object. Don't put it into a pool. + * + * @author Alex Rakhlin + */ + +public class DStack extends Data { + + public DStack (TreeNode head, DataPoolManager dpm){ + super (dpm); + _count = TreeUtils.getChildIntegerData (head, Tags.count_tag).intValue(); + _thread_state = TreeUtils.getChildIntegerData (head, Tags.count_tag).intValue(); + + Vector frames = TreeUtils.findAllTags (head, Tags.frame_tag); + _frames = new Vector(); + for (int i = 0; i < frames.size(); i++){ + TreeNode t = (TreeNode) frames.elementAt (i); + _frames.addElement (new DFrame (t, dpm)); + } + } + + public boolean equalsTo (Data d){ + DStack ds = (DStack) d; + if (ds.getCount() != _count) return false; + if (ds.getThreadState() != _thread_state) return false; + Vector fr = ds.getFrames(); + if (fr.size() != _frames.size()) return false; + for (int i = 0; i < fr.size(); i++) { + DFrame df1 = (DFrame) fr.elementAt (i); + DFrame df2 = (DFrame) _frames.elementAt (i); + if (! df1.equalsTo (df2)) return false; + } + return true; + } + + public Vector getFrames () { return _frames; } + public int getCount () { return _count; } + public int getThreadState () { return _thread_state; } + + private Vector _frames; + + private int _count; + private int _thread_state; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DTestInfo.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DTestInfo.java new file mode 100644 index 00000000000..b82c6e00bda --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DTestInfo.java @@ -0,0 +1,87 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import com.netscape.jsdebugging.apitests.xml.Tags; +import java.util.*; + +/** + * This object contains info about the test. Don't put it into a pool. + * + * @author Alex Rakhlin + */ + +public class DTestInfo extends Data { + + public DTestInfo (TreeNode head, DataPoolManager dpm){ + super (dpm); + + TreeNode h = TreeUtils.getFirstTagImmediate (head, Tags.header_tag); + _start_date = TreeUtils.getChildStringData (h, Tags.date_start_tag); + _finish_date = TreeUtils.getChildStringData (h, Tags.date_finish_tag); + _version = TreeUtils.getChildStringData (h, Tags.version_tag); + TreeNode m = TreeUtils.getFirstTagImmediate (head, Tags.main_tag); + _engine = TreeUtils.getChildStringData (m, Tags.engine_tag); + + TreeNode t = TreeUtils.getFirstTagImmediate (m, Tags.tests_tag); + Vector tests = TreeUtils.findAllTags (t, Tags.test_tag); + _tests = new Vector(); + for (int i = 0; i < tests.size (); i++) + _tests.addElement (((TreeNode) tests.elementAt (i)).getText()); + + TreeNode s = TreeUtils.getFirstTagImmediate (m, Tags.script_files_tag); + Vector files = TreeUtils.findAllTags (s, Tags.file_tag); + _files = new Vector(); + for (int i = 0; i < files.size (); i++) + _files.addElement (((TreeNode) files.elementAt (i)).getText()); + + } + + public String toString () { + String scr_files = "", tests = ""; + for (int i = 0; i < _files.size(); i++) scr_files = scr_files + (String) _files.elementAt (i) + " "; + for (int i = 0; i < _tests.size(); i++) tests = tests + (String) _tests.elementAt (i) + " "; + return "STARTED: " + _start_date + "\n"+ + "ENDED: " + _finish_date + "\n"+ + "ENGINE: " + _engine + "\n"+ + "SCRIPT FILES: " + scr_files + "\n"+ + "TESTS PERFORMED: " + tests; + } + + public boolean equalsTo (Data d){ + // doesn't make much sense to compare these objects + return false; + } + + public String getStartDate () { return _start_date; } + public String getFinishDate () { return _finish_date; } + public String getVersion () { return _version; } + public String getEngine () { return _engine; } + public Vector getTests () { return _tests; } + public Vector getFiles () { return _files; } + + private String _start_date; + private String _finish_date; + private String _version; + private String _engine; + private Vector _tests; + private Vector _files; + +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/Data.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/Data.java new file mode 100644 index 00000000000..e68ca13320a --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/Data.java @@ -0,0 +1,61 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +/** + * This is a parent of all data classes which contain data from the log file describing an object. + * + * @author Alex Rakhlin + */ + +public abstract class Data { + + public Data (DataPoolManager dpm){ + _ignore = false; + _dpm = dpm; + } + + public String toString (){ + return "override this method"; + } + + public String toFormattedString (){ + return "override this method"; + } + + /* must override this method */ + public abstract boolean equalsTo (Data d); + + /** + * should this object be ignored? + */ + public boolean getIgnore () { return _ignore; } + + /** + * Set the ignore field of this object to true. + */ + public void ignore () { _ignore = true; } + + /* ignore flag */ + protected boolean _ignore; + + /* reference to the pool manager -- might need it */ + protected DataPoolManager _dpm; + +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataError.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataError.java new file mode 100644 index 00000000000..ef96b75c33e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataError.java @@ -0,0 +1,73 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import com.netscape.jsdebugging.apitests.xml.Tags; + +/** + * Given the head of a description subtree reconstructs fields which Error contains. + * DataPoolManager is passed to look up serial numbers of objects inside the description. + * + * @author Alex Rakhlin + */ + +public class DataError extends DataSerializable { + + public DataError (TreeNode head, DataPoolManager dpm){ + super (head, dpm); + _msg = TreeUtils.getChildStringData (head, Tags.message_tag); + _url = TreeUtils.getChildStringData (head, Tags.url_tag); + _lineno = TreeUtils.getChildIntegerData (head, Tags.lineno_tag).intValue(); + _linebuf = TreeUtils.getChildStringData (head, Tags.linebuf_tag); + _token_offset = TreeUtils.getChildIntegerData (head, Tags.token_offset_tag).intValue(); + } + + public String toString (){ + return " ErrorReport: MSG: "+_msg+" URL: "+_url+" LINENO: "+_lineno+ + " LINEBUF: "+_linebuf+" TOKEN_OFFSET: "+_token_offset; + } + + public String toFormattedString (){ + return "ErrorReport \n"+ + "MSG: "+_msg+"\n" + + "URL: "+_url+"\n" + + "LINENO: "+_lineno + "\n"+ + "LINEBUF: "+_linebuf + "\n"+ + "TOKEN_OFFSET: "+_token_offset; + } + + public boolean equalsTo (Data d){ + DataError err = (DataError) d; + return (err.getMessage().equals(_msg) && err.getURL().equals(_url) && err.getLineno() == _lineno && + err.getLinebuf().equals(_linebuf) && err.getTokenOffset() == _token_offset); + } + + public String getMessage () { return _msg; } + public String getURL () { return _url; } + public int getLineno () { return _lineno; } + public String getLinebuf () { return _linebuf; } + public int getTokenOffset () { return _token_offset; } + + private String _msg; + private String _url; + private int _lineno; + private String _linebuf; + private int _token_offset; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataEval.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataEval.java new file mode 100644 index 00000000000..7c57e6e02f3 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataEval.java @@ -0,0 +1,101 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import com.netscape.jsdebugging.apitests.xml.Tags; +import java.util.*; + +/** + * Given the head of a description subtree reconstructs fields which Eval contains. + * DataPoolManager is passed to look up serial numbers of objects inside the description. + * + * @author Alex Rakhlin + */ + +public class DataEval extends DataSerializable { + + public DataEval (TreeNode head, DataPoolManager dpm){ + super (head, dpm); + TreeNode t = (TreeNode) TreeUtils.getFirstTagImmediate (head, Tags.frame_tag); + _frame = new DFrame (t, dpm); + + Vector results_tags = TreeUtils.findAllTags (head, Tags.results_tag); + + _eval_strings = new Vector (); + _results = new Vector (); + + for (int i = 0; i < results_tags.size(); i++) { + TreeNode results = (TreeNode) results_tags.elementAt (i); + String eval_str = TreeUtils.getChildStringData (results, Tags.eval_string_tag); + String result = TreeUtils.getChildStringData (results, Tags.result_tag); + _eval_strings.addElement (eval_str); + _results.addElement (result); + } + } + + public String toString (){ + String result = ""; + for (int i = 0; i < _eval_strings.size(); i++) + result = result + " eval ("+getEvalString (i) +") = "+getResult (i); + return result + getFrame().toString(); + } + + public String toFormattedString (){ + String result = ""; + for (int i = 0; i < _eval_strings.size(); i++) + result = result + "eval ("+getEvalString (i) +") = "+getResult (i)+"\n"; + return result + getFrame().toFormattedString(); + } + + public boolean equalsTo (Data d){ + DataEval eval = (DataEval) d; + return (eval.getFrame().equalsTo (_frame) && _equalVectors (eval.getEvalStrings(), _eval_strings) && + _equalVectors (eval.getResults(), _results)); + } + + private static boolean _equalVectors (Vector v1, Vector v2){ + if (v1.size() != v2.size()) return false; + for (int i = 0; i < v1.size(); i ++) { + String s1 = (String) v1.elementAt (i); + String s2 = (String) v2.elementAt (i); + if (!s1.equals (s2)) return false; + } + return true; + } + + public DFrame getFrame () { return _frame; } + private DFrame _frame; + + public Vector getEvalStrings () { return _eval_strings; } + public Vector getResults () { return _results; } + + public String getEvalString (int i) { + if (i < _eval_strings.size()) return (String) _eval_strings.elementAt (i); + return ""; + } + + public String getResult (int i) { + if (i < _results.size()) return (String) _results.elementAt (i); + return ""; + } + + private Vector _eval_strings; + private Vector _results; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPC.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPC.java new file mode 100644 index 00000000000..61b3415fb13 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPC.java @@ -0,0 +1,65 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import com.netscape.jsdebugging.apitests.xml.Tags; + +/** + * Given the head of a description subtree reconstructs fields which PC contains. + * DataPoolManager is passed to look up serial numbers of objects inside the description. + * + * @author Alex Rakhlin + */ + +public class DataPC extends DataSerializable { + + public DataPC (TreeNode head, DataPoolManager dpm){ + super (head, dpm); + _is_valid = TreeUtils.getChildBooleanData (head, Tags.is_valid_tag); + + TreeNode t = TreeUtils.getFirstTagImmediate (head, Tags.source_location_tag); + _sn_source_loc = TreeUtils.getChildIntegerData (t, Tags.serial_number_tag).intValue(); + + _source_location = (DataSourceLocation) _dpm.lookup (Tags.source_location_tag, _sn_source_loc); + } + + public String toString (){ + return " PC object, IS VALID: "+_is_valid +" has "+ _source_location; + } + + public String toFormattedString (){ + return "PC object \n"+ + "IS VALID: "+_is_valid +"\n"+ + " has \n"+ _source_location.toFormattedString(); + } + + public boolean equalsTo (Data d){ + DataPC pc = (DataPC) d; + return (pc.getIsValid () == _is_valid && _source_location.equalsTo (pc.getSourceLocation())); + } + + public boolean getIsValid () { return _is_valid; } + public DataSourceLocation getSourceLocation () { return _source_location; } + + private boolean _is_valid; + private int _sn_source_loc; + + private DataSourceLocation _source_location; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPool.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPool.java new file mode 100644 index 00000000000..485d967deb0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPool.java @@ -0,0 +1,129 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import java.util.*; + +/** + * Keeps a pool (Vector) of data objects + * + * @author Alex Rakhlin + */ + +public class DataPool { + + public DataPool (){ + _pool = new Vector (); + } + + public void add (DataSerializable d){ + _pool.addElement (d); + } + + /** + * Given a serial number, return corresponding object in the pool + */ + public DataSerializable lookup (int sernum){ + /* loop through all elements and find matching serial number -- optimize later */ + for (int i = 0; i < _pool.size(); i++){ + DataSerializable d = (DataSerializable) _pool.elementAt (i); + if (d.getSerialNumber() == sernum) return d; + } + return null; + } + + /** + * Find first occurences of data object (according to equalsTo method), + * starting at index start + */ + public DataSerializable findFirst (DataSerializable d, int start) { + for (int i = start; i < _pool.size(); i++){ + DataSerializable data = (DataSerializable) _pool.elementAt (i); + if (data.equalsTo (d)) return data; + } + return null; + } + + /** + * Find first occurences of data object (according to equalsTo method), starting at 0 + */ + public DataSerializable findFirst (DataSerializable d) { return findFirst (d, 0); } + + + /** + * Find all occurences of data object (according to equalsTo method), starting at index start + */ + public Vector find (DataSerializable d, int start) { + Vector result = new Vector (); + for (int i = start; i < _pool.size(); i++){ + DataSerializable data = (DataSerializable) _pool.elementAt (i); + if (data.equalsTo (d)) result.addElement (data); + } + return result; + } + + /** + * Remove all duplicates from the pool. Comparison done according to equalsTo method + */ + public void removeDuplicates (){ + int i = 0; + while (i < _pool.size() - 1){ + DataSerializable d = (DataSerializable) _pool.elementAt (i); + Vector dup = find (d, i+1); + for (int j = 0; j < dup.size(); j++) { + DataSerializable elem = (DataSerializable) dup.elementAt (j); + /* setting real pointer of the data object to point to the object it's a duplicate of */ + /* this is going to be used when updating the tree with fixTree */ + elem.setRealPointer (d); + _pool.removeElement (elem); //remove duplicate from the pool + } + i++; + } + } + /** + * Important: this scheme assumes that there are no duplicates in each pool. + * So, call removeDuplicates before calling this method + */ + public static DataPool intersectTwoPools (DataPool dp1, DataPool dp2){ + DataPool intersectPool = new DataPool (); + int i = 0; + while (i < dp1.getPool().size()){ + DataSerializable d1 = (DataSerializable) dp1.getPool().elementAt (i); + DataSerializable d2 = dp2.findFirst (d1); // using "equals" method of DataXXXX + if (d2 != null){ // object is in both pools, so remove it from both and put into intersect + dp1.getPool().removeElement (d1); + dp2.getPool().removeElement (d2); + intersectPool.getPool().addElement (d1); + } + else i++; + } + + return intersectPool; + } + + public void print (){ + System.out.println ("Printing pool of "+_pool.size()+" elements"); + for (int i = 0; i<_pool.size(); i++) System.out.println ((Data) _pool.elementAt(i)); + } + + public Vector getPool () { return _pool; } + + private Vector _pool; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPoolManager.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPoolManager.java new file mode 100644 index 00000000000..0d71e966437 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataPoolManager.java @@ -0,0 +1,173 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.xml.Tags; +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import java.util.*; + +/** + * This class manages pools of objects. + * + * @author Alex Rakhlin + */ + +public class DataPoolManager { + + public DataPoolManager (){ + _pools = new Hashtable (); + + _addPools (); + } + + /** + * Add standard pools at creation time + */ + private void _addPools (){ + _pools.put (DataPC.class, new DataPool ()); + _pools.put (DataEval.class, new DataPool ()); + _pools.put (DataError.class, new DataPool ()); + _pools.put (DataScript.class, new DataPool ()); + _pools.put (DataSection.class, new DataPool ()); + _pools.put (DataSourceLocation.class, new DataPool()); + } + + /** + * Get a pool corresponding to a tag name. + */ + public DataPool getPool (String name) { + if (name.equals (Tags.pc_tag)) return (DataPool) _pools.get (DataPC.class); + if (name.equals (Tags.script_tag)) return (DataPool) _pools.get (DataScript.class); + if (name.equals (Tags.eval_tag)) return (DataPool) _pools.get (DataEval.class); + if (name.equals (Tags.error_tag)) return (DataPool) _pools.get (DataError.class); + if (name.equals (Tags.section_tag)) return (DataPool) _pools.get (DataSection.class); + if (name.equals (Tags.source_location_tag)) return (DataPool) _pools.get (DataSourceLocation.class); + return null; + } + + /** + * Read object data from the tree and put it into an object in the corresponding pool + */ + public DataSerializable addNewElement (TreeNode head){ + /* determine the type of the described object by getting "TYPE" tag text. */ + String type = TreeUtils.getFirstTagImmediate (head, Tags.type_tag).getText(); + DataSerializable d = null; + if (type.equals (Tags.pc_tag)) d = new DataPC (head, this); + if (type.equals (Tags.script_tag)) d = new DataScript (head, this); + if (type.equals (Tags.source_location_tag)) d = new DataSourceLocation (head, this); + if (type.equals (Tags.section_tag)) d = new DataSection (head, this); + if (type.equals (Tags.error_tag)) d = new DataError (head, this); + if (type.equals (Tags.eval_tag)) d = new DataEval (head, this); + + if (d != null) add (d, getPool (type)); + + return null; + } + + /* static: add given object to the given pool */ + public static void add (DataSerializable d, DataPool dp){ + dp.add (d); + } + + public DataSerializable lookup (String name, int sernum){ + /* lookup an object given its type and serial number */ + DataPool p = getPool (name); + if (p == null) { + System.err.println ("!!! Unknown tag !!!"); + return null; + } + return p.lookup (sernum); + } + + /** + * Reads data from the descriptions, creates corresponding objects, removes + * descriptions from the tree, replaces serial numbers in the tree by pointers to data objects + */ + public void getDataFromTree (TreeNode head){ + /* get all pointers to the descriptions */ + Vector v = TreeUtils.findAllTags (head, Tags.description_tag); + + /* Add data for all Description tags and then delete tags + * Recursive descriptions done non-recursively (tey all appear in the vector) + */ + for (int i = 0; i < v.size(); i++){ + TreeNode t = (TreeNode) v.elementAt (i); + addNewElement (t); + t.getParent().removeChild (t); + } + + /* go through the tree and replace sernumbers + * by pointers to objects in corresponding pools */ + TreeUtils.replaceSerialNumbersByPointers (this, head, Tags.serial_number_tag); + } + + /** + * Removes duplicates for each pool, then goes through the tree and redirects pointers so that + * they don't point to the removed duplicates, but rather point to the corresponding remaining + * objects. Removed duplicates should therefore be garbage collected since there are no more + * references to them. + */ + public void removeDuplicatesAndFixTree (TreeNode head){ + /* for each pool remove duplicates in that pool */ + Enumeration e = _pools.elements(); + while (e.hasMoreElements()){ + DataPool d = (DataPool) e.nextElement(); + d.removeDuplicates(); + } + /* now go through the tree and update references to data objects */ + TreeUtils.fixRealPointers (head); + } + + /* static: intersect all pools in two pool managers and creates a new manager with intersected pools. + * As sets, result = (dpm1 AND dpm2); dpm1 = (dpm1 - result); dpm2 = (dpm2 - result)*/ + public static DataPoolManager intersectPools (DataPoolManager dpm1, DataPoolManager dpm2){ + DataPoolManager intersect = new DataPoolManager (); + Enumeration e = dpm1.getPools().keys (); + while (e.hasMoreElements()){ + Class d = (Class) e.nextElement(); // lookup by keys + + if (dpm2.getPools().containsKey(d) && intersect.getPools().containsKey(d)){ + DataPool dp1 = (DataPool) dpm1.getPools().get (d); + DataPool dp2 = (DataPool) dpm2.getPools().get (d); + + DataPool intersectPool = DataPool.intersectTwoPools (dp1, dp2); + intersect.getPools().remove (d); + intersect.getPools().put (d, intersectPool); // reinsert into intersect + } + } + return intersect; + } + + public void print (){ + System.out.println ("************** POOLS START ************"); + Enumeration e = _pools.elements(); + while (e.hasMoreElements()) ((DataPool) e.nextElement()).print(); + System.out.println ("************** POOLS END ************"); + } + + public void setTestInfo (DTestInfo dtinf) { _dtinf = dtinf; } + public DTestInfo getTestInfo () { return _dtinf; } + + + public Hashtable getPools () { return _pools; } + + private Hashtable _pools; + + private DTestInfo _dtinf; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataScript.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataScript.java new file mode 100644 index 00000000000..9f235bf42be --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataScript.java @@ -0,0 +1,83 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.xml.Tags; +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import java.util.*; + +/** + * Given the head of a description subtree reconstructs fields which Script contains. + * DataPoolManager is passed to look up serial numbers of objects inside the description. + * + * @author Alex Rakhlin + */ +public class DataScript extends DataSerializable { + + public DataScript (TreeNode head, DataPoolManager dpm){ + super (head, dpm); + _url = TreeUtils.getChildStringData (head, Tags.url_tag); + _fun = TreeUtils.getChildStringData (head, Tags.function_tag); + _baselineno = TreeUtils.getChildIntegerData (head, Tags.baselineno_tag).intValue(); + _line_extent = TreeUtils.getChildIntegerData (head, Tags.line_extent_tag).intValue(); + _is_valid = TreeUtils.getChildBooleanData (head, Tags.is_valid_tag); + + TreeNode t = TreeUtils.getFirstTagImmediate (head, Tags.section_list_tag); + Vector sec = TreeUtils.findAllTags (t, Tags.section_tag); + _sections = new Vector(); + for (int i = 0; i < sec.size(); i++){ + TreeNode s = (TreeNode) sec.elementAt (i); + DataSection d = (DataSection) _dpm.lookup (Tags.section_tag, TreeUtils.getChildIntegerData (s, Tags.serial_number_tag).intValue()); + _sections.addElement (d); + } + } + + public String toString (){ + return " Script object, URL: "+_url+" FUNCTION: "+_fun+" BASE: "+_baselineno+" EXTENT: "+_line_extent+" IS VALID: "+_is_valid; + } + + public String toFormattedString (){ + return "Script object \n"+ + "URL: "+_url+"\n"+ + "FUNCTION: "+_fun+"\n"+ + "BASE: "+_baselineno+"\n"+ + "LINE EXTENT: "+_line_extent+"\n"+ + "IS VALID: "+_is_valid; + } + + public boolean equalsTo (Data d) { + DataScript s = (DataScript) d; + return (s.getURL().equals (_url) && s.getFunction().equals (_fun) && s.getBaselineno() == _baselineno + && s.getLineExtent() == _line_extent && s.getIsValid () == _is_valid); + } + + public String getURL () { return _url; } + public String getFunction () { return _fun; } + public int getBaselineno () { return _baselineno; } + public int getLineExtent () { return _line_extent; } + public boolean getIsValid () { return _is_valid; } + + private String _url; + private String _fun; + private int _baselineno; + private int _line_extent; + private boolean _is_valid; + + private Vector _sections; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSection.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSection.java new file mode 100644 index 00000000000..30e02dd04c2 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSection.java @@ -0,0 +1,54 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import com.netscape.jsdebugging.apitests.xml.Tags; + +/** + * Given the head of a description subtree reconstructs fields which Section contains. + * DataPoolManager is passed to look up serial numbers of objects inside the description. + * + * @author Alex Rakhlin + */ + +public class DataSection extends DataSerializable { + + public DataSection (TreeNode head, DataPoolManager dpm){ + super (head, dpm); + _baselineno = TreeUtils.getChildIntegerData (head, Tags.baselineno_tag).intValue(); + _line_extent = TreeUtils.getChildIntegerData (head, Tags.line_extent_tag).intValue(); + } + + public String toString (){ + return " Section object, BASE: "+_baselineno+" EXTENT: "+_line_extent; + } + + public boolean equalsTo (Data d){ + DataSection s = (DataSection) d; + return (s.getBaselineno () == _baselineno && s.getLineExtent() == _line_extent); + } + + + public int getBaselineno () { return _baselineno; } + public int getLineExtent () { return _line_extent; } + + private int _baselineno; + private int _line_extent; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSerializable.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSerializable.java new file mode 100644 index 00000000000..3322bc1a9e5 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSerializable.java @@ -0,0 +1,64 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.xml.Tags; +import com.netscape.jsdebugging.apitests.analyzing.tree.*; + +/** + * Parent of all data classes which will be put into a pool and given a serial number. + * + * @author Alex Rakhlin + */ + +public abstract class DataSerializable extends Data { + + public DataSerializable (TreeNode head, DataPoolManager dpm){ + super (dpm); + _real_pointer = null; + _head = head; + _sn = TreeUtils.getChildIntegerData (head, Tags.serial_number_tag).intValue(); + } + + /** + * Get the serial number of this object. + */ + public int getSerialNumber () { return _sn; } + + /** + * Set the real pointer for this object. + */ + public void setRealPointer (DataSerializable d) { _real_pointer = d; } + + /** + * Get the real pointer for this object. If this object is a duplicate, then this + * refers to the single real object. Otherwise, null. + */ + public DataSerializable getRealPointer () { return _real_pointer; } + + /** + * if this object is a duplicate, then this refers to the single real object. Otherwise, null. + */ + protected DataSerializable _real_pointer; + + /* serial number */ + protected int _sn; + + protected TreeNode _head; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSourceLocation.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSourceLocation.java new file mode 100644 index 00000000000..e05d9e584f0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/data/DataSourceLocation.java @@ -0,0 +1,59 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.data; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import com.netscape.jsdebugging.apitests.xml.Tags; + +/** + * Given the head of a description subtree reconstructs fields which SourceLocation contains. + * DataPoolManager is passed to look up serial numbers of objects inside the description. + * + * @author Alex Rakhlin + */ + +public class DataSourceLocation extends DataSerializable { + + public DataSourceLocation (TreeNode head, DataPoolManager dpm){ + super (head, dpm); + _lineno = TreeUtils.getChildIntegerData (head, Tags.lineno_tag).intValue(); + _url = TreeUtils.getChildStringData (head, Tags.url_tag); + } + + public String toString (){ + return "SourceLocation object, LINENO: "+_lineno+" URL: "+_url; + } + + public String toFormattedString (){ + return "SourceLocation object \n"+ + "LINENO: "+_lineno+"\n"+ + "URL: "+_url; + } + + public boolean equalsTo (Data d){ + DataSourceLocation sl = (DataSourceLocation) d; + return (sl.getLineno () == _lineno && sl.getURL().equals(_url)); + } + + public int getLineno () { return _lineno; } + public String getURL () { return _url; } + + private int _lineno; + private String _url; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/tree/TreeNode.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/tree/TreeNode.java new file mode 100644 index 00000000000..7b1fd1dabae --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/tree/TreeNode.java @@ -0,0 +1,104 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.analyzing.tree; + +import java.util.*; +import com.netscape.jsdebugging.apitests.analyzing.data.*; +import com.netscape.jsdebugging.apitests.xml.Tags; + +/** + * TreeNode represents a node in the tree corresponding to a tag, text, and children + * in the xml document we want to parse. + * + * @author Alex Rakhlin + */ + +public class TreeNode { + + public TreeNode (TreeNode parent, String tag, String text){ + _parent = parent; + _tag = Tags.encode (tag); + _text = text; + _children = new Vector(); + _pointer = null; + } + + public TreeNode (TreeNode parent, String tag){ + _parent = parent; + _tag = Tags.encode (tag); + _text = ""; + _children = new Vector(); + } + + public void insertChild (TreeNode child){ + _children.addElement (child); + } + + public void removeChild (TreeNode child){ + _children.removeElement (child); + } + + public TreeNode insertChild (String tag){ + TreeNode result = new TreeNode (this, tag); + insertChild (result); + return result; + } + + public TreeNode insertChild (String tag, String text){ + TreeNode result = new TreeNode (this, tag, text); + insertChild (result); + return result; + } + + public void setText (String text){ _text = text; } + + /** + * sets pointer to point to a Data object. This is used when descriptions are replaced + * by actual references to objects + */ + public void setPointer (DataSerializable pointer) { _pointer = pointer; } + public DataSerializable getPointer () { return _pointer; } + + public String getTag () { return Tags.decode(_tag); } + public String getText (){ return _text;} + public Vector getChildren() { return _children; } + public TreeNode getParent() { return _parent; } + + + public String toString (){ + String s = "TAG: "+ getTag() +" DATA: " + getText(); + if (_pointer != null) s = s + _pointer; + return s; + } + + public boolean equalNodeTags (TreeNode t){ + return (t.getTag().equals(Tags.decode (_tag))); + } + + public boolean equalNodeTexts (TreeNode t){ + return (t.getText().equals(_text)); + } + + + private TreeNode _parent; + private int _tag; + private String _text; + private Vector _children; + private DataSerializable _pointer; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/tree/TreePrinter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/tree/TreePrinter.java new file mode 100644 index 00000000000..d4c74aa16c5 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/analyzing/tree/TreePrinter.java @@ -0,0 +1,80 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + + +package com.netscape.jsdebugging.apitests.analyzing.tree; + +import java.util.*; + +/** + * Prints trees, vectors of trees, etc. + * + * @author Alex Rakhlin + */ + +public class TreePrinter { + + /** + * Prints the tree down from the given node + */ + public static void print (TreeNode node){ + System.out.println ("************* TREE START **************"); + _counter = 0; + _pad(); + System.out.println (node); + _printTree (node); + System.out.println ("************* TREE END **************"); + } + + /** + * Prints a vector of nodes + */ + public static void print (Vector list){ + for (int i = 0; i\n"); } + private void writeHTMLFooter(){ endTag ("BODY"); endTag ("HTML"); } + + public void printParagraph (String s){ tag ("P", s); } + public void printBoldParagraph (String s){ startTag ("B"); tag ("P", s); endTag ("B"); } + public void link (String s, String url) { write (""+s+"\n"); } + + public void cell (String s, String url, String fgcolor){ + if (s.equals ("")) s = " "; + write (""); + } + + public void cellPRE (String s, String url, String fgcolor){ + if (s.equals ("")) s = " "; + write (""); + } + + public void twoCells (String s1, String s2, String url1, String url2, String fgcolor){ + write (""); + cell (s1, url1, fgcolor); + cell (s2, url2, fgcolor); + write (""); + } + + public void twoCellsPRE (String s1, String s2, String url1, String url2, String fgcolor){ + write (""); + cellPRE (s1, url1, fgcolor); + cellPRE (s2, url2, fgcolor); + write (""); + } + + public void twoCellTable (String s1, String s2, String url1, String url2, String bgcolor, String fgcolor){ + println ("
"); + write (""); + if (url.equals("")) write(s); + else link (s, url); + write (""); + write (""); + write (""); + if (url.equals("")) write("
"+s+"
"); + else link (s, url); + write ("
"); + write ("
"); + twoCells (s1, s2, url1, url2, fgcolor); + println ("
"); + } + public void oneCellTable (String s, String url, String bgcolor, String fgcolor){ + println (""); + cell (s, url, fgcolor); + println ("
"); + } + + public void twoCellTablePRE (String s1, String s2, String url1, String url2, String bgcolor, String fgcolor){ + println (""); + twoCellsPRE (s1, s2, url1, url2, fgcolor); + println ("
"); + } + + public void oneCellTablePRE (String s, String url, String bgcolor, String fgcolor){ + println (""); + cellPRE (s, url, fgcolor); + println ("
"); + } + + public void table (Vector column1, Vector column2, String bgcolor, String fgcolor){ + println(""); + System.out.println ("TableBoth "+column1.size()+" "+column2.size()); + int count = (int) java.lang.Math.max (column1.size(), column2.size()); + + String s1, s2, url1, url2; + for (int i = 0; i < count; i++){ + s1 = ""; s2 = ""; url1 = ""; url2 = ""; + if (i < column1.size()) s1 = (String) column1.elementAt(i); + if (i < column2.size()) s2 = (String) column2.elementAt(i); + StringTokenizer st1 = new StringTokenizer (s1, " "); + StringTokenizer st2 = new StringTokenizer (s2, " "); + if (st1.countTokens() == 2) url1 = st1.nextToken() + ".html#" + st1.nextToken(); + if (st2.countTokens() == 2) url2 = st2.nextToken() + ".html#" + st2.nextToken(); + twoCells (s1, s2, url1, url2, fgcolor); + } + println ("
"); + } + + public void table (Vector column1, Vector column2, int start1, int start2, int end1, int end2, String bgcolor, String fgcolor){ + System.out.println ("table "+start1+" "+start2+" " + end1+" "+end2+" "); + Vector v1 = new Vector (); + Vector v2 = new Vector (); + if (start1 <= 0) start1 = 1; + if (start2 <= 0) start2 = 1; + for (int i = start1-1; i < end1-1; i++) v1.addElement ((String) column1.elementAt (i)); + for (int i = start2-1; i < end2-1; i++) v2.addElement ((String) column2.elementAt (i)); + table (v1, v2, bgcolor, fgcolor); + } + + public static String pass_fail (int num_known, int num_unknown) { + if (num_unknown == 0) return "
PASS  Known: "+num_known+". Unknown: "+num_unknown+"
"; + return "
FAIL  Known: "+num_known+". Unknown: "+num_unknown+"
"; + } + + public void highlight (String filename, int start1, int start2, int end1, int end2){ + if (filename.equals ("")) return; + println (""); + String st = ""; + DataInputStream din = null; + try { + din = new DataInputStream (new FileInputStream (filename)); + int i = 1; + while (null != (st = din.readLine())) { + if (st.equals ("")) st = " "; + if (i == start1) println (""); + if (i == start2) println (""); + write (""); + if (i >= start1 && i <= end1) write ("
"+st); 
+                else write ("
"+st);
+                if (i >= start2 && i <= end2) println ("
"+st); 
+                else println ("
"+st);
+                i ++;
+            }
+        } catch (FileNotFoundException e){
+            System.out.println ("File not found: "+filename);
+        } catch (IOException e){
+            System.out.println ("Error reading from file "+filename);
+        }
+        println ("
"); + } + + public void highlight_line (String filename, int lineno){ + if (filename.equals ("")) return; + write (""); + String st = ""; + DataInputStream din = null; + try { + din = new DataInputStream (new FileInputStream (filename)); + int i = 1; + while (null != (st = din.readLine())) { + if (st.equals ("")) st = " "; + if (i == lineno) println (""); + write (""); + if (i == lineno) println ("
"+st);
+                else println ("
"+st); 
+                i ++;
+            }
+        } catch (FileNotFoundException e){
+            System.out.println ("File not found: "+filename);
+        } catch (IOException e){
+            System.out.println ("Error reading from file "+filename);
+        }
+        println ("
"); + } + + public void getLinesFromScript (String name){ + try { + DataInputStream din = new DataInputStream (new FileInputStream (name)); + String st; + int i = 1; + //startTag ("PRE"); + while (null != (st = din.readLine())){ + write (""); + println (""+i+": "+st+""); + + i++; + } + //endTag ("PRE"); + } + catch (IOException e) { System.out.println ("Error reading/writing file "+name+"xx");} + } + + public static void makeHTMLFromScript (String name){ + HTMLWriter h = new HTMLWriter (name+".html"); + h.getLinesFromScript (name); + h.close(); + } + +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/TagHandler.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/TagHandler.java new file mode 100644 index 00000000000..70bc55fe905 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/TagHandler.java @@ -0,0 +1,32 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.xml; + +/** + * This is done for compatibility with ibm xml parser. + * + * @author Alex Rakhlin + */ + +public interface TagHandler { + + public void handleStartTag (String tag); + public void handleEndTag (String tag, String text); + +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/Tags.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/Tags.java new file mode 100644 index 00000000000..46769aff74f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/Tags.java @@ -0,0 +1,144 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.xml; + +import java.util.*; + +/** + * tags definitions + * + * @author Alex Rakhlin + */ + +public class Tags { + + public static final String baselineno_tag = "BASE_LINENO"; + public static final String closest_pc_tag = "CLOSEST_PC"; + public static final String count_tag = "COUNT"; + public static final String date_start_tag = "START_DATE"; + public static final String date_finish_tag = "FINISH_DATE"; + public static final String description_tag = "DESCRIPTION"; + public static final String doc_tag = "DOC"; + public static final String engine_tag = "ENGINE"; + public static final String error_tag = "ERROR"; + public static final String eval_tag = "EVAL"; + public static final String eval_string_tag = "EVAL_STRING"; + public static final String file_tag = "FILE"; + public static final String frame_tag = "FRAME"; + public static final String function_tag = "FUNCTION"; + public static final String header_tag = "HEADER"; + public static final String interrupt_tag = "INTERRUPT"; + public static final String is_valid_tag = "IS_VALID"; + public static final String linebuf_tag = "LINE_BUF"; + public static final String lineno_tag = "LINENO"; + public static final String line_tag = "LINE"; + public static final String lines_tag = "LINES"; + public static final String line_extent_tag = "LINE_EXTENT"; + public static final String main_tag = "MAIN"; + public static final String message_tag = "MESSAGE"; + public static final String pc_tag = "PC"; + public static final String result_tag = "RESULT"; + public static final String results_tag = "RESULTS"; + public static final String script_tag = "SCRIPT"; + public static final String script_files_tag = "SCRIPT_FILES"; + public static final String script_loaded_tag = "SCRIPT_LOADED"; + public static final String script_unloaded_tag = "SCRIPT_UNLOADED"; + public static final String section_list_tag = "SECTION_LIST"; + public static final String section_tag = "SECTION"; + public static final String serial_number_tag = "SERIAL_NUMBER"; + public static final String source_location_tag = "SOURCE_LOCATION"; + public static final String stack_tag = "STACK"; + public static final String step_tag = "STEP"; + public static final String test_tag = "TEST"; + public static final String tests_tag = "TESTS"; + public static final String thread_state_tag = "THREAD_STATE"; + public static final String token_offset_tag = "TOKEN_OFFSET"; + public static final String type_tag = "TYPE"; + public static final String url_tag = "URL"; + public static final String version_tag = "VERSION"; + + /** + * Init vector of tags. This function must be called before encode() and decode(). + */ + public static void init (){ + _tags = new Vector (); + _tags.addElement (baselineno_tag); + _tags.addElement (closest_pc_tag); + _tags.addElement (count_tag); + _tags.addElement (date_start_tag); + _tags.addElement (date_finish_tag); + _tags.addElement (description_tag); + _tags.addElement (doc_tag); + _tags.addElement (engine_tag); + _tags.addElement (error_tag); + _tags.addElement (eval_tag); + _tags.addElement (eval_string_tag); + _tags.addElement (file_tag); + _tags.addElement (frame_tag); + _tags.addElement (function_tag); + _tags.addElement (header_tag); + _tags.addElement (interrupt_tag); + _tags.addElement (is_valid_tag); + _tags.addElement (linebuf_tag); + _tags.addElement (lineno_tag); + _tags.addElement (line_tag); + _tags.addElement (lines_tag); + _tags.addElement (line_extent_tag); + _tags.addElement (main_tag); + _tags.addElement (message_tag); + _tags.addElement (pc_tag); + _tags.addElement (result_tag); + _tags.addElement (results_tag); + _tags.addElement (script_tag); + _tags.addElement (script_files_tag); + _tags.addElement (script_loaded_tag); + _tags.addElement (script_unloaded_tag); + _tags.addElement (section_list_tag); + _tags.addElement (section_tag); + _tags.addElement (serial_number_tag); + _tags.addElement (source_location_tag); + _tags.addElement (stack_tag); + _tags.addElement (step_tag); + _tags.addElement (test_tag); + _tags.addElement (tests_tag); + _tags.addElement (thread_state_tag); + _tags.addElement (token_offset_tag); + _tags.addElement (type_tag); + _tags.addElement (url_tag); + _tags.addElement (version_tag); + } + + /** + * Get a number given a tag. + */ + public static int encode (String st){ + return _tags.indexOf (st); + } + + /** + * Get a tag given a number. + */ + public static String decode (int i){ + if (i == -1) return ""; + else return (String) _tags.elementAt (i); + } + + + private static Vector _tags; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/TreeCreator.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/TreeCreator.java new file mode 100644 index 00000000000..7a63bb0efd0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/TreeCreator.java @@ -0,0 +1,59 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.xml; + +import com.netscape.jsdebugging.apitests.analyzing.tree.*; +import java.util.*; + +/** + * Creates a tree by handling start and end tags. This can be simplified because I'm no longer using + * ibm xml parser. + * + * @author Alex Rakhlin + */ + +public class TreeCreator implements TagHandler{ + + public TreeCreator (){ + _processedHead = false; + } + + public void handleStartTag (String tag){ + //System.out.println ("Start tag "+tag); + if (!_processedHead) { //should happen only once + _processedHead = true; + _head = new TreeNode (null, tag); + _current = _head; + } + else _current = _current.insertChild (tag); + } + + + public void handleEndTag (String tag, String text){ + //System.out.println ("End tag "+ tag+" text "+text); + // this is a hack which relies on the assumption that tags which have text have no children. + if (_current.getChildren().size() == 0) _current.setText (text); + _current = _current.getParent(); + } + + public TreeNode getTree () { return _head; } + + private TreeNode _head, _current; + private boolean _processedHead; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLEscape.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLEscape.java new file mode 100644 index 00000000000..20117471b4d --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLEscape.java @@ -0,0 +1,64 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.xml; + +import java.io.*; +import java.util.*; + +/** + * Provides functions for escaping characters. + * + * @author Alex Rakhlin + */ + +public class XMLEscape { + + /** + * Replaces characters, like "<", ">", etc. with the corresponding "<", ">", etc. + */ + public static String escape (String text){ + if (text == null) return null; + text = _replace ("<", "<", text); + text = _replace (">", ">", text); + + return text; + } + + /** + * Undoes escape () + */ + public static String unescape (String text){ + if (text == null) return null; + text = _replace ("<", "<", text); + text = _replace (">", ">", text); + + return text; + } + + private static String _replace (String oldst, String newst, String target){ + String result = target; + int j; + int i = 0; + while (-1 != (j = result.indexOf (oldst, i))){ + result = result.substring (0, j) + newst + result.substring (j+oldst.length()); + i = j; + } + return result; + } +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLParser.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLParser.java new file mode 100644 index 00000000000..aeb8fef1dc0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLParser.java @@ -0,0 +1,85 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.xml; + +import java.io.*; +import com.netscape.jsdebugging.apitests.analyzing.tree.*; + +/** + * Creates a tree from the XML file. + * NOTE: Current parsing relies on specific format of the file. For example, + * I assume that each line is either: + * + * or + * text + * + * Anything else would crash the system. + * + * @author Alex Rakhlin + */ +public class XMLParser { + + public XMLParser (){ + _tag_handler = new TreeCreator (); + } + + /** + * parse the file into a tree. Tree can be retreived by calling getTree(). + */ + public void parse (String filename){ + RandomAccessFile _file = null; + try { + _file = new RandomAccessFile (filename, "r"); + String st = ""; + while ( null != (st = _file.readLine())) { + _processLine(st); + } + } catch (IOException e) { System.out.println ("Error opening file"); return; } + } + + private void _processLine (String st){ + int open1 = st.indexOf ('<'); + int close1 = st.indexOf ('>', open1); + int open2 = st.indexOf ('<', close1); + int close2 = st.indexOf ('>', open2); + + //System.out.println (st+" "+open1+" "+close1+" "+open2+" "+close2); + + if (open1 == -1) return; + + if (open2 == -1){ + if (st.charAt (open1+1) == '/') + _tag_handler.handleEndTag (new String (st.substring(open1+1, close1)), ""); + else _tag_handler.handleStartTag (new String (st.substring(open1+1, close1))); + } + else { + _tag_handler.handleStartTag (new String (st.substring(open1+1, close1))); + _tag_handler.handleEndTag (new String (st.substring(open2+2, close2)), + XMLEscape.unescape(new String (st.substring(close1+1, open2)))); + } + } + + + /** + * Return the tree created from parsing + */ + public TreeNode getTree () { return ((TreeCreator)_tag_handler).getTree(); } + + private TagHandler _tag_handler; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLWriter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLWriter.java new file mode 100644 index 00000000000..599f9b6f479 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/apitests/xml/XMLWriter.java @@ -0,0 +1,131 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.apitests.xml; + +import java.io.*; +import java.util.*; +import com.netscape.jsdebugging.apitests.xml.Tags; + + +/** + * Writes info in the XML format. + * + * @author Alex Rakhlin + */ +public class XMLWriter { + + /** + * @param filename Name of the file to write into. + * @param indent Starting indent in the file + */ + public XMLWriter (String filename, int indent) { + try { + _output = new RandomAccessFile (_base_directory+filename, "rw"); + //_output.seek (_output.length()); + _indent = indent; + } catch (IOException e) { System.out.println ("Error opening "+_base_directory+filename); } + } + + /** + * Writes string to the file + */ + public void write (String s){ + try { + _output.writeBytes (s); + } catch (IOException e) { System.out.println ("Error"); } + } + + private void _indent (){ + String s = ""; + for (int i = 0; i<_indent*INDENT_SIZE; i++) s = s + " "; + write (s); + } + + /** + * Writes string and the new-line character + */ + public void println (String s){ write (s+"\n"); } + + /** + * Writes an open tag with indent. + */ + public void startTag (String s){ + _indent(); + write ("<"+s+">"); + _indent ++; + write ("\n"); + } + + /** + * Writes a closing tag with indent. + */ + public void endTag (String s){ + _indent --; + _indent(); + write (""); + write ("\n"); + } + + /** + * Writes an opening tag, value of the tag, and a closing tag. + */ + public void tag (String tag, String val){ + _indent(); + write ("<"+tag+">"); + write ( XMLEscape.escape(val) ); // write escaped value + write (""); + write ("\n"); + } + + public void tag (String tag, int val){ tag (tag, (new Integer (val)).toString());} + + public void tag (String tag, boolean val){ tag (tag, (new Boolean (val)).toString());} + + /** + * Close the output file. + */ + public void close (){ + try { + _output.close(); + } catch (IOException e) { System.out.println ("Error closing xml document"); } + } + + // remove this later + public void prDTDInit (){ + write ("\n"); + write ("\n"); + } + + private RandomAccessFile _output; + private int _indent; + + private final int INDENT_SIZE = 1; + + /** + * Set the base directory for XMLWriter. This base directory is prepended to the filename + * of all new XMLWriters. + */ + public static void setBaseDirectory (String s) { + if (s == null) { _base_directory = ""; return; } + if (s.equals ("") || s.endsWith ("\\") || s.endsWith ("/")) _base_directory = s; + else _base_directory = s + "\\"; + } + public static String getBaseDirectory () { return _base_directory; } + private static String _base_directory = ""; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IContext.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IContext.java new file mode 100644 index 00000000000..20ebd766aea --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IContext.java @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine; + +public interface IContext +{ + public boolean isValid(); + + // finalization not guaranteed to happen in right order - trust programmer + public void destroy(); + + public String evalString(String s, String filename, int lineno); + + public String loadFile(String filename); + + public IErrorSink getErrorSink(); + public IErrorSink setErrorSink(IErrorSink sink); + + public IPrintSink getPrintSink(); + public IPrintSink setPrintSink(IPrintSink sink); + + public IRuntime getRuntime(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IErrorSink.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IErrorSink.java new file mode 100644 index 00000000000..6330dd1074c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IErrorSink.java @@ -0,0 +1,25 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine; + +public interface IErrorSink +{ + public void error(String msg, String filename, int lineno, + String lineBuf, int offset); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IPrintSink.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IPrintSink.java new file mode 100644 index 00000000000..eee7b4c8d1b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IPrintSink.java @@ -0,0 +1,24 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine; + +public interface IPrintSink +{ + public void print(String s); +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IRuntime.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IRuntime.java new file mode 100644 index 00000000000..1e9b3a8d182 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IRuntime.java @@ -0,0 +1,32 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine; + +public interface IRuntime +{ + public IContext newContext(String[] args); + + public boolean isValid(); + + // finalization not guaranteed to happen in right order - trust programmer + public void destroy(); + + public com.netscape.jsdebugging.api.DebugController getDebugController(); + public com.netscape.jsdebugging.api.SourceTextProvider getSourceTextProvider(); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IRuntimeCreator.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IRuntimeCreator.java new file mode 100644 index 00000000000..a00e0d0930d --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/IRuntimeCreator.java @@ -0,0 +1,27 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine; + +public interface IRuntimeCreator +{ + public static final boolean ENABLE_DEBUGGING = true; + public static final boolean NO_DEBUGGING = false; + + public IRuntime newRuntime(boolean enableDebugging, String[] args); +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/README b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/README new file mode 100644 index 00000000000..7ab964050df --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/README @@ -0,0 +1,6 @@ +/* jband - 09/14/98 - */ + +com.netscape.jsdebugging.engine declares a simple generic interface for starting +and running a JavaScript engine (with optional debug support). It exists to +support testing. Test systems can be compiled and run against this +interface package and choose *at runtime* which engine to load and run. diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/ContextLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/ContextLocal.java new file mode 100644 index 00000000000..367810603bd --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/ContextLocal.java @@ -0,0 +1,100 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine.local; + +import java.io.*; +import java.util.*; +import com.netscape.jsdebugging.engine.*; + + +public class ContextLocal + implements IContext, + com.netscape.nativejsengine.IPrintSink, + com.netscape.nativejsengine.IErrorSink +{ + private ContextLocal(){} + + ContextLocal(RuntimeLocal runtime, String[] args) { + _runtime = runtime; + + _context = com.netscape.nativejsengine.JSContext.newContext( + _runtime.getNativeRuntime()); + if(null == _context) { + _destroyed = true; + return; + } + + _context.setPrintSink(this); + _context.setErrorSink(this); + } + + public boolean isValid() {return ! _destroyed;} + + // finalization not guaranteed to happen in right order - trust programmer + public void destroy() { + _destroyed = true; + _context.destroy(); + } + + public String evalString(String s, String filename, int lineno) { + _context.eval(s, filename, lineno); + return null; + } + + public String loadFile(String filename) { + _context.load(filename); + return null; + } + + public IErrorSink getErrorSink() {return _errorSink;} + public IErrorSink setErrorSink(IErrorSink sink) { + IErrorSink result = _errorSink; + _errorSink = sink; + return result; + } + + public IPrintSink getPrintSink() {return _printSink;} + public IPrintSink setPrintSink(IPrintSink sink) { + IPrintSink result = _printSink; + _printSink = sink; + return result; + } + + // implement com.netscape.nativejsengine.IPrintSink + public void print(String s) { + if(null != _printSink) + _printSink.print(s); + } + + // implement com.netscape.nativejsengine.IErrorSink + public void error(String msg, String filename, int lineno, + String lineBuf, int offset) + { + if(null != _errorSink) + _errorSink.error(msg, filename, lineno, lineBuf, offset); + } + + public IRuntime getRuntime() {return _runtime;} + + private boolean _destroyed = false; + private RuntimeLocal _runtime; + private com.netscape.nativejsengine.JSContext _context; + private IErrorSink _errorSink; + private IPrintSink _printSink; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/README b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/README new file mode 100644 index 00000000000..252e3281138 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/README @@ -0,0 +1,5 @@ +/* jband - 09/14/98 - */ + +com.netscape.jsdebugging.engine.local implements the +com.netscape.jsdebugging.engine interface. It supports running the C engine for +testing. \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/RuntimeCreatorLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/RuntimeCreatorLocal.java new file mode 100644 index 00000000000..46d1d6a6b5f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/RuntimeCreatorLocal.java @@ -0,0 +1,31 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine.local; + +import com.netscape.jsdebugging.engine.*; + +public class RuntimeCreatorLocal implements IRuntimeCreator +{ + public IRuntime newRuntime(boolean enableDebugging, String[] args) { + RuntimeLocal runtime = new RuntimeLocal(enableDebugging, args); + if(! runtime.isValid()) + return null; + return runtime; + } +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/RuntimeLocal.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/RuntimeLocal.java new file mode 100644 index 00000000000..0d532f6a45b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/local/RuntimeLocal.java @@ -0,0 +1,83 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine.local; + +import com.netscape.jsdebugging.engine.*; + +public class RuntimeLocal implements IRuntime +{ + private RuntimeLocal() {} + + public static final String LOCAL_LOADER_NAME = + "com.netscape.jsdebugging.api.local.AdapterLoaderLocal"; + + RuntimeLocal(boolean enableDebugging, String[] args) { + _runtime = com.netscape.nativejsengine.JSRuntime.newRuntime( + com.netscape.nativejsengine.JSRuntime.ENABLE_DEBUGGING); + if(null == _runtime) { + _destroyed = true; + return; + } + + if(enableDebugging) { + + try { + Class clazz = Class.forName(LOCAL_LOADER_NAME); + com.netscape.jsdebugging.api.AdapterLoader loader = + (com.netscape.jsdebugging.api.AdapterLoader) clazz.newInstance(); + + _controller = loader.getDebugController(); + _stp = loader.getSourceTextProvider(); + } + catch(Throwable e) { + System.out.println(e); + } + } + } + + public IContext newContext(String[] args) { + ContextLocal context = new ContextLocal(this, args); + if(! context.isValid()) + return null; + return context; + } + + public boolean isValid() {return ! _destroyed;} + + // finalization not guaranteed to happen in right order - trust programmer + public void destroy() { + _destroyed = true; + _controller = null; + _stp = null; + _runtime.destroy(); + } + + com.netscape.nativejsengine.JSRuntime getNativeRuntime() {return _runtime;} + + public com.netscape.jsdebugging.api.DebugController + getDebugController() {return _controller;} + + public com.netscape.jsdebugging.api.SourceTextProvider + getSourceTextProvider() {return _stp;} + + private com.netscape.nativejsengine.JSRuntime _runtime; + private boolean _destroyed = false; + private com.netscape.jsdebugging.api.DebugController _controller; + private com.netscape.jsdebugging.api.SourceTextProvider _stp; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/ContextRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/ContextRhino.java new file mode 100644 index 00000000000..a49c04b074c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/ContextRhino.java @@ -0,0 +1,288 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine.rhino; + +import java.io.*; +import java.util.*; +import com.netscape.jsdebugging.engine.*; +import com.netscape.javascript.*; +import com.netscape.javascript.debug.*; + + +public class ContextRhino + extends ScriptableObject + implements IContext, com.netscape.javascript.ErrorReporter +{ + private ContextRhino(){} + + ContextRhino(RuntimeRhino runtime, String[] args) { + _runtime = runtime; + _cx = new Context(); + + try { + _cx.enter(); + } catch (InterruptedException e) { + throw new Error(e.getMessage()); + } catch (ThreadAssociationException e) { + throw new Error(e.getMessage()); + } + + // Initialize the standard objects (Object, Function, etc.) + // This must be done before scripts can be executed. + _cx.initStandardObjects(this); + + // Define some global functions particular to the shell. Note + // that these functions are not part of ECMA. + String[] names = {"print", "version", "load"}; + + try { + this.defineFunctionProperties(names, ContextRhino.class, + ScriptableObject.DONTENUM); + } catch (PropertyDefinitionException e) { + throw new Error(e.getMessage()); + } + + _cx.setErrorReporter(this); + + DebugManager dbm = _runtime.getDebugManager(); + + if(null != dbm) { + _cx.setDebugLevel(6); + _cx.setSourceTextManager(_runtime.getSourceTextManager()); + dbm.createdContext(_cx); + } + + + // XXX more stuff... + } + + public boolean isValid() {return ! _destroyed;} + + // finalization not guaranteed to happen in right order - trust programmer + public void destroy() { + _destroyed = true; + try { + _cx.exit(); + } catch (ThreadAssociationException e) { + throw new Error(e.getMessage()); + } + // XXX more stuff... + } + + public String evalString(String s, String filename, int lineno) { + + try { + return Context.toString( + _cx.evaluateString(this, s, filename, lineno, null)); + } + catch(Exception e) { + // eat it silently +// System.out.println(e); + return ""; + } + } + + public String loadFile(String filename) { + return processSource(_cx, this, filename); + } + + public IErrorSink getErrorSink() {return _errorSink;} + public IErrorSink setErrorSink(IErrorSink sink) { + IErrorSink result = _errorSink; + _errorSink = sink; + return result; + } + + public IPrintSink getPrintSink() {return _printSink;} + public IPrintSink setPrintSink(IPrintSink sink) { + IPrintSink result = _printSink; + _printSink = sink; + return result; + } + + public IRuntime getRuntime() {return _runtime;} + + + // required for ScriptableObject. + public String getClassName() { + return "global"; + } + + /** + * Load and execute a set of JavaScript source files. + * + * This method is defined as a JavaScript function. + * + */ + public static void load(Context cx, Scriptable thisObj, + Object[] args, Function funObj) + { + for (int i=0; i < args.length; i++) { + processSource(cx, (ContextRhino)thisObj,cx.toString(args[i])); + } + } + + /** + * Evaluate JavaScript source. + * Code is taken from Shell.java + * + * @param cx the current context + * @param filename the name of the file to compile + */ + public static String processSource(Context cx, ContextRhino self, String filename) { + Reader in = null; + String result = ""; + try { + in = new PushbackReader(new FileReader(filename)); + int c = in.read(); + // Support the executable script #! syntax: If + // the first line begins with a '#', treat the whole + // line as a comment. + if (c == '#') { + while ((c = in.read()) != -1) { + if (c == '\n' || c == '\r') + break; + } + ((PushbackReader) in).unread(c); + } else { + // No '#' line, just reopen the file and forget it + // ever happened. OPT closing and reopening + // undoubtedly carries some cost. Is this faster + // or slower than leaving the PushbackReader + // around? + in.close(); + in = new FileReader(filename); + } + + } + catch (FileNotFoundException ex) { + System.out.println ("Couldn't open"); + return result; + } catch (IOException ioe) { + System.err.println(ioe.toString()); + } + + try { + // Here we evalute the entire contents of the file as + // a script. Text is printed only if the print() function + // is called. + result = Context.toString( + cx.evaluateReader(self, in, filename, 1, null)); + } + catch (WrappedException we) { + System.err.println(we.getWrappedException().toString()); + we.printStackTrace(); + } + catch (EvaluatorException ee) { + // Already printed message, so just fall through. + } + catch (JavaScriptException jse) { + } + catch (IOException ioe) { + System.err.println(ioe.toString()); + } + finally { + try { + in.close(); + } + catch (IOException ioe) { + System.err.println(ioe.toString()); + } + } + return result; + } + + /** + * Get and set the language version. + * + * This method is defined as a JavaScript function. + */ + public static double version(Context cx, Scriptable thisObj, + Object[] args, Function funObj) + { + double result = (double) cx.getLanguageVersion(); + if (args.length > 0) { + double d = cx.toNumber(args[0]); + cx.setLanguageVersion((int) d); + } + return result; + } + + /** + * Print the string values of its arguments. + * + * This method is defined as a JavaScript function. + * Note that its arguments are of the "varargs" form, which + * allows it to handle an arbitrary number of arguments + * supplied to the JavaScript function. + * + */ + public static Object print(Context cx, Scriptable thisObj, + Object[] args, Function funObj) + { + IPrintSink sink = ((ContextRhino)thisObj)._printSink; + + if(null != sink) { + for (int i=0; i < args.length; i++) { + if (i > 0) + sink.print(" "); + + // Convert the + // arbitrary JavaScript value into a string form. + + String s = Context.toString(args[i]); + + sink.print(s); + } + sink.print("\n"); + } + return Context.getUndefinedValue(); + } + + // implement com.netscape.javascript.ErrorReporter + public void warning(String message, String sourceName, int line, + String lineSource, int lineOffset) + { + if(null != _errorSink) + _errorSink.error(message, sourceName, line, lineSource, lineOffset); + } + + public void error(String message, String sourceName, int line, + String lineSource, int lineOffset) + { + if(null != _errorSink) + _errorSink.error(message, sourceName, line, lineSource, lineOffset); + throw new EvaluatorException(message); + } + + public EvaluatorException runtimeError(String message, String sourceName, + int line, String lineSource, + int lineOffset) + { + if(null != _errorSink) + _errorSink.error(message, sourceName, line, lineSource, lineOffset); + return new EvaluatorException(message); + } + + private boolean _destroyed = false; + private RuntimeRhino _runtime; + private Context _cx; + private IErrorSink _errorSink; + private IPrintSink _printSink; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/README b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/README new file mode 100644 index 00000000000..cc5449f3d36 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/README @@ -0,0 +1,5 @@ +/* jband - 09/14/98 - */ + +com.netscape.jsdebugging.engine.rhino implements the +com.netscape.jsdebugging.engine interface. It supports running the JavaScript in +Java (Rhino) engine for testing. diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/RuntimeCreatorRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/RuntimeCreatorRhino.java new file mode 100644 index 00000000000..67231d84a8c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/RuntimeCreatorRhino.java @@ -0,0 +1,31 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine.rhino; + +import com.netscape.jsdebugging.engine.*; + +public class RuntimeCreatorRhino implements IRuntimeCreator +{ + public IRuntime newRuntime(boolean enableDebugging, String[] args) { + RuntimeRhino runtime = new RuntimeRhino(enableDebugging, args); + if(! runtime.isValid()) + return null; + return runtime; + } +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/RuntimeRhino.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/RuntimeRhino.java new file mode 100644 index 00000000000..65b844c28d4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/engine/rhino/RuntimeRhino.java @@ -0,0 +1,87 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.engine.rhino; + +import com.netscape.jsdebugging.engine.*; +import com.netscape.javascript.*; +import com.netscape.javascript.debug.*; + +import com.netscape.jsdebugging.api.rhino.*; + +public class RuntimeRhino implements IRuntime +{ + private RuntimeRhino() {} + + RuntimeRhino(boolean enableDebugging, String[] args) { + if(enableDebugging) { + _debug_dm = new DebugManager(); + _debug_stm = new SourceTextManagerImpl(); + _debug_dm.setSourceTextManager(_debug_stm); + + DebugControllerRhino.setGlobalDebugManager(_debug_dm); + SourceTextProviderRhino.setGlobalSourceTextManager(_debug_stm); + try + { + _controller = DebugControllerRhino.getDebugController(); + if( null == _controller ) + System.out.println ("FAILED to Init DebugController"); + _stp = SourceTextProviderRhino.getSourceTextProvider(); + if( null == _stp ) + System.out.println ("FAILED to Init SourceTextProvider"); + } + catch(Throwable t) + { + System.out.println("execption thrown " + t ); + } + } + } + + public IContext newContext(String[] args) { + ContextRhino context = new ContextRhino(this, args); + if(! context.isValid()) + return null; + return context; + } + + public boolean isValid() {return ! _destroyed;} + + // finalization not guaranteed to happen in right order - trust programmer + public void destroy() { + _destroyed = true; + _debug_dm = null; + _debug_stm = null; + _controller = null; + _stp = null; + } + + public com.netscape.jsdebugging.api.DebugController + getDebugController() {return _controller;} + + public com.netscape.jsdebugging.api.SourceTextProvider + getSourceTextProvider() {return _stp;} + + DebugManager getDebugManager() {return _debug_dm; } + SourceTextManager getSourceTextManager() {return _debug_stm;} + + private DebugManager _debug_dm; + private SourceTextManager _debug_stm; + private boolean _destroyed = false; + private com.netscape.jsdebugging.api.DebugController _controller; + private com.netscape.jsdebugging.api.SourceTextProvider _stp; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BackgroundHackListView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BackgroundHackListView.java new file mode 100644 index 00000000000..53ae09db422 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BackgroundHackListView.java @@ -0,0 +1,63 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this class to implement Unix hack +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; + +class BackgroundHackListView extends ListView +{ + public BackgroundHackListView() + { + super(); + } + public BackgroundHackListView(Rect r) + { + super(r); + } + + public BackgroundHackListView(int x, int y, int dx, int dy ) + { + super(x,y,dx,dy); + } + + public void drawViewBackground(Graphics g, int x, int y, int width,int height) + { + if(!isTransparent()) + { + Color bc = backgroundColor(); + if( null != bc ) + { + g.setColor(bc); + + // XXX: hackage to deal with Unix problem + // (see bugsplat bug #78027) + java.awt.Graphics awtg = AWTCompatibility.awtGraphicsForGraphics(g); + awtg.setColor(java.awt.Color.white); + awtg.setColor(AWTCompatibility.awtColorForColor(bc)); + + g.fillRect(x, y, width, height); + } + } + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Breakpoint.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Breakpoint.java new file mode 100644 index 00000000000..9bf60b1818e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Breakpoint.java @@ -0,0 +1,144 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.api.*; + +public class Breakpoint + implements Comparable, Codable +{ + + public Breakpoint( String url, + int line, + String breakCondition ) + { + this(url,line); + _breakCondition=breakCondition; + } + + public Breakpoint( String url, + int line ) + { + this(new Location(url,line)); + } + public Breakpoint( Location loc ) + { + this(); + _loc = loc; + if(ASS)ER.T(null!=loc,"null location in Breakpoint ctor",this); + } + + public Breakpoint() + { + _hooks = new Hashtable(); + } + + // attributes are immutable + + public Location getLocation() {return _loc;} + public String getURL() {return _loc.getURL(); } + public int getLine() {return _loc.getLine();} + + public String getBreakCondition() {return _breakCondition;} + public void setBreakCondition(String bc) {_breakCondition=bc;} + + public Hashtable getHooks() {return _hooks;} + + public void putHook(Script script, Hook hook) + { + if(ASS)ER.T(null==_hooks.get(script),"putting an existing hook",this); + _hooks.put(script, hook); + } + + public Hook getHook(Script script) + { + return (Hook) _hooks.get(script); + } + + public Hook removeHook(Script script) + { + Hook hook = (Hook) _hooks.remove(script); + if(ASS)ER.T(null!=hook,"removing a non-existant hook",this); + return hook; + } + + // override Object + public String toString() + { + return _loc.toString(); + } + + // override Object + public boolean equals(Object obj) + { + if(ASS)ER.T(obj!=null,"null object handed to Breakpoint equals",this); + if(ASS)ER.T(obj instanceof Breakpoint,"non-Breakpoint obect handed to Breakpoint equals",this); + return _loc.equals( ((Breakpoint)obj)._loc ); + } + + // override Object + public int hashCode() + { + return _loc.hashCode(); + } + + // implement Comparable + public int compareTo(Object obj) + { + if(ASS)ER.T(obj!=null,"null obect handed to Breakpoint compareTo",this); + if(ASS)ER.T(obj instanceof Breakpoint,"non-Breakpoint obect handed to Breakpoint compareTo",this); + + Breakpoint other = (Breakpoint) obj; + return _loc.compareTo(((Breakpoint)obj)._loc); + } + + // implement Codable + public void describeClassInfo(ClassInfo info) + { + info.addField("_loc", OBJECT_TYPE); + info.addField("_breakCondition", STRING_TYPE); + } + public void encode(Encoder encoder) throws CodingException + { + encoder.encodeObject("_loc", _loc); + encoder.encodeString("_breakCondition", _breakCondition); + } + public void decode(Decoder decoder) throws CodingException + { + _loc = (Location) decoder.decodeObject("_loc"); + _breakCondition = decoder.decodeString("_breakCondition"); + } + public void finishDecoding() throws CodingException + { + } + + + private Hashtable _hooks; + private Location _loc; + private String _breakCondition; + private static final boolean ASS = true; // enable ASSERT support? +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointEditorDialog.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointEditorDialog.java new file mode 100644 index 00000000000..dc77de483a3 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointEditorDialog.java @@ -0,0 +1,194 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 10/14/97 jband created class +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; + +class BreakpointEditorDialog + extends InternalWindow + implements Target +{ + private static final int _labelDX = 55; + private static final int _labelDY = 24; + private static final int _editDX = 300; + private static final int _editDY = 24; + private static final int _buttonDX = 64; + private static final int _buttonDY = 24; + private static final int _spacerDX = 5; + private static final int _spacerDY = 5; + + public BreakpointEditorDialog(String title, + int line, + String url, + String condition, + Font font, + boolean isNew ) + { + super(); + + setTitle(title); + setCloseable( false ); + setResizable( false ); + + int contentDX = _labelDX + _editDX + _spacerDX * 3; + int contentDY = _editDY * 3 + _spacerDY * 5 + _buttonDY; + int buttonY = _editDY * 3 + _spacerDY * 4; + int buttonX2 = contentDX - _spacerDX - _buttonDX; + int buttonX1 = buttonX2 - _spacerDX - _buttonDX; + int labelX = _spacerDX; + int editX = labelX + _labelDX + _spacerDX; + + int Y1 = _spacerDY; + int Y2 = Y1 + _editDY + _spacerDY; + int Y3 = Y2 + _editDY + _spacerDY; + + Size size = windowSizeForContentSize(contentDX, contentDY); + setBounds(0,0,size.width,size.height); + + addSubview( _newLabel(labelX, Y1, _labelDX, _labelDY, "line") ); + addSubview( _newLabel(labelX, Y2, _labelDX, _labelDY, "url") ); + addSubview( _newLabel(labelX, Y3, _labelDX, _labelDY, "condition") ); + + _textFieldLine = new TextField(editX,Y1,_editDX,_editDY); + _textFieldLine.setIntValue(line); + _textFieldLine.setFont(font); + addSubview(_textFieldLine); + + _textFieldURL = new TextField(editX,Y2,_editDX,_editDY); + _textFieldURL.setStringValue(new String(url)); + _textFieldURL.setFont(font); + addSubview(_textFieldURL); + + _textFieldCondition = new TextField(editX,Y3,_editDX,_editDY); + _textFieldCondition.setStringValue(new String(condition)); + _textFieldCondition.setFont(font); + addSubview(_textFieldCondition); + + Button button; + + button = new Button(buttonX1,buttonY,_buttonDX,_buttonDY); + button.setTitle("OK"); + button.setTarget(this); + button.setCommand(OK_CMD); + addSubview(button); + + button = new Button(buttonX2,buttonY,_buttonDX,_buttonDY); + button.setTitle("Cancel"); + button.setTarget(this); + button.setCommand(CANCEL_CMD); + addSubview(button); + + if( isNew ) + setFocusedView( _textFieldLine ); + else + setFocusedView( _textFieldCondition ); + center(); + } + + private TextField _newLabel( int x, int y, int dx, int dy, String text ) + { + TextField label = new TextField(x,y,dx,dy); + label.setStringValue(text); + label.setEditable(false); + label.setSelectable(false); + label.setJustification(Graphics.RIGHT_JUSTIFIED); + label.setBackgroundColor(Color.lightGray); + label.setBorder(null); + return label; + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(OK_CMD) ) + { + // get and validate data... + + _URL = _textFieldURL.stringValue(); + if( null == _URL || 0 == _URL.trim().length() ) + { + Alert.runAlertInternally( Alert.notificationImage(), + "invalid entry", + "you must enter a valid url", + "OK", null,null ); + setFocusedView( _textFieldURL ); + return; + } + + _condition = _textFieldCondition.stringValue(); + if( null == _condition || 0 == _condition.trim().length() ) + { + _condition = "true"; + } + + _line = 0; + try + { + String str = _textFieldLine.stringValue(); + if( null != str && 0 != str.trim().length() ) + _line = Integer.parseInt(str); + } + catch( NumberFormatException e ) + { + // eat it + } + if( _line <= 0 ) + { + Alert.runAlertInternally( Alert.notificationImage(), + "invalid entry", + "line number must be >= 1", + "OK", null,null ); + setFocusedView( _textFieldLine ); + return; + } + + _ok = true; + hide(); + } + else if( cmd.equals(CANCEL_CMD) ) + { + hide(); + } + } + + public boolean okPressed() {return _ok;} + public String getURL() {return _URL;} + public String getCondition() {return _condition;} + public int getLine() {return _line;} + + + private TextField _textFieldLine; + private TextField _textFieldURL; + private TextField _textFieldCondition; + private String _URL; + private int _line; + private String _condition; + private boolean _ok = false; + private static final String OK_CMD = "OK_CMD"; + private static final String CANCEL_CMD = "CANCEL_CMD"; +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointHook.java new file mode 100644 index 00000000000..becdf215d42 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointHook.java @@ -0,0 +1,153 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.security.PrivilegeManager; +import com.netscape.jsdebugging.api.*; + +class BreakpointHook + extends InstructionHook + implements ChainableHook, JSErrorReporter +{ + public BreakpointHook(Emperor emperor, PC pc, Object tyrant, Breakpoint bp) + { + super(pc); + _emperor = emperor; + setTyrant(tyrant); + setBreakpoint(bp); + } + + public void aboutToExecute(ThreadStateBase debug) + { + // for safety we make sure not to throw anything at native caller. + try { + _ctrlTyrant.evaluatingBreakpoint(true); + boolean stop = _shouldStop((JSThreadState)debug); + _ctrlTyrant.evaluatingBreakpoint(false); + + if( stop ) + _ctrlTyrant.aboutToExecute( (JSThreadState)debug, (JSPC)getPC(), this ); + else + _ctrlTyrant.breakpointHookCalledButElectedNotToStop((JSThreadState)debug); + if( null != _nextHook ) + _nextHook.aboutToExecute(debug); + } catch(Throwable t){} // eat it. + } + + public Breakpoint getBreakpoint() {return _bp;} + public void setBreakpoint(Breakpoint bp) {_bp = bp;} + + // implement ChainableHook + public void setTyrant(Object tyrant) {_ctrlTyrant = (ControlTyrant) tyrant;} + public void setNextHook(Hook nextHook) {_nextHook = (InstructionHook) nextHook;} + public InstructionHook getNextHook() {return _nextHook;} + + + private boolean _shouldStop(JSThreadState threadState) + { +// System.out.println( "1) in _shouldStop" ); + if( null == _ctrlTyrant || null == _bp ) + return false; + +// System.out.println( "2) in _shouldStop" ); + // currently don't stopping when already stopped + if( ControlTyrant.STOPPED == _ctrlTyrant.getState() ) + return false; + + String breakCondition = _bp.getBreakCondition(); + if( null == breakCondition ) + return true; + +// System.out.println( "3) in _shouldStop" ); + JSErrorReporter oldER = null; + try + { + PrivilegeManager.enablePrivilege("Debugger"); + DebugController dc = _emperor.getDebugController(); + + String filename; + if( _ctrlTyrant.getEmperor().isPre40b6() || + Emperor.REMOTE_SERVER == _ctrlTyrant.getEmperor().getHostMode() ) + filename = "HiddenBreakpointEval"; + else + filename = _bp.getURL(); + + JSStackFrameInfo frame = (JSStackFrameInfo) threadState.getCurrentFrame(); + + _errorString = null; + if( ! _emperor.isCorbaHostConnection() ) + { + oldER = _ctrlTyrant.setErrorReporter(this); + } + +// System.out.println( "4) in _shouldStop, condition = " + breakCondition); + + ExecResult fullresult = + dc.executeScriptInStackFrame(frame,breakCondition,filename,1); + + String result = fullresult.getResult(); + + if( ! _emperor.isCorbaHostConnection() ) + { + _ctrlTyrant.setErrorReporter(oldER); + oldER = null; + } + +// System.out.println( "5) in _shouldStop"); + if( null != _errorString ) + return false; + +// System.out.println( "6) in _shouldStop, result = " + result ); + if( null == result || ! result.equals("true") ) + return false; +// System.out.println( "7) in _shouldStop"); + } + catch(Exception e) + { + // if we hit an expection, then we'll just not stop here... + if( null != oldER ) + _ctrlTyrant.setErrorReporter(oldER); +// System.out.println( "8) in _shouldStop"); + return false; + } +// System.out.println( "9) in _shouldStop"); + return true; + } + + // implement JSErrorReporter interface + public synchronized int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + _errorString = msg; + return JSErrorReporter.RETURN; + } + + private Emperor _emperor; + private ControlTyrant _ctrlTyrant; + private InstructionHook _nextHook; + private Breakpoint _bp; + private String _errorString; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointSaver.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointSaver.java new file mode 100644 index 00000000000..56c79bba413 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointSaver.java @@ -0,0 +1,79 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 07/31/97 jband created this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; + +public class BreakpointSaver + implements Codable +{ + // public ctor with no params necessary for Codable + public BreakpointSaver() {} + + // implement Codable + public void describeClassInfo(ClassInfo info) + { + info.addField("_bps", OBJECT_ARRAY_TYPE); + } + public void encode(Encoder encoder) throws CodingException + { + if( null != _bps && 0 != _bps.length ) + encoder.encodeObjectArray("_bps", _bps, 0, _bps.length); + } + public void decode(Decoder decoder) throws CodingException + { + _bps = decoder.decodeObjectArray("_bps"); + } + public void finishDecoding() throws CodingException + { + } + + // interaction with BreakpointTyrant + + public void sendToTyrant( BreakpointTyrant bpt ) + { + if( null != _bps && 0 != _bps.length ) + { + for(int i = 0; i < _bps.length; i++ ) + { + Breakpoint bp = (Breakpoint) _bps[i]; + + if( null == bpt.findBreakpoint(bp) ) + { + String condition = bp.getBreakCondition(); + bp = bpt.addBreakpoint(bp.getLocation()); + if( null != bp && null != condition ) + bp.setBreakCondition(condition); + } + } + } + } + + public void getFromTyrant( BreakpointTyrant bpt ) + { + _bps = bpt.getAllBreakpoints(); + } + + private Object[] _bps; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointTyrant.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointTyrant.java new file mode 100644 index 00000000000..ecd86133471 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointTyrant.java @@ -0,0 +1,547 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.api.*; +import netscape.security.PrivilegeManager; + +// scripts stored in a Vector with newest scripts at the high end + +public class BreakpointTyrant + extends Observable + implements Observer, PrefsSupport +{ + public BreakpointTyrant(Emperor emperor) + { + super(); + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + + PrivilegeManager.enablePrivilege("Debugger"); + _dc = _emperor.getDebugController(); + + // set script hook + _scriptHook = new BPTyrantScriptHook(this); + _scriptHook.setNextHook(_dc.setScriptHook(_scriptHook)); + + _breakpoints = new Hashtable(); + _scripts = new Vector(); + + _controlTyrant.addObserver(this); + + if(ASS) + { + _uiThreadForAssertCheck = Thread.currentThread(); + } + + _enabled = true; + // process the scripts currently known by the controller + _dc.iterateScripts(_scriptHook); + } + + public Breakpoint findBreakpoint( Location loc ) + { + return (Breakpoint) _breakpoints.get(loc); + } + + public Breakpoint findBreakpoint( Breakpoint bp ) + { + return (Breakpoint) _breakpoints.get(bp.getLocation()); + } + + + public synchronized Breakpoint addBreakpoint( Location loc ) + { + Breakpoint bp; + + if( null != (bp = findBreakpoint(loc)) ) + { + if(ASS)ER.T(false,"attempted to add existing Breakpoint: "+bp,this); + return bp; + } + + loc = _getBestBPLocationForLocation(loc,null); + bp = new Breakpoint(loc); + _breakpoints.put(loc,bp); + _notifyObservers( BreakpointTyrantUpdate.ADD_ONE, bp ); + _setHooksForBP(bp); + + return bp; + } + + + public synchronized void removeBreakpoint( Breakpoint bp ) + { + if( null == findBreakpoint(bp) ) + { + if(ASS)ER.T(false,"attempted to remove non-existant Breakpoint: "+bp,this); + return; + } + + _clearHooksForBP(bp); + _breakpoints.remove(bp.getLocation()); + _notifyObservers( BreakpointTyrantUpdate.REMOVE_ONE, bp ); + } + + public synchronized void removeAllBreakpoints() + { + Enumeration e = _breakpoints.elements(); + + while( e.hasMoreElements() ) + { + Breakpoint bp = (Breakpoint) e.nextElement(); + _clearHooksForBP(bp); + } + + _breakpoints.clear(); + _notifyObservers( BreakpointTyrantUpdate.REMOVE_ALL, null ); + } + + public synchronized void removeAllBreakpointsForURL( String url ) + { + + Vector vec = getBreakpointsForURL(url); + int count = vec.count(); + if( 0 == count ) + return; + + for( int i = 0; i < count; i++ ) + { + Breakpoint bp = (Breakpoint) vec.elementAt(i); + _clearHooksForBP(bp); + _breakpoints.remove(bp.getLocation()); + } + _notifyObservers( BreakpointTyrantUpdate.REMOVE_ALL_FOR_URL, new Breakpoint(url,0) ); + } + + public Vector getBreakpointsForURL( String url ) + { + Vector vret = new Vector(); + + Enumeration e = _breakpoints.elements(); + while( e.hasMoreElements() ) + { + Breakpoint bp = (Breakpoint) e.nextElement(); + if( url.equals(bp.getURL()) ) + vret.addElement(bp); + } + return vret; + } + + + public Object[] getAllBreakpoints() + { + return _breakpoints.elementsArray(); + } + + public Object[] getAllScripts() + { + int count = _scripts.count(); + if( 0 == count ) + return null; + Object[] a = new Object[count]; + + // we reverse the list so that newest scripts are first + + for( int i = count-1; i >= 0; i-- ) + a[count-(i+1)] = _scripts.elementAt(i); + return a; + } + + public Vector getScriptsVectorForURL(String url) + { + Vector vret = new Vector(); + + // we reverse the list so that newest scripts are first + + int count = _scripts.count(); + for( int i = count-1; i >= 0; i-- ) + { + Script script = (Script) _scripts.elementAt(i); + if( url.equals(script.getURL()) ) + vret.addElement(script); + } + return vret; + } + + public Object[] getScriptsForURL(String url) + { + return getScriptsVectorForURL(url).elementArray(); + } + + public void modifiedBreakpoint( Breakpoint bp ) + { + _notifyObservers(BreakpointTyrantUpdate.MODIFIED_ONE, bp); + } + + /*******************************/ + + private boolean _isNonShadowedLocationInScript(Location loc, Script script) + { + if( ! _isLocationInScript(loc, script) ) + return false; + + if( null != script.getFunction() ) + return true; + + boolean oursSeen = false; + int count = _scripts.count(); + // we reverse the list so that newest scripts are first + for( int i = count-1; i >= 0; i-- ) + { + Script scriptCur = (Script) _scripts.elementAt(i); + if( script.equals(scriptCur) ) + { + oursSeen = true; + continue; + } + if( ! oursSeen ) + continue; + + if( _isLocationInScript(loc, scriptCur) ) + { + if( null != scriptCur.getFunction() ) + return false; + return true; + } + } + return true; + } + + private boolean _isLocationInScript(Location loc, Script script) + { + if( ! loc.getURL().equals(script.getURL()) ) + return false; + + int line = loc.getLine(); + ScriptSection[] sections = script.getSections(); + for( int i = 0; i < sections.length; i++ ) + { + int base = sections[i].getBaseLineNumber(); + int extent = sections[i].getLineExtent(); + if( line >= base && line < base+extent ) + return true; + } + return false; + } + + private Script _getNewestScriptForLocation( Location loc ) + { + Script scriptTopLevel = null; + Script scriptBest = null; + + int count = _scripts.count(); + for( int i = count-1; i >= 0; i-- ) + { + Script script = (Script) _scripts.elementAt(i); + if( _isLocationInScript(loc, script) ) + { + if( null != script.getFunction() ) + scriptBest = script; + else if( null != scriptTopLevel ) + break; + else + scriptBest = scriptTopLevel = script; + } + } + return scriptBest; + } + + // 'script' can be null + private Location _getBestBPLocationForLocation(Location loc, Script script) + { + if( null == script ) + script = _getNewestScriptForLocation(loc); + + if( null == script ) + return loc; + + JSPC pc = script.getClosestPC(loc.getLine()); + if( null == pc ) + return loc; + + JSSourceLocation sloc = (JSSourceLocation) pc.getSourceLocation(); + if( null == sloc ) + return loc; + + if( sloc.getLine() == loc.getLine() ) + return loc; + + return new Location( loc.getURL(), sloc.getLine() ); + } + + private synchronized void _setHooksForBP(Breakpoint bp) + { + PrivilegeManager.enablePrivilege("Debugger"); + Location loc = bp.getLocation(); + boolean setAny = false; + + int count = _scripts.count(); + for( int i = 0; i < count; i++ ) + { + Script script = (Script) _scripts.elementAt(i); + if( ! _isNonShadowedLocationInScript(loc, script) ) + continue; + + JSPC pc = script.getClosestPC(bp.getLine()); +// if(ASS)ER.T(null==pc,"null returned from script.getClosestPC",this); + if( null == pc ) + continue; + + // generate a hook (doublelinked to BP) + BreakpointHook hook = new BreakpointHook(_emperor,pc,_controlTyrant,bp); + bp.putHook(script, hook); + + // set hook (with chaining) + hook.setNextHook( _dc.setInstructionHook(hook.getPC(),hook) ); + setAny = true; + } + if( setAny ) + _notifyObservers(BreakpointTyrantUpdate.ACTIVATED_ONE, bp); + } + + private synchronized void _clearHooksForBP(Breakpoint bp) + { + boolean clearedAny = false; + + Hashtable hookTable = bp.getHooks(); + Enumeration e = hookTable.elements(); + while( e.hasMoreElements() ) + { + BreakpointHook hook = (BreakpointHook) e.nextElement(); + + // somewhat dubious chaining... + PrivilegeManager.enablePrivilege("Debugger"); + _dc.setInstructionHook(hook.getPC(), hook.getNextHook()); + hook.setTyrant(null); + hook.setBreakpoint(null); + clearedAny = true; + } + hookTable.clear(); + + if( clearedAny ) + _notifyObservers(BreakpointTyrantUpdate.DEACTIVATED_ONE, bp); + } + + private Vector _getBreakpointsForScript(Script script) + { + Vector vret = new Vector(); + + Enumeration e = _breakpoints.elements(); + while( e.hasMoreElements() ) + { + Breakpoint bp = (Breakpoint) e.nextElement(); + if( _isNonShadowedLocationInScript(bp.getLocation(), script) ) + vret.addElement(bp); + } + return vret; + } + + private synchronized void _setHooksForScript(Script script) + { + PrivilegeManager.enablePrivilege("Debugger"); + Vector vec = _getBreakpointsForScript(script); + + int count = vec.count(); + if( 0 == count ) + return; + + for( int i = 0; i < count; i++ ) + { + Breakpoint bp = (Breakpoint) vec.elementAt(i); + + JSPC pc = script.getClosestPC(bp.getLine()); +// if(ASS)ER.T(null==pc,"null returned from script.getClosestPC",this); + if( null == pc ) + continue; + + // generate a hook (doublelinked to BP) + BreakpointHook hook = new BreakpointHook(_emperor,pc,_controlTyrant,bp); + bp.putHook(script, hook); + // set hook (with chaining) + hook.setNextHook( _dc.setInstructionHook(hook.getPC(),hook) ); + + // this is called on native thread, can not do notify!!! +// _notifyObservers(BreakpointTyrantUpdate.ACTIVATED_ONE, bp); + } + } + + private synchronized void _clearHooksForScript(Script script) + { + Vector vec = _getBreakpointsForScript(script); + + int count = vec.count(); + if( 0 == count ) + return; + + for( int i = 0; i < count; i++ ) + { + Breakpoint bp = (Breakpoint) vec.elementAt(i); + BreakpointHook hook = (BreakpointHook) bp.getHook(script); + if( null == hook ) + continue; + // somewhat dubious chaining... + PrivilegeManager.enablePrivilege("Debugger"); + _dc.setInstructionHook(hook.getPC(), hook.getNextHook()); + + hook.setTyrant(null); + hook.setBreakpoint(null); + bp.removeHook(script); + + // this is called on native thread, can not do notify!!! +// _notifyObservers(BreakpointTyrantUpdate.DEACTIVATED_ONE, bp); + } + } + + // implement observer interface + public void update(Observable o, Object arg) + { + if( o == _controlTyrant ) + { + int type = ((ControlTyrantUpdate)arg).type; + if( ControlTyrantUpdate.DEBUGGER_DISABLED == type ) + { + _enabled = false; + removeAllBreakpoints(); + } + } + } + + // helper + private void _notifyObservers( int type, Breakpoint bp ) + { + if(ASS)ER.T(Thread.currentThread()==_uiThreadForAssertCheck,"_notifyObservers called on thread other than UI thread",this); + setChanged(); + notifyObservers( new BreakpointTyrantUpdate(type,bp) ); + } + + // these are called by our script hook + public void justLoadedScript(Script script) + { +// if(ASS)System.out.println( "loaded script: " + script ); + if( ! _enabled ) + return; + if( ! script.isValid() ) + return; + + synchronized(this) + { + // add to the table of scripts + _scripts.addElement(script); + _setHooksForScript(script); + } + } + public void aboutToUnloadScript(Script script) + { +// if(ASS)System.out.println( "unloaded script: " + script ); + if( ! _enabled ) + return; + synchronized(this) + { + _scripts.removeElement(script); + _clearHooksForScript(script); + } + } + + // implement PrefsSupport interface + public void prefsWrite(Archiver archiver) throws CodingException + { + BreakpointSaver bs = new BreakpointSaver(); + bs.getFromTyrant(this); + archiver.archiveRootObject(bs); + } + public void prefsRead(Unarchiver unarchiver) throws CodingException + { + int id = Util.RootIdentifierForClassName(unarchiver.archive(), + "com.netscape.jsdebugging.ifcui.BreakpointSaver" ); + if( -1 != id ) + { + BreakpointSaver bs = (BreakpointSaver) + unarchiver.unarchiveIdentifier(id); + bs.sendToTyrant(this); + } + } + + + // data... + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + private DebugController _dc; + + private Hashtable _breakpoints; + private Vector _scripts; + + private BPTyrantScriptHook _scriptHook; + private boolean _enabled = false; + private Thread _uiThreadForAssertCheck = null; + + private static final boolean ASS = true; // enable ASSERT support? +} + +// used here only... +class BPTyrantScriptHook + extends ScriptHook + implements ChainableHook +{ + public BPTyrantScriptHook(BreakpointTyrant bpTyrant) + { + setTyrant(bpTyrant); + } + + public void justLoadedScript(Script script) + { + // for safety we make sure not to throw anything at native caller. + try { + if( null != _bpTyrant ) + _bpTyrant.justLoadedScript(script); + if( null != _nextHook ) + _nextHook.justLoadedScript(script); + } catch(Throwable t){} // eat it. + } + + public void aboutToUnloadScript(Script script) + { + // for safety we make sure not to throw anything at native caller. + try { + if( null != _bpTyrant ) + _bpTyrant.aboutToUnloadScript(script); + if( null != _nextHook ) + _nextHook.aboutToUnloadScript(script); + } catch(Throwable t){} // eat it. + } + + // implement ChainableHook + public void setTyrant(Object tyrant) {_bpTyrant = (BreakpointTyrant) tyrant;} + public void setNextHook(Hook nextHook) {_nextHook = (ScriptHook) nextHook;} + + private BreakpointTyrant _bpTyrant; + private ScriptHook _nextHook; + +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointTyrantUpdate.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointTyrantUpdate.java new file mode 100644 index 00000000000..f6e1e76dc5b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointTyrantUpdate.java @@ -0,0 +1,47 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.api.*; + +class BreakpointTyrantUpdate +{ + public static final int ADD_ONE = 0; + public static final int REMOVE_ONE = 1; + public static final int REMOVE_ALL = 2; + public static final int REMOVE_ALL_FOR_URL = 3; + public static final int REFRESH_ALL = 4; + public static final int ACTIVATED_ONE = 5; // these not always called + public static final int DEACTIVATED_ONE = 6; // these not always called + public static final int MODIFIED_ONE = 7; + + public BreakpointTyrantUpdate( int type, Breakpoint bp ) + { + this.type = type; + this.bp = bp; + } + + public int type; + public Breakpoint bp; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointView.java new file mode 100644 index 00000000000..95b4c45ba95 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BreakpointView.java @@ -0,0 +1,380 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; + +public class BreakpointView + extends InternalWindow + implements Observer, Target +{ + private static final int _buttonWidth = 70; + private static final int _buttonHeight = 24; + private static final int _buttonYSpace = 5; + private static final int _buttonXSpace = 5; + + private int _nextButtonX; + private int _nextButtonY; + + public BreakpointView( Emperor emperor, Rect rect ) + { + super(rect); + + _emperor = emperor; + _breakpointTyrant = emperor.getBreakpointTyrant(); + _commandTyrant = emperor.getCommandTyrant(); + + if(ASS)ER.T(null!=_breakpointTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_commandTyrant,"emperor init order problem", this); + + _breakpointTyrant.addObserver(this); + + _listview = new BackgroundHackListView(); + + Size size = contentSize(); + int listwidth = size.width - (_buttonWidth + (_buttonXSpace * 2)); + Rect rectSG = new Rect(0, 0, listwidth, size.height); + + _nextButtonX = listwidth + _buttonXSpace; + _nextButtonY = _buttonYSpace; + + _addButton( "New", NEW_CMD ); + _addButton( "Edit", EDIT_CMD); + _addButton( "Delete", DEL_CMD ); + _nextButtonY += _buttonYSpace * 2; + _addButton( "Done", DONE_CMD); + + ScrollGroup sg = new ScrollGroup(rectSG); + sg.setHorizScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg.setVertScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg.setContentView( _listview ); + sg.setAutoResizeSubviews(true); + sg.contentView().setLayoutManager( new MarginLayout() ); + sg.setBackgroundColor(_emperor.getBackgroundColor()); + + setCloseable( false ); + setResizable( false ); + setTitle( "Breakpoints" ); + addSubview(sg); + setAutoResizeSubviews(true); + + _listview.setAllowsEmptySelection(false); + _listview.setAllowsMultipleSelection(false); + + _listview.setTarget(this); + _listview.setCommand(""); + _listview.setDoubleCommand(EDIT_CMD); + + _listview.setBackgroundColor(_emperor.getBackgroundColor()); + + setLayer(InternalWindow.PALETTE_LAYER); + + refresh(); + + layoutView(1,1); + layoutView(-1,-1); + } + + private Button _addButton( String title, String cmd ) + { + Button button = new Button(_nextButtonX,_nextButtonY, + _buttonWidth,_buttonHeight); + button.setTitle(title); + button.setTarget(this); + button.setCommand(cmd); + addSubview(button); + _nextButtonY += _buttonHeight + _buttonYSpace; + return button; + } + + // implement observer interface + public void update(Observable o, Object arg) + { + if ( o == _breakpointTyrant ) + { + // always refresh if visible... + if( isVisible() ) + refresh(); + } + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(NEW_CMD ) ) + { + newBreakpoint(); + } + else if( cmd.equals(EDIT_CMD) ) + { + int index = _listview.selectedIndex(); + if( -1 == index ) + return; + + Breakpoint bp = (Breakpoint) _listview.selectedItem().data(); + if( null == bp ) + return; + + editBreakpoint(bp); + } + else if( cmd.equals(DEL_CMD ) ) + { + int index = _listview.selectedIndex(); + if( index < 0 ) + return; + + Breakpoint bp = (Breakpoint)_listview.itemAt(index).data(); + + _breakpointTyrant.removeBreakpoint(bp); + // will be refreshed upon notification from _breakpointTyrant + } + else if( cmd.equals(DONE_CMD) ) + { + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.BREAKPOINTS_SHOW_HIDE), + this ); + } + } + + public synchronized void refresh() + { + int i; + + Breakpoint selBP = null; + ListItem selItem = _listview.selectedItem(); + if( null != selItem ) + selBP = (Breakpoint) selItem.data(); + + _listview.removeAllItems(); + + Font linefont = _emperor.getFixedFont(); + int maxlinelen = 0; + + int itemCount; + Object[] raw = _breakpointTyrant.getAllBreakpoints(); + if( null == raw || 0 == (itemCount = raw.length) ) + return; + + // create a sorted list + + Vector breakpoints = new Vector(itemCount); + for( i = 0; i < itemCount; i++ ) + breakpoints.insertElementAt(raw[i],i); + + breakpoints.sort(true); + + // find the max lengths for later formating of each item + + int maxLineno = 0; + int maxFilenameChars = 0; + + for( i = 0; i < itemCount; i++ ) + { + Breakpoint bp = (Breakpoint) breakpoints.elementAt(i); + maxLineno = Math.max(maxLineno,bp.getLine()); + maxFilenameChars = Math.max(maxFilenameChars,bp.getURL().length()); + } + int maxStrLenForNum = new Integer(maxLineno).toString().length(); + + StringBuffer buf = new StringBuffer(); + + // add each item + for( i = 0; i < itemCount; i++ ) + { + Breakpoint bp = (Breakpoint) breakpoints.elementAt(i); + + // format text... + + buf.setLength(0); + + // padded line number + int lineno = bp.getLine(); + buf.append(lineno); + + int pad = maxStrLenForNum - new Integer(lineno).toString().length(); + while( pad-- > 0 ) + buf.insert(0,' '); + + // padded filename + buf.append(", "); + buf.append(bp.getURL()); + for( int k = bp.getURL().length()-1; k >= maxFilenameChars; k-- ) + buf.append(' '); + + if( null != bp.getBreakCondition() ) + { + buf.append(", "); + buf.append(bp.getBreakCondition()); + } + + ListItem item = new ListItem(); + String text = new String(buf); + +// System.out.println("item number " + i); +// System.out.println(buf); +// System.out.println(text); + + maxlinelen = Math.max( maxlinelen, text.length() ); + item.setTitle( text ); + item.setData( bp ); + item.setFont( linefont ); + item.setSelectedColor(_emperor.getSelectionColor()); + _listview.addItem( item ); + + if( 0 == i ) + _listview.selectItemAt(i); // make sure SOMETHING selected + + if( null != selBP && selBP == bp ) + { + _listview.selectItemAt(i); + selBP = null; // we only want the first match... + } + } + + FontMetrics fm = linefont.fontMetrics(); + _listview.setBounds( 0, 0, (maxlinelen+1) * fm.charWidth('X'),0 ); + _listview.sizeToMinSize(); + + layoutView(0,0); + _listview.draw(); + } + + // from original code... + + public boolean newBreakpoint() + { + BreakpointEditorDialog bed = + new BreakpointEditorDialog( "New Breakpoint", + 1, "", "true", + _emperor.getFixedFont(), + true ); + bed.showModally(); + if( bed.okPressed() ) + { + // create a new BP + Breakpoint bp; + Location loc = new Location( bed.getURL(), bed.getLine() ); + + String condition = bed.getCondition(); + if( null != condition ) + condition = condition.trim(); + if( 0 == condition.length() || condition.equals("true") ) + condition = null; + + bp = _breakpointTyrant.findBreakpoint(loc); + if( null == bp ) + bp = _breakpointTyrant.addBreakpoint(loc); + + bp.setBreakCondition(condition); + + _breakpointTyrant.modifiedBreakpoint(bp); + + // select the new item + int i = _indexOfListItemWithBP(bp); + if( -1 != i ) + _listview.selectItemAt(i); + return true; + } + return false; + + } + + public boolean editBreakpoint( Breakpoint bp ) + { + if(ASS)ER.T(null!=bp,"null Breakpoint", this); + + String condition = bp.getBreakCondition(); + if( null == condition ) + condition = "true"; + + BreakpointEditorDialog bed = + new BreakpointEditorDialog( "Edit Breakpoint", + bp.getLine(), + bp.getURL(), + condition, + _emperor.getFixedFont(), + false ); + bed.showModally(); + if( bed.okPressed() ) + { + // what changed? + + condition = bed.getCondition(); + if( null != condition ) + condition = condition.trim(); + if( 0 == condition.length() || condition.equals("true") ) + condition = null; + + if( ! bed.getURL().equals(bp.getURL()) || + bed.getLine() != bp.getLine() ) + { + // we need to construct a new breakpoint! + _breakpointTyrant.removeBreakpoint(bp); + Location loc = new Location( bed.getURL(), bed.getLine() ); + bp = _breakpointTyrant.addBreakpoint(loc); + } + + bp.setBreakCondition(condition); + _breakpointTyrant.modifiedBreakpoint(bp); + + // select the new item + int i = _indexOfListItemWithBP(bp); + if( -1 != i ) + _listview.selectItemAt(i); + return true; + } + return false; + } + + private int _indexOfListItemWithBP( Breakpoint bp ) + { + for( int i = _listview.count()-1; i >= 0; i-- ) + { + if( ((Breakpoint) _listview.itemAt(i).data()) == bp ) + return i; + } + // failed to find it... + return -1; + } + + + private Emperor _emperor; + private BreakpointTyrant _breakpointTyrant; + private CommandTyrant _commandTyrant; + private ListView _listview; + + private static final String NEW_CMD = "NEW_CMD"; + private static final String EDIT_CMD = "EDIT_CMD"; + private static final String DEL_CMD = "DEL_CMD"; + private static final String DONE_CMD = "DONE_CMD"; + + private static final boolean ASS = true; // enable ASSERT support? +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BuildDate.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BuildDate.java new file mode 100644 index 00000000000..47e440a5534 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/BuildDate.java @@ -0,0 +1,21 @@ + +// generated automatically by gen_date.awk + +package com.netscape.jsdebugging.ifcui; + +class BuildDate +{ + // Tuesday, September 15, 1998 at 12:00 PM + + public static final long buildDate = 905886043000L; + + public static final java.util.Date date() + { + return new java.util.Date(buildDate); + } + + public static final String display() + { + return date().toString(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CallChain.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CallChain.java new file mode 100644 index 00000000000..ba2a762ab67 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CallChain.java @@ -0,0 +1,86 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.api.*; + +// I may regret this later, but I'm just going to store an array of Scripts. + +class CallChain +{ + // compare return codes + + public static final int EQUAL = 0; + public static final int CALLER = 1; + public static final int CALLEE = 2; + public static final int DISJOINT = 3; + + public CallChain( JSThreadState threadState ) + { + try + { + StackFrameInfo[] infoarray = threadState.getStack(); + if( null == infoarray || 0 == infoarray.length ) + return; + + int count = infoarray.length; + _chain = new Script[count]; + + for( int i = 0; i < count; i++ ) + _chain[i] = ((JSPC)(infoarray[i].getPC())).getScript(); + } + catch( InvalidInfoException e ) + { + _chain = null; + return; + } + } + + public int compare( CallChain other ) + { + if( this == other ) + return EQUAL; + if( null == _chain || null == other || null == other._chain ) + return DISJOINT; + + int count = _chain.length; + int other_count = other._chain.length; + if( 0 == count || 0 == other_count ) + return DISJOINT; + + int lesser_count = Math.min( count, other_count ); + int i; + for( i = 0; i < lesser_count; i++ ) + { + if( ! _chain[i].equals(other._chain[i]) ) + return DISJOINT; + } + if( count > other_count ) + return CALLER; + if( count < other_count ) + return CALLEE; + return EQUAL; + } + + private Script[] _chain; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ChainableHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ChainableHook.java new file mode 100644 index 00000000000..f3ceeadbbe7 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ChainableHook.java @@ -0,0 +1,32 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.api.*; + +interface ChainableHook +{ + public void setTyrant( Object tyrant); + public void setNextHook(Hook nextHook); +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CmdState.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CmdState.java new file mode 100644 index 00000000000..3ad4e607486 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CmdState.java @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +class CmdState +{ + public CmdState( int id, + String name, + boolean enabled, + boolean checked ) + { + this.id = id; + this.name = name; + this.enabled = enabled; + this.checked = checked; + } + public int id; + public String name; + public boolean enabled; + public boolean checked; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CommandTyrant.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CommandTyrant.java new file mode 100644 index 00000000000..598fef12404 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CommandTyrant.java @@ -0,0 +1,743 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.security.PrivilegeManager; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.PopupButton; +import com.netscape.jsdebugging.api.*; + +public class CommandTyrant + extends Observable + implements Observer, Target +{ + // this list of ids must start with 0 and be contiguous and have count set + // ............................................ + public static final int RUN = 0; + public static final int ABORT = 1; + public static final int STEP_OVER = 2; + public static final int STEP_INTO = 3; + public static final int STEP_OUT = 4; + public static final int INTERRUPT = 5; + public static final int PAGELIST_CLICK = 6; + public static final int PAGELIST_DBLCLICK = 7; + public static final int PAGELIST_SHOW_HIDE = 8; + public static final int REFRESH_ALL = 9; + public static final int STACKVIEW_CLICK = 10; + public static final int STACKVIEW_DBLCLICK = 11; + public static final int EVAL_STRING = 12; + public static final int EVAL_SEL_STRING = 13; + public static final int SHOW_LINE_NUMBERS = 14; + public static final int TOGGLE_BREAKPOINT = 15; + public static final int COPY = 16; + public static final int PASTE = 17; + public static final int WATCHES_SHOW_HIDE = 18; + public static final int COPY_TO_WATCH = 19; + public static final int EDIT_BREAKPOINT = 20; + public static final int BREAKPOINTS_SHOW_HIDE = 21; + public static final int INSPECTOR_SHOW_HIDE = 22; + public static final int INSPECT_SEL_STRING = 23; + public static final int WATCH_STRING = 24; + public static final int CLEAR_CONSOLE = 25; + public static final int COPY_STRING = 26; + public static final int CUT = 27; + public static final int TEST = 28; + // XXX add the rest... + public static final int CMD_COUNT = 29; // just a count of the above + // ............................................ + + private void _initCmdStates() + { + // initialize the cmdStatesArray + int i; + _cmdStatesArray = new CmdState[CMD_COUNT]; + for( i = 0; i < CMD_COUNT; i++ ) + _cmdStatesArray[i] = new CmdState(i,null,true,false); + + // add the names + // these must match the full list above + // ............................................ + _cmdStatesArray[RUN ].name = "RUN"; + _cmdStatesArray[ABORT ].name = "ABORT"; + _cmdStatesArray[STEP_OVER ].name = "STEP_OVER"; + _cmdStatesArray[STEP_INTO ].name = "STEP_INTO"; + _cmdStatesArray[STEP_OUT ].name = "STEP_OUT"; + _cmdStatesArray[INTERRUPT ].name = "INTERRUPT"; + _cmdStatesArray[PAGELIST_CLICK ].name = "PAGELIST_CLICK"; + _cmdStatesArray[PAGELIST_DBLCLICK ].name = "PAGELIST_DBLCLICK"; + _cmdStatesArray[PAGELIST_SHOW_HIDE ].name = "PAGELIST_SHOW_HIDE"; + _cmdStatesArray[REFRESH_ALL ].name = "REFRESH_ALL"; + _cmdStatesArray[STACKVIEW_CLICK ].name = "STACKVIEW_CLICK"; + _cmdStatesArray[STACKVIEW_DBLCLICK ].name = "STACKVIEW_DBLCLICK"; + _cmdStatesArray[EVAL_STRING ].name = "EVAL_STRING"; + _cmdStatesArray[EVAL_SEL_STRING ].name = "EVAL_SEL_STRING"; + _cmdStatesArray[SHOW_LINE_NUMBERS ].name = "SHOW_LINE_NUMBERS"; + _cmdStatesArray[TOGGLE_BREAKPOINT ].name = "TOGGLE_BREAKPOINT"; + _cmdStatesArray[COPY ].name = "COPY"; + _cmdStatesArray[PASTE ].name = "PASTE"; + _cmdStatesArray[WATCHES_SHOW_HIDE ].name = "WATCHES_SHOW_HIDE"; + _cmdStatesArray[COPY_TO_WATCH ].name = "COPY_TO_WATCH"; + _cmdStatesArray[EDIT_BREAKPOINT ].name = "EDIT_BREAKPOINT"; + _cmdStatesArray[BREAKPOINTS_SHOW_HIDE ].name = "BREAKPOINTS_SHOW_HIDE"; + _cmdStatesArray[INSPECTOR_SHOW_HIDE ].name = "INSPECTOR_SHOW_HIDE"; + _cmdStatesArray[INSPECT_SEL_STRING ].name = "INSPECT_SEL_STRING"; + _cmdStatesArray[WATCH_STRING ].name = "WATCH_STRING"; + _cmdStatesArray[CLEAR_CONSOLE ].name = "CLEAR_CONSOLE"; + _cmdStatesArray[COPY_STRING ].name = "COPY_STRING"; + _cmdStatesArray[CUT ].name = "CUT"; + _cmdStatesArray[TEST ].name = "TEST"; + +// _cmdStatesArray[].name = ""; + // XXX add the rest... + // ............................................ + + // check in debugging build only... + if(ASS) + { + for( i = 0; i < CMD_COUNT; i++ ) + if(ASS)ER.T(null!=_cmdStatesArray[i].name, "name not set for cmdstate number " + i, this); + } + + // build the hashtable + _cmdStatesHashtable = new Hashtable(CMD_COUNT); + for( i = 0; i < CMD_COUNT; i++ ) + _cmdStatesHashtable.put(_cmdStatesArray[i].name,_cmdStatesArray[i]); + + } + + public void refreshCmdStatesAndNotifyObservers() + { + refreshCmdStates(); + _notify(); + } + + public void refreshCmdStates() + { + _getViewsFromEmperor(); + + boolean running = _controlTyrant.getState() == ControlTyrant.RUNNING; + + if( running ) + { + _cmdStatesArray[RUN ].enabled = false; + _cmdStatesArray[ABORT ].enabled = false; + _cmdStatesArray[STEP_OVER ].enabled = false; + _cmdStatesArray[STEP_INTO ].enabled = false; + _cmdStatesArray[STEP_OUT ].enabled = false; + _cmdStatesArray[EVAL_STRING ].enabled = false; + _cmdStatesArray[EVAL_SEL_STRING ].enabled = false; + _cmdStatesArray[INSPECT_SEL_STRING ].enabled = false; + _cmdStatesArray[WATCH_STRING ].enabled = false; + _cmdStatesArray[TEST ].enabled = false; + } + else + { + _cmdStatesArray[RUN ].enabled = true; + _cmdStatesArray[ABORT ].enabled = true; + _cmdStatesArray[STEP_OVER ].enabled = true; + _cmdStatesArray[STEP_INTO ].enabled = true; + _cmdStatesArray[STEP_OUT ].enabled = true; + _cmdStatesArray[EVAL_STRING ].enabled = true; + _cmdStatesArray[WATCH_STRING ].enabled = true; + _cmdStatesArray[TEST ].enabled = true; + if( null != _sourceTyrant && null != _sourceTyrant.getSelectedText()) + { + _cmdStatesArray[EVAL_SEL_STRING ].enabled = true; + _cmdStatesArray[INSPECT_SEL_STRING ].enabled = true; + } + else + { + _cmdStatesArray[EVAL_SEL_STRING ].enabled = false; + _cmdStatesArray[INSPECT_SEL_STRING ].enabled = false; + } + } + if( _controlTyrant.getInterrupt() ) + _cmdStatesArray[INTERRUPT ].checked = true; + else + _cmdStatesArray[INTERRUPT ].checked = false; + + if( null == _pageListView || ! _pageListView.isVisible() ) + _cmdStatesArray[PAGELIST_SHOW_HIDE ].checked = false; + else + _cmdStatesArray[PAGELIST_SHOW_HIDE ].checked = true; + + if( null == _watchView || ! _watchView.isVisible() ) + _cmdStatesArray[WATCHES_SHOW_HIDE ].checked = false; + else + _cmdStatesArray[WATCHES_SHOW_HIDE ].checked = true; + + if( null == _breakpointView || ! _breakpointView.isVisible() ) + _cmdStatesArray[BREAKPOINTS_SHOW_HIDE ].checked = false; + else + _cmdStatesArray[BREAKPOINTS_SHOW_HIDE ].checked = true; + + if( null == _inspectorView || ! _inspectorView.isVisible() ) + _cmdStatesArray[INSPECTOR_SHOW_HIDE ].checked = false; + else + _cmdStatesArray[INSPECTOR_SHOW_HIDE ].checked = true; + + if( null == _sourceViewManager || ! _sourceViewManager.getShowLineNumbers() ) + _cmdStatesArray[SHOW_LINE_NUMBERS ].checked = false; + else + _cmdStatesArray[SHOW_LINE_NUMBERS ].checked = true; + + SourceTextItem item; + String selURL; + int selLine; + if( null == _breakpointTyrant || + null == _sourceTyrant || + null == (selURL = _sourceTyrant.getUrlOfSelectedLine()) || + 0 == (selLine = _sourceTyrant.getLineNumberOfSelectedLine()) || + null == (item = _sourceTyrant.findSourceItem(selURL)) ) + { + _cmdStatesArray[TOGGLE_BREAKPOINT ].enabled = false; + _cmdStatesArray[TOGGLE_BREAKPOINT ].checked = false; + _cmdStatesArray[EDIT_BREAKPOINT ].enabled = false; + } + else + { + _cmdStatesArray[TOGGLE_BREAKPOINT ].enabled = true; + + int sysline = _sourceTyrant.userLine2SystemLine(item,selLine); + if( null != _breakpointTyrant.findBreakpoint( new Location(selURL,sysline) ) ) + { + _cmdStatesArray[TOGGLE_BREAKPOINT ].checked = true; + _cmdStatesArray[EDIT_BREAKPOINT ].enabled = true; + } + else + { + _cmdStatesArray[TOGGLE_BREAKPOINT ].checked = false; + _cmdStatesArray[EDIT_BREAKPOINT ].enabled = false; + } + } + + if( null == _consoleView || + null == _inspectorView || + null == _sourceTyrant ) + { + _cmdStatesArray[COPY].enabled = false; + _cmdStatesArray[COPY_TO_WATCH].enabled = false; + _cmdStatesArray[PASTE].enabled = false; + _cmdStatesArray[CUT].enabled = false; + } + else + { + if( null != _sourceTyrant.getSelectedText() || + _inspectorView.canCopy() || + _consoleView.canCopy() ) + { + _cmdStatesArray[COPY].enabled = true; + _cmdStatesArray[COPY_TO_WATCH].enabled = true; + } + else + { + _cmdStatesArray[COPY].enabled = false; + _cmdStatesArray[COPY_TO_WATCH].enabled = false; + } + + if( _inspectorView.canCopy() || _consoleView.canCopy() ) + _cmdStatesArray[CUT].enabled = true; + else + _cmdStatesArray[CUT].enabled = false; + + if( _consoleView.canPaste() || _inspectorView.canPaste() ) + _cmdStatesArray[PASTE].enabled = true; + else + _cmdStatesArray[PASTE].enabled = false; + } + } + + public CommandTyrant(Emperor emperor) + { + _app = Application.application(); + _emperor = emperor; + + _controlTyrant = emperor.getControlTyrant (); + _breakpointTyrant = emperor.getBreakpointTyrant(); + _sourceTyrant = emperor.getSourceTyrant (); + _stackTyrant = emperor.getStackTyrant (); + _watchTyrant = emperor.getWatchTyrant (); + _consoleTyrant = emperor.getConsoleTyrant (); + _inspectorTyrant = emperor.getInspectorTyrant (); + + // figure out if native clipboard is supported... + try + { + Class.forName("java.awt.datatransfer.Clipboard"); + Class.forName("netscape.application.jdk11compatibility.JDKClipboard"); +// if(ASS)System.out.println( "using native clipboard"); + } + catch(Exception e) + { + _usingLocalClipboard = true; +// if(ASS)System.out.println( "using local clipboard"); + } + + + if(ASS)ER.T(null!=_controlTyrant ,"emperor init order problem", this); + if(ASS)ER.T(null!=_breakpointTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_sourceTyrant ,"emperor init order problem", this); + if(ASS)ER.T(null!=_stackTyrant ,"emperor init order problem", this); + if(ASS)ER.T(null!=_watchTyrant ,"emperor init order problem", this); + if(ASS)ER.T(null!=_consoleTyrant ,"emperor init order problem", this); + if(ASS)ER.T(null!=_inspectorTyrant ,"emperor init order problem", this); + + _controlTyrant.addObserver(this); + _sourceTyrant.addObserver(this); + _breakpointTyrant.addObserver(this); + + _initCmdStates(); + refreshCmdStates(); + } + + public CmdState findCmdState(int id) {return _cmdStatesArray[id];} + public CmdState findCmdState(String name){return (CmdState)_cmdStatesHashtable.get(name);} + + public String cmdString(int id) {return _cmdStatesArray[id].name;} + public int cmdID(String name) {return ((CmdState)_cmdStatesHashtable.get(name)).id;} + + // implement observer interface + public void update(Observable o, Object arg) + { + refreshCmdStatesAndNotifyObservers(); + } + + private void _notify() + { + setChanged(); + notifyObservers(null); + } + + + // implement target interface + public void performCommand(String cmd, Object data) + { + SourceTextItem item; + String selURL; + int selLine; + Location loc; + Breakpoint bp; + int sysline; + + _getViewsFromEmperor(); + + CmdState cmdState = findCmdState(cmd); + if( null == cmdState ) + { + if(ASS)ER.T( false, "failed to find cmdState named: " + cmd, this); + return; + } + switch(cmdState.id) + { + case RUN: + _controlTyrant.runit(); + break; + case ABORT: + _controlTyrant.abort(); + break; + case STEP_OVER: + _controlTyrant.stepOver(); + break; + case STEP_INTO: + _controlTyrant.stepInto(); + break; + case STEP_OUT : + _controlTyrant.stepOut(); + break; + case INTERRUPT: + if( null != _controlTyrant ) + _controlTyrant.interrupt(! _controlTyrant.getInterrupt()); + refreshCmdStatesAndNotifyObservers(); + break; + case PAGELIST_CLICK: + _updateSelectedPageListItem( (ListView)data ); + break; + case PAGELIST_DBLCLICK: + _updateSelectedPageListItem( (ListView)data ); + SourceTextItem sti = _sourceTyrant.getSelectedSourceItem(); + if( null != sti && null != _sourceViewManager ) + { + SourceView view = _sourceViewManager.findView(sti); + if( null != view ) + _sourceViewManager.activateView(view); + else + _sourceViewManager.createView(sti); + } + // fall through to hide the list... + // break; + case PAGELIST_SHOW_HIDE: + if( null == _pageListView ) + break; + if( _pageListView.isVisible() ) + _pageListView.hide(); + else + { + _sourceTyrant.refreshSourceTextItemVector(); + _pageListView.show(); + } + refreshCmdStatesAndNotifyObservers(); + break; + case REFRESH_ALL: + // XXX do other things... + _sourceTyrant.refreshSourceTextItemVector(); + break; + case STACKVIEW_CLICK: + _emperor.setWaitCursor(true); + _stackTyrant.setCurrentFrame( ((ListView)data).selectedIndex() ); + _emperor.setWaitCursor(false); + break; + case STACKVIEW_DBLCLICK: + // ignored + break; + case EVAL_STRING: + _emperor.setWaitCursor(true); + _consoleTyrant.eval((String)data); + _emperor.setWaitCursor(false); + break; + case EVAL_SEL_STRING: + if( null != _sourceTyrant && null != _sourceTyrant.getSelectedText()) + { + _emperor.setWaitCursor(true); + _consoleTyrant.eval(_sourceTyrant.getSelectedText()); + _emperor.setWaitCursor(false); + } + break; + case SHOW_LINE_NUMBERS: + if( null != _sourceViewManager ) + { + _emperor.setWaitCursor(true); + _sourceViewManager.setShowLineNumbers( ! _sourceViewManager.getShowLineNumbers() ); + _emperor.setWaitCursor(false); + } + refreshCmdStatesAndNotifyObservers(); + break; + case TOGGLE_BREAKPOINT: + if( null == _breakpointTyrant || + null == _sourceTyrant || + null == (selURL = _sourceTyrant.getUrlOfSelectedLine()) || + 0 == (selLine = _sourceTyrant.getLineNumberOfSelectedLine()) || + null == (item = _sourceTyrant.findSourceItem(selURL)) ) + { + break; + } + sysline = _sourceTyrant.userLine2SystemLine(item,selLine); + loc = new Location( selURL, sysline ); + bp = _breakpointTyrant.findBreakpoint(loc); + if( null == bp ) + _breakpointTyrant.addBreakpoint(loc); + else + _breakpointTyrant.removeBreakpoint(bp); + // redraw done on notification from BreakpointTyrant... + break; + case COPY: + String s = _getCopyText(); + if( null != s ) + { + _setClipboardContents(s); + refreshCmdStatesAndNotifyObservers(); + } + break; + case PASTE: + String contents = _getClipboardContents(); + if( null != contents ) + { + if( null != _inspectorView && _inspectorView.canPaste() ) + _inspectorView.paste(contents); + else if( null != _consoleView && _consoleView.canPaste() ) + _consoleView.paste(contents); + refreshCmdStatesAndNotifyObservers(); + } + break; + case WATCHES_SHOW_HIDE: + if( null == _watchView ) + break; + if( _watchView.isVisible() ) + _watchView.hide(); + else + { + _watchView.refresh(); + _watchView.show(); + } + refreshCmdStatesAndNotifyObservers(); + break; + case COPY_TO_WATCH: + String str = _getCopyText(); + if( null != str ) + { + _watchTyrant.addWatchString(str); + _watchTyrant.evalList(); + + if( null != _watchView ) + _watchView.refresh(); + + refreshCmdStatesAndNotifyObservers(); + } + break; + case EDIT_BREAKPOINT: + if( null == _breakpointView || + null == _breakpointTyrant || + null == _sourceTyrant || + null == (selURL = _sourceTyrant.getUrlOfSelectedLine()) || + 0 == (selLine = _sourceTyrant.getLineNumberOfSelectedLine()) || + null == (item = _sourceTyrant.findSourceItem(selURL)) ) + { + break; + } + sysline = _sourceTyrant.userLine2SystemLine(item,selLine); + loc = new Location( selURL, sysline ); + bp = _breakpointTyrant.findBreakpoint(loc); +// if( null == bp ) +// bp = _breakpointTyrant.addBreakpoint(loc); + if( null != bp ) + _breakpointView.editBreakpoint(bp); + // redraw done on notification from BreakpointTyrant... + break; + case BREAKPOINTS_SHOW_HIDE: + if( null == _breakpointView ) + break; + if( _breakpointView.isVisible() ) + _breakpointView.hide(); + else + { + _breakpointView.refresh(); + _breakpointView.show(); + } + refreshCmdStatesAndNotifyObservers(); + break; + case INSPECTOR_SHOW_HIDE: + if( null == _inspectorView ) + break; + if( _inspectorView.isVisible() ) + _inspectorView.hide(); + else + { + _inspectorView.refresh(); + _inspectorView.show(); + } + refreshCmdStatesAndNotifyObservers(); + break; + case INSPECT_SEL_STRING: + if( null != _sourceTyrant && null != _sourceTyrant.getSelectedText()) + { + _emperor.setWaitCursor(true); + _inspectorTyrant.setNewRootNode(_sourceTyrant.getSelectedText()); + _emperor.setWaitCursor(false); + } + InspectorView iView = _emperor.getInspectorView(); + if( null == _inspectorView ) + break; + if( ! _inspectorView.isVisible() ) + { + _inspectorView.refresh(); + _inspectorView.show(); + } + refreshCmdStatesAndNotifyObservers(); + break; + case WATCH_STRING: + if( null != data ) + { + _watchTyrant.addWatchString((String)data); + _watchTyrant.evalList(); + + if( null != _watchView ) + _watchView.refresh(); + + refreshCmdStatesAndNotifyObservers(); + } + break; + case CLEAR_CONSOLE: + if( null != _consoleView ) + _consoleView.clear(); + break; + case COPY_STRING: + if( null != data ) + { + _setClipboardContents((String)data); + refreshCmdStatesAndNotifyObservers(); + } + break; + case CUT: + String s2 = _getCutText(); + if( null != s2 ) + { + _setClipboardContents(s2); + refreshCmdStatesAndNotifyObservers(); + } + break; + case TEST: + Test.doTest(_emperor); + break; + default: + if(ASS)ER.T( false, "cmdState id not handled: " + cmdState.id, this); + break; + } + } + + private void _setClipboardContents(String s) + { + if( ! _usingLocalClipboard ) + { + try + { + PrivilegeManager.enablePrivilege("UniversalSystemClipboardAccess"); + _app.setClipboardText(s); + return; + } + catch(Exception e) + { + _usingLocalClipboard = true; +// if(ASS)System.out.println( "switching to use local clipboard"); + } + } + + _localClipboard = s; + } + private String _getClipboardContents() + { + if( ! _usingLocalClipboard ) + { + try + { + PrivilegeManager.enablePrivilege("UniversalSystemClipboardAccess"); + return _app.clipboardText(); + } + catch(Exception e) + { + _usingLocalClipboard = true; +// if(ASS)System.out.println( "switching to use local clipboard"); + } + } + return _localClipboard; + } + + private String _getCopyText() + { + String s = null; + + if( null != _sourceTyrant ) + s = _sourceTyrant.getSelectedText(); + if( null == s ) + { + if( null != _inspectorView && _inspectorView.canCopy() ) + s = _inspectorView.copy(); + else if( null != _consoleView && _consoleView.canCopy() ) + s = _consoleView.copy(); + } + return s; + } + + private String _getCutText() + { + String s = null; + + if( null != _inspectorView && _inspectorView.canCopy() ) + s = _inspectorView.cut(); + else if( null != _consoleView && _consoleView.canCopy() ) + s = _consoleView.cut(); + return s; + } + + private void _updateSelectedPageListItem( ListView listview ) + { + ListItem li = listview.selectedItem(); + if( null != li ) + { + SourceTextItem sti = PageListView.sourceTextItemForListItem(li); + _sourceTyrant.setSelectedSourceItem(sti); + } + else + _sourceTyrant.setSelectedSourceItem(null); + } + + private void _getViewsFromEmperor() + { + if( _haveAllViews ) + return; + + if( null == _pageListView ) + _pageListView = _emperor.getPageListView(); + if( null == _sourceViewManager ) + _sourceViewManager = _emperor.getSourceViewManager(); + if( null == _commandView ) + _commandView = _emperor.getCommandView(); + if( null == _stackView ) + _stackView = _emperor.getStackView(); + if( null == _consoleView ) + _consoleView = _emperor.getConsoleView(); + if( null == _watchView ) + _watchView = _emperor.getWatchView(); + if( null == _breakpointView ) + _breakpointView = _emperor.getBreakpointView(); + if( null == _inspectorView ) + _inspectorView = _emperor.getInspectorView(); + + _haveAllViews = + null != _pageListView && + null != _sourceViewManager && + null != _commandView && + null != _stackView && + null != _consoleView && + null != _watchView && + null != _breakpointView && + null != _inspectorView ; + } + + // data... + + private Application _app; + private Emperor _emperor; + private ControlTyrant _controlTyrant ; + private BreakpointTyrant _breakpointTyrant; + private SourceTyrant _sourceTyrant ; + private StackTyrant _stackTyrant ; + private WatchTyrant _watchTyrant ; + private ConsoleTyrant _consoleTyrant ; + private InspectorTyrant _inspectorTyrant ; + + + // if any views are added, then add them to _getViewsFromEmperor() + private boolean _haveAllViews = false; + private PageListView _pageListView ; + private SourceViewManager _sourceViewManager; + private CommandView _commandView ; + private StackView _stackView ; + private ConsoleView _consoleView ; + private WatchView _watchView ; + private BreakpointView _breakpointView ; + private InspectorView _inspectorView ; + + private String _localClipboard; + private boolean _usingLocalClipboard; + + private CmdState[] _cmdStatesArray; + private Hashtable _cmdStatesHashtable; + + private static final boolean ASS = true; // enable ASSERT support? +} + + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CommandView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CommandView.java new file mode 100644 index 00000000000..d77fa8b1348 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/CommandView.java @@ -0,0 +1,373 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.toolbar.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.toolTip.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.PopupButton; +import java.io.File; +// used internally... +class CmdViewItem +{ + public CmdViewItem(boolean enabled, boolean checked) + { + this.enabled = enabled; + this.checked = checked; + } + + public MenuItem menuItem; + public PopupButton button; + public boolean enabled; + public boolean checked; + public String checkedText; + public String uncheckedText; +} + +public class CommandView + implements Observer +{ + public CommandView( Emperor emperor, + Menu mainMenu, + MenuItem fileMenu, + int originY ) + { + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + _commandTyrant = emperor.getCommandTyrant(); + + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_commandTyrant,"emperor init order problem", this); + + _commandTyrant.addObserver(this); + + // init storage + + int count = CommandTyrant.CMD_COUNT; + _items = new CmdViewItem[count]; + for( int i = 0; i < count; i++ ) + { + CmdState state = _commandTyrant.findCmdState(i); + if(ASS)ER.T(null!=state,"invalid cmd state initing _items",this); + _items[i] = new CmdViewItem(state.enabled,state.checked); + } + + // set special text cases + + _items[CommandTyrant.SHOW_LINE_NUMBERS].checkedText = "Hide Line Numbers"; + _items[CommandTyrant.SHOW_LINE_NUMBERS].uncheckedText = "Show Line Numbers"; + + _items[CommandTyrant.PAGELIST_SHOW_HIDE].checkedText = "Hide Open Dialog"; + _items[CommandTyrant.PAGELIST_SHOW_HIDE].uncheckedText = "Open..."; + + _items[CommandTyrant.INTERRUPT].checkedText = "Clear Interrupt"; + _items[CommandTyrant.INTERRUPT].uncheckedText = "Set Interrupt"; + + _items[CommandTyrant.TOGGLE_BREAKPOINT].checkedText = "Clear Breakpoint"; + _items[CommandTyrant.TOGGLE_BREAKPOINT].uncheckedText = "Set Breakpoint"; + + _items[CommandTyrant.WATCHES_SHOW_HIDE].checkedText = "Hide Watches Dialog"; + _items[CommandTyrant.WATCHES_SHOW_HIDE].uncheckedText = "Watches..."; + + _items[CommandTyrant.BREAKPOINTS_SHOW_HIDE].checkedText = "Hide Breakpoints Dialog"; + _items[CommandTyrant.BREAKPOINTS_SHOW_HIDE].uncheckedText = "Breakpoints..."; + + _items[CommandTyrant.INSPECTOR_SHOW_HIDE].checkedText = "Hide Inspector"; + _items[CommandTyrant.INSPECTOR_SHOW_HIDE].uncheckedText = "Inspector..."; + + // create toolbar + _toolbarTray = new ToolbarTray(); + _mainToolbar = new Toolbar(); + +// _mainToolbar.setBackgroundImage("Nautical.gif"); + _mainToolbar.setBackgroundColor(Color.lightGray); + _mainToolbar.showLabels(true); + + addToolbarButtons(); + addMenuItems(mainMenu, fileMenu); + refreshAllStates(true); + + // size toolbar + + _toolbarTray.addToolbar(_mainToolbar); + _toolBarWindow = new InternalWindow(0,originY,0,0); + _toolBarWindow.setBuffered(true); + + _toolBarWindow.setType(Window.BLANK_TYPE); + MarginLayout layout = new MarginLayout(); + _toolBarWindow.contentView().setLayoutManager(layout); + _toolBarWindow.contentView().addSubview(_toolbarTray); + Size minSize = layout.minSize(_toolBarWindow.contentView()); + RootView rv = _emperor.getRootView(); + minSize = _toolBarWindow.windowSizeForContentSize(rv.width(), minSize.height); + _toolBarWindow.sizeTo(minSize.width, minSize.height); + + _emperor.setToolbarHeight(minSize.height); + _emperor.setToolBarWindow(_toolBarWindow); + + _toolBarWindow.setLayer(InternalWindow.PALETTE_LAYER); +// _toolBarWindow.show(); + } + + private void addToolbarButtons() + { + addButton(CommandTyrant.PAGELIST_SHOW_HIDE, "Open", "Hide/Show Open Dialog","PageListTool.gif", true); + addButton(CommandTyrant.REFRESH_ALL, "Refrsh","Refresh All", "RefreshTool.gif", false); + addButton(CommandTyrant.COPY, "Copy", "Copy", "CopyTool.gif", false); + addButton(CommandTyrant.PASTE, "Paste", "Paste", "PasteTool.gif", false); + addButton(CommandTyrant.EVAL_SEL_STRING, "Eval", "Evaluate", "EvalTool.gif", false); + addButton(CommandTyrant.INTERRUPT, "Intrpt","Interrupt", "InterruptTool.gif", true); + addButton(CommandTyrant.TOGGLE_BREAKPOINT, "BrkPt", "Breakpoint", "BreakpointTool.gif",true); + addButton(CommandTyrant.RUN, "Run", "Run", "RunTool.gif", false); + addButton(CommandTyrant.STEP_OVER, "Over", "Step Over", "StepOverTool.gif", false); + addButton(CommandTyrant.STEP_INTO, "Into", "Step Into", "StepIntoTool.gif", false); + addButton(CommandTyrant.STEP_OUT, "Out", "Step Out", "StepOutTool.gif", false); + addButton(CommandTyrant.ABORT, "Abort", "Abort", "AbortTool.gif", false); + } + + private void addMenuItems( Menu mainMenu, MenuItem fileMenu) + { + addMenuItem( CommandTyrant.PAGELIST_SHOW_HIDE,"Open...", fileMenu ); + addMenuItem( CommandTyrant.REFRESH_ALL, "Refresh All", fileMenu ); + // NOTE: separator and "Exit" are later appended here by our creator + + MenuItem editMenu = mainMenu.addItemWithSubmenu("Edit"); + addMenuItem( CommandTyrant.CUT, "Cut", editMenu ); + addMenuItem( CommandTyrant.COPY, "Copy", editMenu ); + addMenuItem( CommandTyrant.PASTE, "Paste", editMenu ); + addMenuSeparator(editMenu); + addMenuItem( CommandTyrant.EVAL_SEL_STRING, "Evaluate", editMenu ); + addMenuItem( CommandTyrant.INSPECT_SEL_STRING,"Inspect...", editMenu ); + addMenuItem( CommandTyrant.COPY_TO_WATCH, "Copy to Watch",editMenu ); + addMenuSeparator(editMenu); + addMenuItem( CommandTyrant.CLEAR_CONSOLE, "Clear Console",editMenu ); + addMenuSeparator(editMenu); + MenuItem prefsMenu = editMenu.submenu().addItemWithSubmenu("Preferences"); + addMenuItem( CommandTyrant.SHOW_LINE_NUMBERS, "Show Line Numbers", prefsMenu ); + + MenuItem controlMenu = mainMenu.addItemWithSubmenu("Control"); + addMenuItem( CommandTyrant.INTERRUPT, "Interrupt", controlMenu ); + addMenuItem( CommandTyrant.TOGGLE_BREAKPOINT, "Set Breakpoint", controlMenu ); + addMenuItem( CommandTyrant.EDIT_BREAKPOINT, "Edit Breakpoint...",controlMenu ); + addMenuSeparator(controlMenu); + addMenuItem( CommandTyrant.RUN, "Run", controlMenu ); + addMenuItem( CommandTyrant.STEP_OVER, "Step Over", controlMenu ); + addMenuItem( CommandTyrant.STEP_INTO, "Step Into", controlMenu ); + addMenuItem( CommandTyrant.STEP_OUT, "Step Out", controlMenu ); + addMenuItem( CommandTyrant.ABORT, "Abort", controlMenu ); + addMenuSeparator(controlMenu); + addMenuItem( CommandTyrant.TEST, "Test", controlMenu ); + + MenuItem windowsMenu = mainMenu.addItemWithSubmenu("Windows"); + addMenuItem( CommandTyrant.INSPECTOR_SHOW_HIDE, "Inspector...", windowsMenu ); + addMenuItem( CommandTyrant.WATCHES_SHOW_HIDE, "Watches...", windowsMenu ); + addMenuItem( CommandTyrant.BREAKPOINTS_SHOW_HIDE,"Breakpoints...",windowsMenu ); + } + + /* + * Temporary method to add menu item separators until IFC gets a native one.... + */ + private static void addMenuSeparator(MenuItem item) + { + item.submenu().addSeparator(); +// AWTCompatibility.awtMenuForMenu(item.submenu()).addSeparator(); + } + + private void addMenuItem( int id, String text, MenuItem menuitem ) + { + CmdState state = _commandTyrant.findCmdState(id); + if(ASS)ER.T(null!=state,"invalid cmd state while creating menu item",this); + _items[id].menuItem = menuitem.submenu().addItem(text,state.name,_commandTyrant); + } + + private void addButtonSpacer() + { + PopupButton button; + button = _mainToolbar.addButton("",null,null,null,"NarrowSpaceTool.gif"); + button.setEnabled(false); + } + + private void addButton( int id, String text, String tip, String image, boolean toggle ) + { + CmdState state = _commandTyrant.findCmdState(id); + if(ASS)ER.T(null!=state,"invalid cmd state while creating buttons",this); + CmdViewItem item = _items[id]; + + Bitmap bmp = _loadBitmap(image, true); + item.button = _mainToolbar.addButton(text,tip,_commandTyrant,state.name,bmp,null); + + if( toggle ) + item.button.setCanToggle(true); + + } + + private Bitmap _loadBitmap(String name, boolean fromJar) + { + java.awt.Image image = null; + Bitmap bitmap = null; + + if(!fromJar) + return Bitmap.bitmapNamed(name); + + try + { + java.io.InputStream in = null; + String fullname = "images/"+name; + ClassLoader loader = getClass().getClassLoader(); + if(null != loader) + { +// if(ASS)System.out.println("using loader.getResourceAsStream()"); + in = loader.getResourceAsStream(fullname); + } + else + { +// if(ASS)System.out.println("using ClassLoader.getSystemResourceAsStream()"); + in = ClassLoader.getSystemResourceAsStream(fullname); + } + + if(null != in) + { +// System.err.println("good stream"); + byte[] buf = new byte[in.available()]; + in.read(buf); + image = java.awt.Toolkit.getDefaultToolkit().createImage(buf); + } +// else +// System.err.println("bad stream"); + } + catch (java.io.IOException e) + { +// System.err.println("Unable to read image."); +// e.printStackTrace(); + } + if(null != image) + { + int width; + int height; + + // XXX pretty iffy! + while(-1 == (width = image.getWidth(null)) || + -1 == (height = image.getHeight(null))) + Thread.currentThread().yield(); + +// System.err.println("width = "+width); +// System.err.println("height = "+height); + + int[] pix = new int[width*height]; + + java.awt.image.PixelGrabber grabber = + new java.awt.image.PixelGrabber(image, 0, 0, width, height, + pix, 0, width); + + try + { + if(grabber.grabPixels()) + bitmap = new Bitmap(pix, width, height); + } + catch(InterruptedException ie) + { +// System.err.println("grabber interrupted"); +// ie.printStackTrace(); + } + } + if(null == bitmap) + { + if(ASS)System.err.println("loading bitmap from jar failed, trying Bitmap.bitmapNamed()"); + bitmap = Bitmap.bitmapNamed(name); + } + + return bitmap; + } + + private void refreshSingleItemState(int i, boolean force) + { + CmdState state = _commandTyrant.findCmdState(i); + if(ASS)ER.T(null!=state,"invalid cmd state in refreshAllStates()",this); + CmdViewItem item = _items[i]; + + if( null != item.button ) + { + if( force || + item.enabled != state.enabled || + item.checked != state.checked ) + { + item.button.setEnabled(state.enabled); + item.button.setChecked(state.checked); + item.button.draw(); + } + } + if( null != item.menuItem ) + { + if( force || item.enabled != state.enabled ) + item.menuItem.setEnabled(state.enabled); + if( force || item.checked != state.checked ) + { + if( state.checked && null != item.checkedText ) + item.menuItem.setTitle( item.checkedText ); + else if( ! state.checked && null != item.uncheckedText ) + item.menuItem.setTitle( item.uncheckedText ); + } + } + item.enabled = state.enabled; + item.checked = state.checked; + } + + private void refreshAllStates(boolean force) + { + int count = CommandTyrant.CMD_COUNT; + for( int i = 0; i < count; i++ ) + refreshSingleItemState(i, force); + } + + // implement observer interface + public void update(Observable o, Object arg) + { + refreshAllStates(false); + } + + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + private CommandTyrant _commandTyrant; + + private ToolbarTray _toolbarTray; + private Toolbar _mainToolbar; + private InternalWindow _toolBarWindow; + + private CmdViewItem[] _items; + + // special cases for menu item text refreshes + private boolean _oldLineNumbersShowing; + private boolean _oldPageListShowing; + private boolean _oldInterruptOn; + private boolean _oldBkeakpointSet; + + + private static final boolean ASS = true; // enable ASSERT support? +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsolePrinter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsolePrinter.java new file mode 100644 index 00000000000..208914143d6 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsolePrinter.java @@ -0,0 +1,29 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +interface ConsolePrinter +{ + public void print(String stringToPrint, boolean isOutput); +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsoleTyrant.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsoleTyrant.java new file mode 100644 index 00000000000..7eb7c43117f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsoleTyrant.java @@ -0,0 +1,237 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; +import com.netscape.jsdebugging.api.*; + +public class ConsoleTyrant + extends Observable + implements Observer, Target, JSErrorReporter // , SimulatorPrinter // XXX Sim Hack +{ + public ConsoleTyrant(Emperor emperor) + { + super(); + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + _stackTyrant = emperor.getStackTyrant(); + + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_stackTyrant,"emperor init order problem", this); + + + // XXX Sim Hack... +// Simulator.setPrinter(this); + } + + + public void setPrinter(ConsolePrinter printer) + { + _printer = printer; + // XXX need to plant this hook (or our own pass through) into JSD + } + + /* + * NOTE: this ErrorReporter may be called on a thread other than + * the IFC UI thread + */ + + // implement JSErrorReporter interface + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + _errorString = msg; + return JSErrorReporter.RETURN; + } + + public void eval(String input) + { + if( null == input ) + return; + + String eval = null; + int evalLine = ++_lineno; + + /* + * In order to allow the user to enter functions on multiple lines, + * this hack accumulates line which go to the console printer, but + * are not sent to JSD until the end is reached. + * The rule is that when not accumulating if a line ends with '{' + * then it is assumed to be the end of a function definition line and + * accumulation begins. If accumulating, then if a line + * has only one char and it is '}' the accumulation ends + */ + + int len = input.length(); + if( null == _accumulator && len > 0 && '{' == input.charAt(len-1) ) + { + _accumulator = new String(input + "\n"); + _accumulatorLine = evalLine; + } + else if( null != _accumulator ) + { + if( 1 == len && '}' == input.charAt(0) ) + { + eval = _accumulator + input + "\n"; + evalLine =_accumulatorLine; + _accumulator = null; + } + else + { + _accumulator += input + "\n"; + } + } + else + eval = input + "\n"; + + // Sent the input to the printer. + _sendInputToPrinter(input, null == _accumulator); + + if( null == eval ) + return; + + // currently don't allow eval when not stopped. + if( ControlTyrant.STOPPED != _controlTyrant.getState() ) + return; + + JSStackFrameInfo frame = (JSStackFrameInfo) _stackTyrant.getCurrentFrame(); + if( null == frame ) + return; + + JSSourceLocation loc = _stackTyrant.getCurrentLocation(); + if( null == loc ) + return; + + String filename; + if( _emperor.isPre40b6() || Emperor.LOCAL != _emperor.getHostMode() ) + filename = "console"; + else + filename = loc.getURL(); + + _emperor.setWaitCursor(true); + + PrivilegeManager.enablePrivilege("Debugger"); + + String result = ""; + _errorString = null; + + JSErrorReporter oldER = null; + + if( ! _emperor.isCorbaHostConnection() ) + oldER = _controlTyrant.setErrorReporter(this); + + DebugController dc = _emperor.getDebugController(); + if( null != dc && null != frame ) + { + ExecResult fullresult = + dc.executeScriptInStackFrame(frame,eval,filename,evalLine); + result = fullresult.getResult(); + + if( Emperor.REMOTE_SERVER == _emperor.getHostMode() && + fullresult.getErrorOccured() ) + { + _errorString = fullresult.getErrorMessage(); + } + } + + if( ! _emperor.isCorbaHostConnection() ) + _controlTyrant.setErrorReporter(oldER); + + // XXX quick test... +// _emperor.getInspectorTyrant().getPropNamesOfJavaScriptThing(eval); + + if( null != _printer ) + { + if( null != _errorString ) + _printer.print("[error "+_errorString+"]\n", true); + else if( null == result ) + _printer.print("[null]\n", true); + else + _printer.print(result + "\n", true); + } + + _emperor.setWaitCursor(false); + } + + // implement observer interface + public void update(Observable o, Object arg) + { + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + } + +/* + // implement SimulatorPrinter interface + public void print(String stringToPrint) + { + if(null != _printer) + _printer.print(stringToPrint, false); + else + System.out.print(stringToPrint); + } +*/ + + private static final boolean SHOW_CONSOLE_LINES = false; + + private void _sendInputToPrinter(String input, boolean full) + { + if(null != _printer) + { + if( SHOW_CONSOLE_LINES ) + { + String num = ""+_lineno; + num = Util.TEN_ZEROS.substring(0,4-num.length()) + num; + _printer.print(num+(full?": ":"+ ")+input+"\n", false); + } + else + { +// _printer.print("eval> "+input+"\n", false); + _printer.print(input+"\n", false); + } + } + } + + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + private StackTyrant _stackTyrant; + private int _lineno; + private String _accumulator = null; + private int _accumulatorLine; + private ConsolePrinter _printer; + private String _errorString; + + private static final boolean ASS = true; // enable ASSERT support? +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsoleView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsoleView.java new file mode 100644 index 00000000000..c6f61e830d4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ConsoleView.java @@ -0,0 +1,347 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import com.netscape.jsdebugging.api.*; + + +public class ConsoleView + extends InternalWindow + implements Observer, ConsolePrinter, Target, TextFilter +{ + public ConsoleView( Emperor emperor, Rect rect ) + { + super(rect); + + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + _consoleTyrant = emperor.getConsoleTyrant(); + _commandTyrant = emperor.getCommandTyrant(); + + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_consoleTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_commandTyrant,"emperor init order problem", this); + + _editKeyTextFilter = new EditKeyTextFilter(_commandTyrant); + + _listview = new NoSelectListView(); + _textfield = new TextField(0,0,rect.width-1,25); + + _linefont = _emperor.getFixedFont(); + + Rect rectSG = new Rect(rect); + rectSG.moveBy(-rect.x, -rect.y); + + ScrollGroup sg1 = new ScrollGroup(rectSG); + sg1.setHorizScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg1.setVertScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg1.setContentView( _listview ); + sg1.setAutoResizeSubviews(true); + sg1.contentView().setLayoutManager( new MarginLayout() ); + sg1.setBackgroundColor(_emperor.getBackgroundColor()); + + ScrollGroup sg2 = new ScrollGroup(rectSG); + sg2.setHorizScrollBarDisplay( ScrollGroup.NEVER_DISPLAY ); + sg2.setVertScrollBarDisplay( ScrollGroup.NEVER_DISPLAY ); + sg2.setContentView( _textfield ); + sg2.setAutoResizeSubviews(true); + sg2.contentView().setLayoutManager( new MarginLayout() ); + sg2.setBackgroundColor(_emperor.getBackgroundColor()); + + BoxView sv = new BoxView(SplitterView.VERT); + + sv.addFlexibleView(sg1); + sv.addFixedView(sg2,30); + + setCloseable( false ); // XXX nice to allow close and track in menu + setResizable( true ); + setTitle( "Console" ); + addSubview(sv); + setAutoResizeSubviews(true); + contentView().setLayoutManager( new MarginLayout() ); + + _listview.setAllowsEmptySelection(true); + _listview.setAllowsMultipleSelection(false); + _listview.setBackgroundColor(_emperor.getBackgroundColor()); + + _textfield.setTextColor(Color.black); + _textfield.setSelectionColor(_emperor.getSelectionColor()); + _setTextFieldEnabledState(); + +// _textfield.setWrapsContents(true); +// _textfield.setJustification(Graphics.LEFT_JUSTIFIED); + _textfield.setSelectable(true); + _textfield.setFont(_linefont); + _textfield.setHorizResizeInstruction( View.WIDTH_CAN_CHANGE ); + _textfield.setFilter(this); // to catch return key and edit cmds + + _redrawTimer = new Timer(this, null, 100 ); + _redrawTimer.setCommand(DRAW_CMD); + _redrawTimer.setRepeats(false); + _redrawTimer.setCoalesce(true); + + _lastLineTerminated = true; + _consoleTyrant.setPrinter(this); + + setFocusedView(_textfield); + + layoutView(1,1); + layoutView(-1,-1); + +// show(); + + _controlTyrant.addObserver(this); + } + + // implement observer interface + public void update(Observable o, Object arg) + { + if ( o == _controlTyrant ) + _setTextFieldEnabledState(); + } + + private void _setTextFieldEnabledState() + { + if( ControlTyrant.STOPPED == _controlTyrant.getState() ) + { + _textfield.setBackgroundColor(_emperor.getBackgroundColor()); + _textfield.setEditable(true); + } + else + { + _textfield.setBackgroundColor(_emperor.getDisabledBackgroundColor()); + _textfield.setEditable(false); + } + } + + + // implement ConsolePrinter interface + public synchronized void print(String stringToPrint, boolean isOutput) + { + StringBuffer buf; + + if( null == stringToPrint || 0 == stringToPrint.length() ) + return; + + if( ! _lastLineTerminated ) + { + // get the text of the last item in the list + + int listItemIndex = _listview.count() - 1; + if(ASS)ER.T(listItemIndex>=0,"bad listview item",this); + + buf = new StringBuffer( _listview.itemAt(listItemIndex).title() ); + _listview.removeItemAt(listItemIndex); + } + else + buf = new StringBuffer(); + + int len = stringToPrint.length(); + for( int i = 0; i < len; i++ ) + { + char c = stringToPrint.charAt(i); + if( c == '\n' ) + { + _addStringToList( buf.toString(), isOutput ); + buf.setLength(0); + } + else + buf.append(c); + } + + // add the left overs + if( 0 != buf.length() ) + _addStringToList( buf.toString(), isOutput ); + + _lastLineTerminated = ('\n' == stringToPrint.charAt(len-1)); + + // do defered draw + _redrawTimer.start(); + } + + private void _addStringToList(String text, boolean isOutput) + { + text = Util.expandTabs(text,8); + + ListItem item = new ListItem(); + item.setTitle( text ); + item.setFont( _linefont ); + item.setSelectedColor(_emperor.getSelectionColor()); + item.setTextColor( isOutput ? Color.red : Color.black ); + _listview.addItem( item ); + + _maxlinelen = Math.max( _maxlinelen, text.length() ); + } + + // implement Target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(EVAL_CMD) ) + { + String text = _textfield.stringValue(); + _consoleTyrant.eval(text); + _textfield.setStringValue(""); + _textfield.setFocusedView(); + } + else if( cmd.equals(DRAW_CMD) ) + { + // do defered draw + // draw and layout + + FontMetrics fm = _linefont.fontMetrics(); + _listview.setBounds( 0, 0, (_maxlinelen+1) * fm.charWidth('X'),0 ); + _listview.sizeToMinSize(); + this.layoutView(0,0); + + int last = _listview.count() - 1; + if( last >= 0 ) + _listview.scrollItemAtToVisible(last); + _listview.draw(); + } + } + + // implement TextFilter interface + public boolean acceptsEvent(Object o, KeyEvent ke , Vector vec) + { + if( ke.isReturnKey() ) + { + Application.application().performCommandLater(this, EVAL_CMD, null); + return false; + } + return _editKeyTextFilter.acceptsEvent(o, ke , vec); + } + + public synchronized void clear() + { + _listview.removeAllItems(); + _lastLineTerminated = true; + _maxlinelen = 0; + + // force a correct redraw + performCommand( DRAW_CMD, null ); + } + + public void didBecomeMain() + { + _commandTyrant.refreshCmdStatesAndNotifyObservers(); + super.didBecomeMain(); + } + + public void didResignMain() + { + _commandTyrant.refreshCmdStatesAndNotifyObservers(); + super.didResignMain(); + } + + public boolean canCopy() + { + if( null == _textfield ) + return false; + if( ! _textfield.isEditable() ) + return false; + if( ! isMain() ) + return false; + // the problem with this is that we're not getting notified when + // a selection does happen. Rather than failing to notify commandTyrant + // when we later become copyable, we'd rather lie and say that we're + // copyable even if we aren't really (yet)... + // + // XXX fixing this with a proper notification would be good. + // +// return _textfield.hasSelection(); + return true; + } + + public String copy() + { + if( ! canCopy() ) + return null; + return _textfield.stringForRange( _textfield.selectedRange() ); + } + + public String cut() + { + if( ! canCopy() ) + return null; + Range r = _textfield.selectedRange(); + String retval = _textfield.stringForRange(r); + _textfield.replaceRangeWithString(r, ""); + _textfield.setInsertionPoint(r.index); + return retval; + } + + public boolean canPaste() + { + if( null == _textfield ) + return false; + if( ! _textfield.isEditable() ) + return false; + if( ! isMain() ) + return false; + return true; + } + + public void paste(String s) + { + if( null == s || 0 == s.length() ) + return; + if( ! canPaste() ) + return; + Range r = _textfield.selectedRange(); + _textfield.replaceRangeWithString(r, s); + _textfield.setInsertionPoint(r.index + s.length()); + } + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + private ConsoleTyrant _consoleTyrant; + private CommandTyrant _commandTyrant; + private ListView _listview; + private TextField _textfield; + + private Timer _redrawTimer; + + private int _maxlinelen = 0; + private Font _linefont; + private boolean _lastLineTerminated; + private EditKeyTextFilter _editKeyTextFilter; + + private static final String EVAL_CMD = "EVAL_CMD"; + private static final String DRAW_CMD = "DRAW_CMD"; + + private static final boolean ASS = true; // enable ASSERT support? +} + +class NoSelectListView extends BackgroundHackListView +{ + public NoSelectListView() {super();} + public boolean mouseDown(MouseEvent me) {return false;} + public void mouseDragged(MouseEvent me) {} + public void mouseUp(MouseEvent me) {} +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ControlTyrant.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ControlTyrant.java new file mode 100644 index 00000000000..3ae73f9d813 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ControlTyrant.java @@ -0,0 +1,645 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; +import com.netscape.jsdebugging.api.*; + +public class ControlTyrant + extends Observable + implements Observer, Target, JSErrorReporter +{ + public static final int RUNNING = 0; + public static final int STOPPED = 1; + + // ctors + + public ControlTyrant(Emperor emperor) throws ForbiddenTargetException + { + super(); + _app = Application.application(); + _emperor = emperor; + + PrivilegeManager.enablePrivilege("Debugger"); + _dc = _emperor.getDebugController(); + + _semaphore = new CtrlSemaphore(); + + // set our interrupt hook (with chaining) + _interruptHook = new CtrlInterruptHook(this); + _interruptHook.setNextHook(_dc.setInterruptHook(_interruptHook)); + + // set our debugBreak hook (with chaining) + _debugBreakHook = new CtrlDebugBreakHook(this); + _debugBreakHook.setNextHook(_dc.setDebugBreakHook(_debugBreakHook)); + + _dc.setErrorReporter(this); + + if( _emperor.getHostMode() == _emperor.REMOTE_SERVER ) + _useServerSideStepper = true; + else + _useServerSideStepper = false; + + if(ASS) + { + _uiThreadForAssertCheck = Thread.currentThread(); + } + + // add ourself as observer of ??? + + // notify that we are running (if anyone cares at this point!) + _state = RUNNING; + _notifyOfStateChange(); + } + + // accessors + + public int getState() {return _state;} + public boolean getInterrupt() {return _interrupt;} + public boolean getEnabled() {return _enabled;} + public Emperor getEmperor() {return _emperor;} + + public JSThreadState getThreadState() + { + if( STOPPED == _state ) + return _threadState; + if(ASS)ER.T(false,"getThreadState called when not really stopped",this); + return null; + } + + public JSPC getPC() + { + if( STOPPED == _state ) + return _pc; + if(ASS)ER.T(false,"getPC called when not really stopped",this); + return null; + } + + public JSSourceLocation getSourceLocation() + { + if( STOPPED == _state ) + return _sourceLocation; + if(ASS)ER.T(false,"getSourceLocation called when not really stopped",this); + return null; + } + + // command handlers + + public synchronized void interrupt(boolean b) + { + PrivilegeManager.enablePrivilege("Debugger"); + if( b == _interrupt ) + return; + _interrupt = b; + if( _interrupt ) + { + _stepHandler = null; + _serverSideStepperIsSet = false; + _dc.sendInterrupt(); + } + } + + public synchronized void runit() + { + _continueAndNotify(true); + } + + public synchronized void abort() + { + if( _state != STOPPED || _semaphore.available() || null == _threadState ) + { + if(ASS)ER.T(false,"abort called when not really stopped",this); + return; + } + + _threadState.setContinueState( ThreadStateBase.DEBUG_STATE_THROW ); + _continueAndNotify(true); + } + + private static final int STEP_OVER = 0; + private static final int STEP_INTO = 1; + private static final int STEP_OUT = 2; + + public synchronized void stepOver() + { + if( _useServerSideStepper ) + _setServerSideStepper(STEP_OVER); + else + _setStepHandler( new StepOver(_threadState, _sourceLocation, _pc) ); + } + + public synchronized void stepInto() + { + if( _useServerSideStepper ) + _setServerSideStepper(STEP_INTO); + else + _setStepHandler( new StepInto(_sourceLocation, _pc) ); + } + + public synchronized void stepOut() + { + if( _useServerSideStepper ) + _setServerSideStepper(STEP_OUT); + else + _setStepHandler( new StepOut(_threadState, _pc) ); + } + + private synchronized void _setServerSideStepper( int type ) + { + if( _state != STOPPED || _semaphore.available() ) + { + if(ASS)ER.T(false,"_setServerSideStepper called when not really stopped",this); + return; + } + _interrupt = false; + _stepHandler = null; + PrivilegeManager.enablePrivilege("Debugger"); + switch(type) + { + case STEP_OVER: + _dc.sendInterruptStepOver(_threadState); + break; + case STEP_INTO: + _dc.sendInterruptStepInto(_threadState); + break; + case STEP_OUT : + _dc.sendInterruptStepOut(_threadState); + break; + default: + if(ASS)ER.T(false,"invalid type passed to _setServerSideStepper",this); + return; + } + _serverSideStepperIsSet = true; + _serverSideStepperType = type; + + _continueAndNotify(true); + } + + private synchronized void _setStepHandler( StepHandler handler ) + { + if( _state != STOPPED || _semaphore.available() ) + { + if(ASS)ER.T(false,"_setStepHandler called when not really stopped",this); + return; + } + _interrupt = false; + _stepHandler = handler; + _serverSideStepperIsSet = false; + PrivilegeManager.enablePrivilege("Debugger"); + _dc.sendInterrupt(); + _continueAndNotify(true); + } + + public synchronized void disableDebugger() + { + if( false == _enabled ) + return; + + _enabled = false; + + if( _state == STOPPED && ! _semaphore.available() ) + { + _continueAndNotify(false); + } + + _notifyOfDebuggerDisabled(); + } + + private void _continueAndNotify( boolean notify ) + { + if( _state != STOPPED || _semaphore.available() ) + { + if(ASS)ER.T(false,"_continueAndNotify called when not really stopped",this); + return; + } + +// if(ASS){System.out.println( "running again" );} + + // transition state + _state = RUNNING; + if( notify ) + _notifyOfStateChange(); + + synchronized(_semaphore) + { + _semaphore.release(); + _threadState.resume(); +// if(ASS){System.out.println( "returning after interrupt" );} + } + } + + public synchronized void evaluatingBreakpoint(boolean b) + { + _evaluatingBreakpoint += (b ? 1 : -1); + if(ASS)ER.T(_evaluatingBreakpoint >= 0,"_evaluatingBreakpoint less than zero",this); + } + + public synchronized void breakpointHookCalledButElectedNotToStop(JSThreadState ts) + { + if( _useServerSideStepper ) + { + if(_serverSideStepperIsSet ) + _dc.reinstateStepper(ts); + } + else + { + if( null != _stepHandler ) + { + PrivilegeManager.enablePrivilege("Debugger"); + _dc.sendInterrupt(); + } + } + } + + // implement our hooks + + // called by both breakpoints and interrupt hook (on JS thread) + void aboutToExecute(JSThreadState debug, JSPC pc, Hook hook) + { + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "1) entered" ); + if( ! _enabled ) + { + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "2) exit, ! _enabled" ); + return; + } + + if( _evaluatingBreakpoint > 0 ) + { + if(ASS)System.out.println("ignoring break while evaluating breakpoint"); + return; + } + + PrivilegeManager.enablePrivilege("Debugger"); + + // grab the semaphore (return if not available) + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "3) about to call _semaphore.grab()" ); + if( ! _semaphore.grab() ) + { + if(ASS)System.out.println( "blowing past nested break at: " + pc ); + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "4) exit _semaphore.grab() failed" ); + return; + } + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "5) exit _semaphore.grab() succeeded" ); + + if( hook instanceof CtrlDebugBreakHook ) + { + _stepHandler = null; + _serverSideStepperIsSet = false; + _interrupt = false; + } + + // Keep going if the interrupt no longer needed. + if( hook instanceof CtrlInterruptHook && + null == _stepHandler && ! _interrupt && ! _serverSideStepperIsSet ) + { + _semaphore.release(); + return; + } + + // save arguments + + _threadState = debug; + _pc = pc; + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "6) about to call _pc.getSourceLocation()"); + _sourceLocation = (JSSourceLocation) _pc.getSourceLocation(); + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "7) _pc.getSourceLocation() returned"); + + if(false) + { + String leadin = "interrupted at:"; + String url = _sourceLocation.getURL()+"#"+(_sourceLocation.getLine()); + String fun = (null != _pc.getScript().getFunction()) ? (_pc.getScript().getFunction()+"()") : "toplevel"; + String script = "["+(_pc.getScript().getBaseLineNumber())+","+ + (_pc.getScript().getBaseLineNumber()+_pc.getScript().getLineExtent()-1)+"]"; + String where = "pc: " + _pc.getPC(); + + if(ASS){System.out.println(leadin+" "+url+" "+fun+" "+script+" "+where);} +// if(ASS)Thread.dumpStack(); + } + + // Hitting any other type of hook clears the interrupt stepper + if( ! (hook instanceof CtrlInterruptHook) ) + { + _stepHandler = null; + _serverSideStepperIsSet = false; + } + + // If there is a step handler then let it process the hook + if( null != _stepHandler ) + { + switch( _stepHandler.step(_threadState,_pc,_sourceLocation,hook) ) + { + case StepHandler.STOP: + _stepHandler = null; + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "8) StepHandler.STOP"); + break; + case StepHandler.CONTINUE_SEND_INTERRUPT: + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "9) StepHandler.CONTINUE_SEND_INTERRUPT about to sendInterrupt"); + _dc.sendInterrupt(); + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "10) sendInterrupt returned"); + _semaphore.release(); + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "10.5) _semaphore.release() returned"); + return; + case StepHandler.CONTINUE_DONE: + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "11) StepHandler.CONTINUE_DONE"); + _stepHandler = null; + _semaphore.release(); + return; + } + } + + // if(ASS){System.out.println( "about to send HIT_EXEC_HOOK" );} + // if(ASS){System.out.println( "this = " + this );} + // if(ASS){System.out.println( "HIT_EXEC_HOOK = " + HIT_EXEC_HOOK );} + // if(ASS){System.out.println( "hook = " + hook );} + // if(ASS){System.out.println( "Thread = " + Thread.currentThread() );} + + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "12) about to call _threadState.leaveSuspended()"); + _threadState.leaveSuspended(); + if(ASS)Log.trace("ControlTyrant.aboutToExecute", "13) _threadState.leaveSuspended() returned"); + + // post message to UI thread + _app.performCommandLater( this, HIT_EXEC_HOOK, hook ); + } + + // This where we receive commands from the CommandPoster + // implement target interface + public synchronized void performCommand(String cmd, Object data) + { + if( ! _enabled ) + { + _state = STOPPED; + _continueAndNotify(false); + return; + } + if( cmd.equals(HIT_EXEC_HOOK) ) + { + SourceTyrant st = _emperor.getSourceTyrant(); + if( null == st || + null == _sourceLocation || + null == _sourceLocation.getURL() || + null == st.findSourceItem(_sourceLocation.getURL()) ) + { + if(ASS){System.out.println( "continuing: source text unavailable");} + _state = STOPPED; + _continueAndNotify(false); + return; + } + + _emperor.setWaitCursor(true); + _interrupt = false; + + // if(ASS){System.out.println( "got stop command, transitioning state" );} + + _emperor.bringAppToFront(); + + // transition to STOPPED state + _state = STOPPED; + _notifyOfStateChange(); + _emperor.setWaitCursor(false); + } + else if( cmd.equals(HIT_ERROR_REPORTER) ) + { + _emperor.bringAppToFront(); + Sound.soundNamed("droplet.au").play(); +// AWTCompatibility.awtToolkit().beep(); + + ErrorReporterDialog erd = + new ErrorReporterDialog(_emperor, (ErrorReport) data); + + _emperor.enableAppClose(false); + erd.showModally(); + _emperor.enableAppClose(true); + + _debugBreakResponse = erd.getAnswer(); + notify(); + } + else + { + if(ASS)ER.T(false,"unhandled command received in perform command: " + cmd,this); + } + + } + + // implement observer interface + public void update(Observable o, Object arg) + { + + } + + /* + * NOTE: this ErrorReporter may be called on a thread other than + * the IFC UI thread + */ + public synchronized JSErrorReporter setErrorReporter(JSErrorReporter er) + { + JSErrorReporter old = _errorReporter; + _errorReporter = er; + return old; + + } + public JSErrorReporter getErrorReporter() + { + return null != _errorReporter ? _errorReporter : this ; + } + + // implement JSErrorReporter interface + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + if( ! _enabled ) + return JSErrorReporter.PASS_ALONG; + + if( null != _errorReporter && this != _errorReporter ) + return _errorReporter.reportError(msg,filename,lineno,linebuf,tokenOffset); + + synchronized(this) + { + ErrorReport er = new ErrorReport( msg, filename, lineno, + linebuf, tokenOffset ); + + _debugBreakResponse = -1; + _app.performCommandLater( this, HIT_ERROR_REPORTER, er ); + + while( -1 == _debugBreakResponse && _enabled ) + { + try + { + wait(); + } + catch(Exception e) + { + if(ASS){System.out.println("threw during wait for command response");} + if(ASS){System.out.println(e);} + } + } + if( -1 == _debugBreakResponse ) + _debugBreakResponse = JSErrorReporter.PASS_ALONG; + + return _debugBreakResponse; + } + } + + private void _notifyOfStateChange() + { + if(ASS)ER.T(Thread.currentThread()==_uiThreadForAssertCheck,"_notifyObservers called on thread other than UI thread",this); + setChanged(); + notifyObservers( new ControlTyrantUpdate( ControlTyrantUpdate.STATE_CHANGED,_state) ); + } + + private void _notifyOfDebuggerDisabled() + { + if(ASS)ER.T(Thread.currentThread()==_uiThreadForAssertCheck,"_notifyObservers called on thread other than UI thread",this); + setChanged(); + notifyObservers( new ControlTyrantUpdate( ControlTyrantUpdate.DEBUGGER_DISABLED,_state) ); + } + + + // data... + private Application _app; + private int _state; + private boolean _interrupt; + private Emperor _emperor; + private DebugController _dc; + private CtrlSemaphore _semaphore; + private JSThreadState _threadState; + private JSPC _pc; + private JSSourceLocation _sourceLocation; + + private StepHandler _stepHandler; + + private CtrlInterruptHook _interruptHook; + private CtrlDebugBreakHook _debugBreakHook; + private int _debugBreakResponse; + + private boolean _enabled = true; + private Thread _uiThreadForAssertCheck = null; + private JSErrorReporter _errorReporter; + + private boolean _useServerSideStepper = false; + private boolean _serverSideStepperIsSet = false; + private int _serverSideStepperType; + + private int _evaluatingBreakpoint = 0; + + private final String HIT_EXEC_HOOK = "HIT_EXEC_HOOK"; + private final String HIT_ERROR_REPORTER = "HIT_ERROR_REPORTER"; + private static final boolean ASS = true; // enable ASSERT support? +} + +/***************************************************************************/ +// used internally only... +class CtrlSemaphore +{ + public boolean available() {return _available;} + public synchronized void release() {_available = true;} + public synchronized boolean grab() + { + if(! _available) + return false; + _available = false; + return true; + } + + private boolean _available = true; +} + +// used internally only... +class CtrlInterruptHook + extends InterruptHook + implements ChainableHook +{ + CtrlInterruptHook( ControlTyrant ctrlTyrant ) + { + setTyrant( ctrlTyrant ); + } + + public void aboutToExecute(ThreadStateBase debug, PC pc) + { +// System.out.println( "called the right hook..." ); + + // for safety we make sure not to throw anything at native caller. + try { + if( null != _ctrlTyrant ) + { + if(ASS)ER.T(debug instanceof JSThreadState,"wrong kind of threadstate",this); + if(ASS)ER.T(pc instanceof JSPC,"wrong kind of pc",this); + _ctrlTyrant.aboutToExecute( (JSThreadState)debug, (JSPC) pc, this ); + } + if( null != _nextHook ) + _nextHook.aboutToExecute(debug, pc); + } catch(Throwable t){t.printStackTrace();} // eat it. + } + + // implement ChainableHook + public void setTyrant(Object tyrant) {_ctrlTyrant = (ControlTyrant) tyrant;} + public void setNextHook(Hook nextHook) {_nextHook = (InterruptHook) nextHook;} + + private ControlTyrant _ctrlTyrant; + private InterruptHook _nextHook; + private static final boolean ASS = true; // enable ASSERT support? +} + +// used internally only... +class CtrlDebugBreakHook + extends DebugBreakHook + implements ChainableHook +{ + CtrlDebugBreakHook( ControlTyrant ctrlTyrant ) + { + setTyrant( ctrlTyrant ); + } + + public void aboutToExecute(ThreadStateBase debug, PC pc) + { + // for safety we make sure not to throw anything at native caller. + try { + if( null != _ctrlTyrant ) + { + if(ASS)ER.T(debug instanceof JSThreadState,"wrong kind of threadstate",this); + if(ASS)ER.T(pc instanceof JSPC,"wrong kind of pc",this); + _ctrlTyrant.aboutToExecute( (JSThreadState)debug, (JSPC) pc, this ); + } + if( null != _nextHook ) + _nextHook.aboutToExecute(debug, pc); + } catch(Throwable t){} // eat it. + } + + // implement ChainableHook + public void setTyrant(Object tyrant) {_ctrlTyrant = (ControlTyrant) tyrant;} + public void setNextHook(Hook nextHook) {_nextHook = (DebugBreakHook) nextHook;} + + private ControlTyrant _ctrlTyrant; + private DebugBreakHook _nextHook; + private static final boolean ASS = true; // enable ASSERT support? +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ControlTyrantUpdate.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ControlTyrantUpdate.java new file mode 100644 index 00000000000..264c694a632 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ControlTyrantUpdate.java @@ -0,0 +1,38 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +class ControlTyrantUpdate +{ + public static final int STATE_CHANGED = 0; + public static final int DEBUGGER_DISABLED = 1; + + public ControlTyrantUpdate( int type, int state ) + { + this.type = type; + this.state = state; + } + public int type; + public int state; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/EditKeyTextFilter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/EditKeyTextFilter.java new file mode 100644 index 00000000000..8b261a0a3e2 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/EditKeyTextFilter.java @@ -0,0 +1,69 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 11/19/97 jband added this class +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; + +public class EditKeyTextFilter + implements TextFilter +{ + public EditKeyTextFilter(CommandTyrant commandTyrant) + { + _commandTyrant = commandTyrant; + } + + // implement TextFilter interface + public boolean acceptsEvent(Object o, KeyEvent ke , Vector vec) + { + if( ke.isControlKeyDown() ) + { + switch(ke.key + 'a' - 1) + { + case 'c': + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.COPY), + null); + return false; + case 'v': + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.PASTE), + null); + return false; + case 'x': + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.CUT), + null); + return false; + default: + break; + } + } + return true; + } + + private CommandTyrant _commandTyrant; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Emperor.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Emperor.java new file mode 100644 index 00000000000..c8e04646b52 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Emperor.java @@ -0,0 +1,673 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.io.*; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.toolTip.*; +import netscape.javascript.*; +import com.netscape.jsdebugging.api.*; + +/** +* Emperor starts it up and is connect point to the Application +*/ + +public class Emperor + implements WindowOwner +{ + public Emperor( EmperorOwner owner, + ToolTipExternalWindow mainWindow, + Menu mainMenu, + MenuItem fileMenu, + MenuView menuView, + int hostMode, + String host, + StatusWindow statusWindow ) + + { + _owner = owner; + _mainWindow = mainWindow; + _mainMenu = mainMenu; + _menuView = menuView; + + _hostMode = hostMode; + _host = host; + + _rootView = mainWindow.rootView(); + _mainWindow.setOwner(this); + _mainWindow.setHidesWhenPaused(false); + + _fixedFont = new Font( "Courier", Font.PLAIN, 13 ); + + _debuggerIsActive = true; + + if(ASS) + { + _uiThreadForAssertCheck = Thread.currentThread(); + } + + setWaitCursor(true); + + _gatherVersionInfo(); + + statusWindow.setText(REMOTE_SERVER == hostMode ? + "Connecting to Server..." : "Connecting to Navigator..."); + _connectToTarget(); + + statusWindow.setText("Initializing Models..."); + _createTyrants(); + statusWindow.setText("Initializing Views..."); + _createViews(fileMenu); + + statusWindow.setText("Reading Prefs..."); + _readPrefs(); + _readBreakpointListHackFile(); + _commandTyrant.refreshCmdStatesAndNotifyObservers(); + _showViews(); + + setWaitCursor(false); + } + + public static final int LOCAL = 0; + public static final int REMOTE_SERVER = 1; + public static final int RHINO = 2; + + public static final String LOCAL_LOADER_NAME = + "com.netscape.jsdebugging.api.local.AdapterLoaderLocal"; + public static final String SERVER_LOADER_NAME = + "com.netscape.jsdebugging.api.corba.AdapterLoaderCorba"; + public static final String RHINO_LOADER_NAME = + "com.netscape.jsdebugging.api.rhino.AdapterLoaderRhino"; + + public static boolean isDebuggingSupported(int which, String host) + { + String loaderName = null; + switch(which) + { + case LOCAL: + loaderName = LOCAL_LOADER_NAME; + break; + case REMOTE_SERVER: + loaderName = SERVER_LOADER_NAME; + break; + case RHINO: + loaderName = RHINO_LOADER_NAME; + break; + default: + return false; + } + + try + { + PrivilegeManager.enablePrivilege("Debugger"); + Class clazz = Class.forName(loaderName); + AdapterLoader loader = (AdapterLoader) clazz.newInstance(); + loader.setHost(host); + return loader.isDebuggingSupported(); + } + catch( Throwable e ) + { + System.out.println(e); + } + return false; + } + + private boolean _connectToTarget() + { + String loaderName = null; + switch(_hostMode) + { + case LOCAL: + loaderName = LOCAL_LOADER_NAME; + break; + case REMOTE_SERVER: + loaderName = SERVER_LOADER_NAME; + break; + case RHINO: + loaderName = RHINO_LOADER_NAME; + break; + default: + return false; + } + + try + { + PrivilegeManager.enablePrivilege("Debugger"); + Class clazz = Class.forName(loaderName); + AdapterLoader loader = (AdapterLoader) clazz.newInstance(); + + loader.setHost(_host); + + _debugController = loader.getDebugController(); + _sourceTextProvider = loader.getSourceTextProvider(); + if( null == _sourceTextProvider || null == _debugController ) + return false; + return true; + } + catch( Throwable e ) + { + System.out.println(e); + } + return false; + } + + private void _createTyrants() + { + _controlTyrant = new ControlTyrant(this); + _sourceTyrant = new SourceTyrant(this); + _stackTyrant = new StackTyrant(this); + _breakpointTyrant = new BreakpointTyrant(this); + _consoleTyrant = new ConsoleTyrant(this); + _watchTyrant = new WatchTyrant(this); + _inspectorTyrant = new InspectorTyrant(this); + _commandTyrant = new CommandTyrant(this); + _sourceTyrant.refreshSourceTextItemVector(); + } + + private void _createViews( MenuItem fileMenu ) + { + if( null != _menuView ) + _menuViewHeight = _menuView.itemHeight(); + + _commandView = new CommandView( this, _mainMenu, fileMenu, _menuViewHeight ); + + Rect rectCanvas = getClientRect(); + // hack for space for native menu +// rectCanvas.height -= 20; + +// _lowerWindowDY = 200; + _lowerWindowDY = rectCanvas.height / 3; + int stackViewWidth = 150; + int lowerWindowY = rectCanvas.y + rectCanvas.height - _lowerWindowDY; + + int popupDX = rectCanvas.width * 5 / 6; + int popupDY = rectCanvas.height * 1 / 2; + + Rect rectPageList = new Rect(rectCanvas.x,rectCanvas.y,popupDX,popupDY); + Rect rectWatchView = new Rect(rectCanvas.x+20,rectCanvas.y+20,popupDX,popupDY); + Rect rectBreakpointView = new Rect(rectCanvas.x+40,rectCanvas.y+40,popupDX,popupDY); + Rect rectInspectorView = new Rect(rectCanvas.x+60,rectCanvas.y+60,popupDX,popupDY); + Rect rectStackView = new Rect( 0, lowerWindowY, + stackViewWidth, + _lowerWindowDY ); + Rect rectConsole = new Rect( stackViewWidth, lowerWindowY, + rectCanvas.width-stackViewWidth, + _lowerWindowDY); + + // hack for "unsigned window" subwindow + Rect rectSrc = new Rect(rectCanvas.x,rectCanvas.y, + rectCanvas.width, + rectCanvas.height-_lowerWindowDY); + + _pageListView = new PageListView( this, rectPageList ); + _sourceViewManager = new SourceViewManager(this); + _sourceViewManager.setPreferedNewViewRect( rectSrc ); + _stackView = new StackView( this, rectStackView ); + _consoleView = new ConsoleView(this, rectConsole ); + _watchView = new WatchView(this, rectWatchView); + _breakpointView = new BreakpointView(this, rectBreakpointView); + _inspectorView = new InspectorView(this, rectInspectorView); + } + + public void _showViews() + { + _toolBarWindow.show(); + _stackView.show(); + _consoleView.show(); + } + + + private void _readPrefs() + { + PrivilegeManager.enablePrivilege("Debugger"); + PrivilegeManager.enablePrivilege("UniversalFileRead"); + + String prefsDir = Env.getPrefsDir(); + if( null == prefsDir ) + return; + + String prefsFullFilename; + if( LOCAL == _hostMode ) + prefsFullFilename = prefsDir + _prefsFilenameClient; + else + prefsFullFilename = prefsDir + _prefsFilenameServer; + + // we don't want to spit this info to the console if not an applet + if( isApplet() ) + System.out.println("JSD is using prefs file: " + prefsFullFilename ); + + _prefsFile = new java.io.File(prefsFullFilename); + if( null == _prefsFile ) + return; + + // any existing prefs? + if( ! _prefsFile.exists() ) + return; + + try + { + FileInputStream fis = new FileInputStream(_prefsFile); + Archive archive = new Archive(); + archive.readASCII(fis); + Unarchiver unarchiver = new Unarchiver(archive); + + // XXX: process each object that implements PrefsSupport here + + if( null != _breakpointTyrant ) + _breakpointTyrant.prefsRead( unarchiver ); + + if( null != _sourceViewManager ) + _sourceViewManager.prefsRead( unarchiver ); + + if( null != _watchTyrant ) + _watchTyrant.prefsRead( unarchiver ); + + + // add the rest... + + + + fis.close(); + } + catch( Exception e ) + { + // print and eat + System.out.println(e); + } + + + } + + private void _writePrefs() + { + if( null == _prefsFile ) + return; + PrivilegeManager.enablePrivilege("Debugger"); + PrivilegeManager.enablePrivilege("UniversalFileWrite"); + + try + { + Archiver archiver = new Archiver(new Archive()); + + // XXX: process each object that implements PrefsSupport here + + if( null != _breakpointTyrant ) + _breakpointTyrant.prefsWrite( archiver ); + + if( null != _sourceViewManager ) + _sourceViewManager.prefsWrite( archiver ); + + if( null != _watchTyrant ) + _watchTyrant.prefsWrite( archiver ); + + // add the rest... + + + + FileOutputStream fos = new FileOutputStream(_prefsFile); + archiver.archive().writeASCII(fos, true); + fos.close(); + } + catch( Exception e ) + { + // print and eat + System.out.println(e); + } + + + } + + private void _debuggerIsClosing() + { + if( ! _debuggerIsActive ) + return; + + _writePrefs(); + _debuggerIsActive = false; + + if( null != _controlTyrant ) + _controlTyrant.disableDebugger(); + } + + public void enableAppClose( boolean b ) {_appCanClose=b;} + + public void IFC_cleanupCalled() + { + _debuggerIsClosing(); + } + + + // implement WindowOwner interface + public boolean windowWillShow(Window aWindow) {return true;} + public void windowDidShow(Window aWindow) {} + public boolean windowWillHide(Window aWindow) + { + if( null == _mainWindow || _mainWindow != aWindow || _ignoreHide ) + return true; + + if( ! _appCanClose ) + return false; + return true; + } + public void windowDidHide(Window aWindow) + { + if( null == _mainWindow || _mainWindow != aWindow || _ignoreHide ) + return; + + _debuggerIsClosing(); + + // close the applet that owns us + try + { + if( _isApplet ) + { + JSObject jso = JSObject.getWindow( AWTCompatibility.awtApplet() ); + if( null != jso ) + jso.eval( "window.close()" ); + } + } + catch(Throwable e){} // eat failure + } + public void windowDidBecomeMain(Window aWindow) {} + public void windowDidResignMain(Window aWindow) {} + public void windowWillSizeBy(Window aWindow, Size deltaSize) + { + if (_toolBarWindow != null) + { + Size minSize = _toolBarWindow.windowSizeForContentSize(_rootView.width(), 0); + _toolBarWindow.sizeTo(minSize.width,_toolBarWindow.height()); + } + if( null != _sourceViewManager ) + _sourceViewManager.setPreferedNewViewRect(getPreferedNewSourceViewRect()); + } + + + private void _readBreakpointListHackFile() + { + if( null == _breakpointTyrant ) + return; + PrivilegeManager.enablePrivilege("Debugger"); + PrivilegeManager.enablePrivilege("UniversalFileRead"); + + String prefsDir = Env.getPrefsDir(); + if( null == prefsDir ) + return; + + String bpFullFilename; + if( LOCAL == _hostMode ) + bpFullFilename = prefsDir + _bpFilenameClient; + else + bpFullFilename = prefsDir + _bpFilenameServer; + java.io.File bpFile = new java.io.File(bpFullFilename); + if( null == bpFile ) + return; + + // any existing breakpoints file? + if( ! bpFile.exists() ) + return; + + // we don't want to spit this info to the console if not an applet + if( isApplet() ) + System.out.println("JSD is reading breakpoint list file: " + bpFullFilename ); + + try + { + DataInputStream s = new DataInputStream(new FileInputStream(bpFile)); + if( null != s ) + { + String linetext; + while( null != (linetext = s.readLine()) ) + { + String url; + String condition; + int sep1; + int sep2; + + sep1 = linetext.indexOf(","); + if( -1 == sep1 ) + continue; + sep2 = linetext.indexOf(",", sep1+1); + String lineString = linetext.substring(0,sep1).trim(); + + if( -1 != sep2 ) + { + url = linetext.substring(sep1+1,sep2).trim(); + condition = linetext.substring(sep2+1).trim(); + } + else + { + url = linetext.substring(sep1+1).trim(); + condition = null; + } + + // System.out.println("lineString = " + lineString); + // System.out.println("url = " + url); + // System.out.println("condition = " + condition); + + int line = Integer.parseInt(lineString); + + if( 0 == line || null == url || 0 == url.length() ) + continue; + + // add the breakpoint + + Location loc = new Location(url, line); + if( null == _breakpointTyrant.findBreakpoint(loc) ) + { + Breakpoint bp = _breakpointTyrant.addBreakpoint(loc); + if( null != bp && null != condition ) + bp.setBreakCondition(condition); + } + } + s.close(); + } + } + catch( Exception e ) + { + // print and eat + System.out.println(e); + } + } + + private void _gatherVersionInfo() + { + try + { + _isApplet = Application.application().isApplet(); + if( _isApplet ) + { + // detect if this is a pre- 4.0b6 version of Navigator + // check for "4.0bx " where x is < 6 + PrivilegeManager.enablePrivilege("Debugger"); + JSObject jso = JSObject.getWindow( AWTCompatibility.awtApplet() ); + if( null != jso ) + { + String ver = (String) jso.eval( "navigator.appVersion" ); + if( null != ver ) + { + // check for "4.0bx " where x is < 6 + if( ver.length() >= 6 && + ver.startsWith("4.0b") && + ver.charAt(5) == ' ' && + ver.charAt(4) >= '1' && + ver.charAt(4) <= '5' ) + { + System.out.println( "JSDebugger running in 4.0b5 or earlier, get new Communicator :)"); + _isPre40b6 = true; + } + } + } + } + } + catch( Throwable e ) {} // eat any exception... + } + + public Rect getClientRect() + { + Size s = _mainWindow.contentSize(); + return new Rect(0,_toolbarHeight+_menuViewHeight, + s.width,s.height-_toolbarHeight-_menuViewHeight); + } + + private Rect getPreferedNewSourceViewRect() + { + Rect rect = getClientRect(); + rect.height -= _lowerWindowDY; + return rect; + } + + public View getCanvasView() {return _rootView;} + public RootView getRootView() {return _rootView;} + + public ToolTipExternalWindow getMainWindow() {return _mainWindow;} + public Menu getMainMenu() {return _mainMenu;} + public InternalWindow getToolBarWindow() {return _toolBarWindow;} + + public void setToolbarHeight(int i) {_toolbarHeight=i;} + public void setToolBarWindow(InternalWindow w) {_toolBarWindow=w;} + + public ControlTyrant getControlTyrant() {return _controlTyrant ;} + public BreakpointTyrant getBreakpointTyrant() {return _breakpointTyrant;} + public SourceTyrant getSourceTyrant() {return _sourceTyrant ;} + public StackTyrant getStackTyrant() {return _stackTyrant ;} + public WatchTyrant getWatchTyrant() {return _watchTyrant ;} + public ConsoleTyrant getConsoleTyrant() {return _consoleTyrant ;} + public CommandTyrant getCommandTyrant() {return _commandTyrant ;} + public InspectorTyrant getInspectorTyrant() {return _inspectorTyrant ;} + + public PageListView getPageListView() {return _pageListView ;} + public SourceViewManager getSourceViewManager() {return _sourceViewManager;} + public CommandView getCommandView() {return _commandView ;} + public StackView getStackView() {return _stackView ;} + public ConsoleView getConsoleView() {return _consoleView ;} + public WatchView getWatchView() {return _watchView ;} + public BreakpointView getBreakpointView() {return _breakpointView ;} + public InspectorView getInspectorView() {return _inspectorView ;} + + public SourceTextProvider getSourceTextProvider() {return _sourceTextProvider;} + public DebugController getDebugController() {return _debugController;} + + public void bringAppToFront() + { + try + { + if(ASS)ER.T(Thread.currentThread()==_uiThreadForAssertCheck,"bringAppToFront() called on non-UI thread",this); + RootView mrv = Application.application().mainRootView(); + if( null != mrv.mainWindow() ) + return; + ExternalWindow win = mrv.externalWindow(); + win.show(); + win.moveToFront(); + } + catch(Exception e){} // eat failure + } + + public boolean isApplet() {return _isApplet;} + + public void setWaitCursor(boolean set) + { + _owner.setWaitCursor(set); + } + + public Color getBackgroundColor() {return _backgroundColor;} + public Color getDisabledBackgroundColor() {return _disabledBackgroundColor;} + public Color getSelectionColor() {return _selectionColor;} + public Font getFixedFont() {return _fixedFont;} + public boolean isPre40b6() {return _isPre40b6;} + + public boolean isCorbaHostConnection() + { + // XXX this will need reworking as we use Corba in more ways... + return _hostMode == REMOTE_SERVER; + } + public int getHostMode() {return _hostMode;} + public String getHost() {return _host;} + + public void ignoreHide(boolean b) {_ignoreHide = b;} + + + // data... + + private EmperorOwner _owner; + private ToolTipExternalWindow _mainWindow; + private Menu _mainMenu; + private MenuView _menuView; + private int _menuViewHeight; + private InternalWindow _toolBarWindow; + private int _toolbarHeight; + private RootView _rootView; + private boolean _appCanClose = true; + + private ControlTyrant _controlTyrant ; + private BreakpointTyrant _breakpointTyrant; + private SourceTyrant _sourceTyrant ; + private StackTyrant _stackTyrant ; + private WatchTyrant _watchTyrant ; + private ConsoleTyrant _consoleTyrant ; + private InspectorTyrant _inspectorTyrant ; + private CommandTyrant _commandTyrant ; + + private PageListView _pageListView ; + private SourceViewManager _sourceViewManager; + private CommandView _commandView ; + private StackView _stackView ; + private ConsoleView _consoleView ; + private WatchView _watchView ; + private BreakpointView _breakpointView ; + private InspectorView _inspectorView ; + + private SourceTextProvider _sourceTextProvider; + private DebugController _debugController; + + private int _lowerWindowDY; + + private static final Color _backgroundColor = Color.white; + private static final Color _disabledBackgroundColor = Color.lightGray; + private static final Color _selectionColor = Color.lightGray; +// private static final Color _backgroundColor = Color.lightGray; +// private static final Color _selectionColor = Color.white; + + private static final String _prefsFilenameClient = "jsdcpref.txt"; + private static final String _prefsFilenameServer = "jsdspref.txt"; + private static final String _bpFilenameClient = "jsdcbp.txt"; + private static final String _bpFilenameServer = "jsdsbp.txt"; + + private Font _fixedFont = null; + private boolean _isPre40b6 = false; + private boolean _debuggerIsActive = false; + private java.io.File _prefsFile; + + private int _hostMode; + private String _host; + private boolean _ignoreHide; + private Thread _uiThreadForAssertCheck = null; + + private boolean _isApplet; + + private static final boolean ASS = true; // enable ASSERT support? +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/EmperorOwner.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/EmperorOwner.java new file mode 100644 index 00000000000..42baebdac88 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/EmperorOwner.java @@ -0,0 +1,28 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 11/10/97 jband added file +// + +package com.netscape.jsdebugging.ifcui; + +public interface EmperorOwner +{ + public void setWaitCursor(boolean set); +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Env.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Env.java new file mode 100644 index 00000000000..a5acd7b68b0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Env.java @@ -0,0 +1,204 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 12/06/97 jband added this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import java.io.File; + +/* A place to get info about the application Environment */ + +// all statics... +public class Env +{ + public static final int ENV_WIN = 1; + public static final int ENV_MAC = 2; + public static final int ENV_UNIX = 3; + + public static void Init() + { + _initPlatformType(); + _initCodebaseDir(); + _initPrefsDir(); + } + + public static int getCoursePlatformType() + { + if( 0 == _coursePlatformType ) + _initPlatformType(); + return _coursePlatformType; + } + + public static String getPrefsDir() + { + if( null == _prefsDir ) + _initPrefsDir(); + return _prefsDir; + } + + public static String getCodebaseDir() + { + if( null == _codebaseDir ) + _initCodebaseDir(); + return _codebaseDir; + } + + private static void _initPlatformType() + { + if( 0 != _coursePlatformType ) + return; + try + { + String os = System.getProperty("os.name").toUpperCase(); + // System.out.println("System.getProperty(\"os.name\").toUpperCase() returned: " + os); + if( os.startsWith("WIN") ) + _coursePlatformType = ENV_WIN; + else if( os.startsWith("MAC") ) + _coursePlatformType = ENV_MAC; + else + _coursePlatformType = ENV_UNIX; + } + catch(Exception e) + { + System.out.println(e); + System.out.println("Failed in getting os.name, defaulting to Unix"); + _coursePlatformType = ENV_UNIX; + } + } + + private static void _initCodebaseDir() + { + if( null != _codebaseDir ) + return; + + Application app = Application.application(); + if( null == app ) + { + System.out.println("Failed in getting app, codebasedir set to /"); + return; + } + // get codebase + java.net.URL loadDirURL = app.codeBase(); + String loadDir = loadDirURL.getFile(); + if(null != loadDir) + _codebaseDir = loadDir.replace('/', File.separatorChar); + + // unescape the path + StringBuffer sb = new StringBuffer(); + int len = _codebaseDir.length(); + for(int i = 0; i < len; i++ ) + { + char c = _codebaseDir.charAt(i); + if('%' == c && i+2 < len) + { + int high = Character.digit(_codebaseDir.charAt(i+1),16); + int low = Character.digit(_codebaseDir.charAt(i+2),16); + + if(-1 != high && -1 != low) + { + c = (char) ((high * 16) + low); + i += 2; + } + } + sb.append(c); + } + _codebaseDir = sb.toString(); + + _initPlatformType(); + + // hack to lose the leading slash in Windows filenames + if( ENV_WIN == _coursePlatformType && + _codebaseDir.length() >= 3 && + _codebaseDir.charAt(0) == File.separatorChar && + (_codebaseDir.charAt(2) == ':' || _codebaseDir.charAt(2) == '|') ) + { + _codebaseDir = _codebaseDir.substring(1); + } + + // hack to lose the leading slash in Mac filenames + // + // REMOVED! Mac Java in Nav wants leading slash! + // + // if( ENV_MAC == _coursePlatformType && + // _codebaseDir.length() >= 2 && + // _codebaseDir.charAt(0) == File.separatorChar ) + // { + // _codebaseDir = _codebaseDir.substring(1); + // } + + // + // force leading slash on Mac + // + if( ENV_MAC == _coursePlatformType && + _codebaseDir.length() >= 2 && + _codebaseDir.charAt(0) != File.separatorChar ) + { + _codebaseDir = File.separatorChar + _codebaseDir; + } + + // hack to get a 'normal' filename on Windows + if( ENV_WIN == _coursePlatformType && _codebaseDir.charAt(1) == '|' ) + _codebaseDir = _codebaseDir.charAt(0)+":"+ _codebaseDir.substring(2); + } + + private static void _initPrefsDir() + { + if( null != _prefsDir ) + return; + + _initPlatformType(); + _initCodebaseDir(); + + // set default + _prefsDir = _codebaseDir; + if( null == _prefsDir ) + _prefsDir = "/"; + + String s = Application.application().parameterNamed("PrefsDir"); + if( null != s ) + { + _prefsDir = s; + System.out.println("JSD set prefs dir from applet tag"); + } + else if( ENV_MAC == _coursePlatformType && _codebaseDir.length() > 1 ) + { + // is a Mac, try to use 'System Folder/Preferences' + + // use codebase for Volume name + int sep = _codebaseDir.indexOf(File.separatorChar,1); + if(-1 != sep) + { + _prefsDir = _codebaseDir.substring(0,sep+1) + + "System Folder" + + File.separatorChar + + "Preferences" + + File.separatorChar; + } + } + } + + + private static int _coursePlatformType = 0; + private static String _codebaseDir = null; + private static String _prefsDir = null; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ErrorReport.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ErrorReport.java new file mode 100644 index 00000000000..04b78d2c0ac --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ErrorReport.java @@ -0,0 +1,49 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/30/97 jband added this simple dumb data class +// + +package com.netscape.jsdebugging.ifcui; + +class ErrorReport +{ + private ErrorReport() {}; // 'Hidden' default ctor + + public ErrorReport( + String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + this.msg = msg; + this.filename = filename; + this.lineno = lineno; + this.linebuf = linebuf; + this.tokenOffset = tokenOffset; + } + + // data... + public String msg; + public String filename; + public int lineno; + public String linebuf; + public int tokenOffset; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ErrorReporterDialog.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ErrorReporterDialog.java new file mode 100644 index 00000000000..aa94f1f378f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/ErrorReporterDialog.java @@ -0,0 +1,198 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/30/97 jband added this class +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.api.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; + +class ErrorReporterDialog + extends InternalWindow + implements Target +{ + private static final int _boxDX = 350; + private static final int _boxDY = 150; + private static final int _buttonDX = 64; + private static final int _buttonDY = 24; + private static final int _spacerDX = 5; + private static final int _spacerDY = 5; + + public ErrorReporterDialog( Emperor emperor, ErrorReport er ) + { + super(); + + setTitle("JavaScript Error"); + setCloseable( false ); + setResizable( false ); + + Button icon = new Button(_spacerDX,_spacerDY,100,100); + icon.setEnabled(false); + icon.setBordered(false); + icon.setImage(Alert.warningImage()); + Size sz = icon.minSize(); + icon.sizeTo(sz.width,sz.height); + addSubview(icon); + + int boxTop = _spacerDY + sz.height + _spacerDY; + + int contentDX = _boxDX + _spacerDX * 2; + int contentDY = boxTop + _boxDY + _spacerDY * 3 + _buttonDY; + int buttonY = boxTop + _boxDY + _spacerDY * 2; + int buttonX3 = _boxDX + _spacerDX - _buttonDX; + int buttonX2 = buttonX3 - _spacerDX - _buttonDX; + int buttonX1 = buttonX2 - _spacerDX - _buttonDX; + + Size size = windowSizeForContentSize(contentDX, contentDY); + setBounds(0,0,size.width,size.height); + + int titleX = _spacerDX + sz.width + _spacerDX; + TextField title = new TextField(titleX, _spacerDY, + contentDX-titleX, sz.height); + title.setFont(new Font(Font.defaultFont().name(), Font.BOLD, 18)); + title.setJustification(Graphics.LEFT_JUSTIFIED); + title.setStringValue("JavaScript Error"); + title.setBorder(null); + title.setBackgroundColor(Color.lightGray); + title.setEditable(false); + addSubview(title); + + ERDListView lv = new ERDListView( emperor.getFixedFont() ); + + lv.setAllowsEmptySelection(true); + lv.setAllowsMultipleSelection(false); + lv.setBackgroundColor(Color.lightGray); + + if( null != er.filename ) + { + lv.addLine( "IN "+ er.filename ); + lv.addLine( "LINE "+ er.lineno ); + lv.addLine( "" ); + } + + lv.addLine( er.msg ); + + if( null != er.linebuf ) + { + StringBuffer sb = new StringBuffer(er.tokenOffset+2); + for(int i = 0; i < er.tokenOffset; i++ ) + sb.append('.'); + sb.append('^'); + + lv.addLine( "" ); + lv.addLine( er.linebuf ); + lv.addLine( sb.toString() ); + } + lv.sizeToContent(); + + ScrollGroup sg1 = new ScrollGroup(_spacerDX,boxTop,_boxDX,_boxDY); + sg1.setHorizScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg1.setVertScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg1.setContentView( lv ); + sg1.setAutoResizeSubviews(true); + sg1.contentView().setLayoutManager( new MarginLayout() ); + sg1.setBackgroundColor(Color.lightGray); + addSubview(sg1); + + Button button; + + button = new Button(buttonX1,buttonY,_buttonDX,_buttonDY); + button.setTitle("OK"); + button.setTarget(this); + button.setCommand(OK_CMD); + addSubview(button); + + button = new Button(buttonX2,buttonY,_buttonDX,_buttonDY); + button.setTitle("Debug"); + button.setTarget(this); + button.setCommand(DEBUG_CMD); + if( "syntax error".equals(er.msg) ) + button.setEnabled(false); + addSubview(button); + + button = new Button(buttonX3,buttonY,_buttonDX,_buttonDY); + button.setTitle("Pass On"); + button.setTarget(this); + button.setCommand(PASS_ON_CMD); + addSubview(button); + + center(); + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(OK_CMD) ) + _answer = JSErrorReporter.RETURN; + else if( cmd.equals(DEBUG_CMD) ) + _answer = JSErrorReporter.DEBUG; + else if( cmd.equals(PASS_ON_CMD) ) + _answer = JSErrorReporter.PASS_ALONG; + else + return; + hide(); + } + + public int getAnswer() {return _answer;} + + private int _answer = JSErrorReporter.RETURN; + + private static final String OK_CMD = "OK_CMD"; + private static final String DEBUG_CMD = "DEBUG_CMD"; + private static final String PASS_ON_CMD = "PASS_ON_CMD"; +} + +class ERDListView extends BackgroundHackListView +{ + public ERDListView( Font font ) + { + super(); + _linefont = font; + } + + public void addLine( String text ) + { + ListItem item = new ListItem(); + item.setTitle( text ); + item.setFont( _linefont ); + addItem( item ); + + _maxlinelen = Math.max( _maxlinelen, text.length() ); + } + + public void sizeToContent() + { + FontMetrics fm = _linefont.fontMetrics(); + setBounds( 0, 0, (_maxlinelen+1) * fm.charWidth('X'),0 ); + sizeToMinSize(); + } + + // don't allow selection... + public boolean mouseDown(MouseEvent me) {return false;} + public void mouseDragged(MouseEvent me) {} + public void mouseUp(MouseEvent me) {} + + private Font _linefont = null; + private int _maxlinelen = 0; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/HostNameDialog.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/HostNameDialog.java new file mode 100644 index 00000000000..32fe4523bd4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/HostNameDialog.java @@ -0,0 +1,189 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 11/10/97 jband added this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; + +class HostNameDialog + extends InternalWindow + implements Target, TextFilter +{ + private static final int _labelDX = 300; + private static final int _labelDY = 24; + private static final int _editDX = 300; + private static final int _editDY = 24; + private static final int _buttonDX = 70; + private static final int _buttonDY = 24; + private static final int _spacerDX = 5; + private static final int _spacerDY = 5; + + public HostNameDialog(String title, String label, String hostname) + { + super(); + + setTitle(title); + setCloseable( false ); + setResizable( false ); + + int contentDX = _editDX + _spacerDX * 2; + int contentDY = _labelDY + _editDY + _buttonDY + _spacerDY * 4; + int labelY = _spacerDY; + int editY = _labelDY + _spacerDY * 2; + int buttonY = _labelDY + _editDY + _spacerDY * 3; + + int labelX = _spacerDX; + int editX = _spacerDX; + + int buttonX3 = contentDX - _spacerDX - _buttonDX; + int buttonX2 = buttonX3 - _spacerDX - _buttonDX; + int buttonX1 = buttonX2 - _spacerDX - _buttonDX; + + Size size = windowSizeForContentSize(contentDX, contentDY); + setBounds(0,0,size.width,size.height); + + addSubview( _newLabel(labelX, labelY, _labelDX, _labelDY, label) ); + + _textField = new TextField(editX,editY,_editDX,_editDY); + _textField.setStringValue(hostname); + _textField.setInsertionPoint(hostname.length()); +// _textField.selectRange(new Range(0,hostname.length())); + _textField.setFilter(this); // to catch return key + addSubview(_textField); + + Button button; + + button = new Button(buttonX1,buttonY,_buttonDX,_buttonDY); + button.setTitle("OK"); + button.setTarget(this); + button.setCommand(OK_CMD); + addSubview(button); + + button = new Button(buttonX2,buttonY,_buttonDX,_buttonDY); + button.setTitle("Localhost"); + button.setTarget(this); + button.setCommand(LOCALHOST_CMD); + addSubview(button); + + button = new Button(buttonX3,buttonY,_buttonDX,_buttonDY); + button.setTitle("Cancel"); + button.setTarget(this); + button.setCommand(CANCEL_CMD); + addSubview(button); + + center(); + } + + private TextField _newLabel( int x, int y, int dx, int dy, String text ) + { + TextField label = new TextField(x,y,dx,dy); + label.setStringValue(text); + label.setEditable(false); + label.setSelectable(false); + label.setJustification(Graphics.LEFT_JUSTIFIED); + label.setBackgroundColor(Color.lightGray); + label.setBorder(null); + return label; + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(OK_CMD) ) + { + // get and validate data... + + _hostName = _textField.stringValue(); + if( null != _hostName ) + _hostName = _hostName.trim(); + if( null == _hostName || 0 == _hostName.length() ) + { + _hostName = _hostName.trim(); + Alert.runAlertInternally( + Alert.notificationImage(), + "invalid entry", + "you must enter a valid hostname or ip address", + "OK", null,null ); + setFocusedView( _textField ); + return; + } + + _keyPressed = OK; + hide(); + } + else if( cmd.equals(LOCALHOST_CMD) ) + { + _keyPressed = LOCALHOST; + hide(); + } + else if( cmd.equals(CANCEL_CMD) ) + { + _keyPressed = CANCEL; + hide(); + } + } + + // implement TextFilter interface + public boolean acceptsEvent(Object o, KeyEvent ke , Vector vec) + { + if( ke.isReturnKey() ) + { + Application.application().performCommandLater(this, OK_CMD, null); + return false; + } + return true; + } + + public void showModally() + { + _keyPressed = CANCEL; + super.showModally(); + } + + public void show() + { + // for some reason this dialog does not want to really get the focus + // until the user clicks on it. I'm not figuring out why. This sucks. +// Application.application().mainRootView().setFocusedView(this); + super.show(); + _textField.setFocusedView(); + } + + public static final int CANCEL = 0; + public static final int OK = 1; + public static final int LOCALHOST = 2; + + public String getHostName() {return _hostName;} + public int getKeyPressed() {return _keyPressed;} + + private TextField _textField; + private int _keyPressed; + private String _hostName; + + private static final String CANCEL_CMD = "CANCEL_CMD"; + private static final String LOCALHOST_CMD = "LOCALHOST_CMD"; + private static final String OK_CMD = "OK_CMD"; +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorNodeModel.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorNodeModel.java new file mode 100644 index 00000000000..9641c98429a --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorNodeModel.java @@ -0,0 +1,152 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 10/30/97 jband added this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; + +public class InspectorNodeModel +{ + public InspectorNodeModel( String name, + int depth, + InspectorNodeModel parent, + InspectorTyrant tyrant ) + { + _name = name.trim(); + _depth = depth; + _parent = parent; + _tyrant = tyrant; + String fullname = getFullName(); + _type = _tyrant.eval("typeof "+fullname); + + if( "function".equals(_type) ) + { + _value = "[function]"; + _hasProperties = false; + } + else + { + _value = Util.expandTabs( _tyrant.eval(fullname), 8 ); +// _hasProperties = "object".equals(_type) +// && ! "[null]".equals(_value); + if(! _value.equals("[null]")) + if(_type.startsWith("object") || _type.startsWith("array")) + _hasProperties = true; + } + } + + public synchronized int expand() + { + if( null != _firstChild ) + { + _firstChild.clearLinks(); + _firstChild = null; + } + + InspectorNodeModel prev = null; + int childCount = 0; + String[] childNames = _tyrant.getPropNamesOfJavaScriptThing(getFullName()); + if( null != childNames && 0 != (childCount = childNames.length) ) + { + for(int i = 0; i < childCount; i++ ) + { + InspectorNodeModel cur = new InspectorNodeModel(childNames[i], + _depth + 1, + this, + _tyrant); + if( null == _firstChild ) + _firstChild = cur; + if( null != prev ) + prev._nextSib = cur; + prev = cur; + } + } + return childCount; + } + + public synchronized void clearLinks() + { + _parent = null; + if( null != _firstChild ) + { + _firstChild.clearLinks(); + _firstChild = null; + } + if( null != _nextSib ) + { + _nextSib.clearLinks(); + _nextSib = null; + } + } + + public String getName() {return _name;} + public String getValue() {return _value;} + public String getType() {return _type;} + public int getDepth() {return _depth;} + public boolean hasProperties() {return _hasProperties;} + public String getFullName() + { + if( null == _fullname ) + { + if( null != _parent ) + { + _fullname = _parent.getFullName(); + if( ! _name.startsWith("[") ) + _fullname += "."; + _fullname += _name; + } + else + _fullname = _name; + } + return _fullname; + } + public InspectorNodeModel getParent() {return _parent;} + public InspectorNodeModel getFirstChild() {return _firstChild;} + public InspectorNodeModel getNextSib() {return _nextSib;} + + public boolean isAncestor(InspectorNodeModel model) + { + InspectorNodeModel p = _parent; + while(null != p) + { + if( p == model ) + return true; + p = p.getParent(); + } + return false; + } + + private InspectorTyrant _tyrant; + + private InspectorNodeModel _parent; + private InspectorNodeModel _firstChild; + private InspectorNodeModel _nextSib; + private String _fullname; + private String _name; + private int _depth; + private String _value; + private boolean _hasProperties; + private String _type; + private boolean _isValid; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorTyrant.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorTyrant.java new file mode 100644 index 00000000000..1da0861954c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorTyrant.java @@ -0,0 +1,325 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 10/30/97 jband added this file +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; +import com.netscape.jsdebugging.api.*; + +public class InspectorTyrant + extends Observable + implements Observer, Target, JSErrorReporter // , SimulatorPrinter // XXX Sim Hack +{ + public InspectorTyrant(Emperor emperor) + { + super(); + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + _stackTyrant = emperor.getStackTyrant(); + + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_stackTyrant,"emperor init order problem", this); + + _controlTyrant.addObserver(this); + _stackTyrant.addObserver(this); + } + + public InspectorNodeModel getRootNode() {return _rootNode;} + + public InspectorNodeModel setNewRootNode( String name ) + { + _emperor.setWaitCursor(true); + if( null != _rootNode ) + { + _rootNode.clearLinks(); + _rootNode = null; + } + + if( null != name ) + _rootNode = new InspectorNodeModel( name, 0, null, this ); + + // for now the notification just means: "rootNode changed" + _notifyObservers(); + _emperor.setWaitCursor(false); + return _rootNode; + } + + // It is important that our function name not conflict with anything + // in the user's namespace. I think this should be safe :) + private static final String _propEnumeratorFunctionName = + "__John_Bandhauer_Says_This_Is_A_Unique_Identifier__"; + + // Rhino currently does not like this form +// private static final String _propEnumeratorFunction = +// "function "+_propEnumeratorFunctionName+"(ob)\n"+ +// "{\n"+ +// " var retval = \"\";\n"+ +// " var prop;\n"+ +// " for(prop in ob)\n"+ +// " retval += prop+\",\";\n"+ +// " return retval;\n"+ +// "}\n"; + + private static final String _propEnumeratorFunction = + _propEnumeratorFunctionName+" = new Function(\"ob\",\""+ + " var retval = new String();"+ + " var prop;"+ + " for(prop in ob)"+ + " retval += prop+\',\';"+ + " return retval;\")"; + + public String[] getPropNamesOfJavaScriptThing(String jsthing) + { + eval(_propEnumeratorFunction); + String list = eval(_propEnumeratorFunctionName +"("+jsthing+")"); + eval( "delete " + _propEnumeratorFunctionName); + //System.out.println(list); + + int len; + String[] retval = null; + if( null != list && 0 != (len = list.length()) ) + { + // XXX This is a pure hack to add the 'layers' property to a list + // that looks like a 'document', but lacks the 'layers' property. + // This gets around the bug in Nav of not setting the ENUM flag + // for document.layers + // + // a partial and arbitary list of props that ought to be there... + if( -1 == list.indexOf("layers") && + -1 != list.indexOf("alinkColor") && + -1 != list.indexOf("vlinkColor") && + -1 != list.indexOf("applets") && + -1 != list.indexOf("bgColor") && + -1 != list.indexOf("embeds") ) + { + list = list + "layers,"; + len = list.length(); + } + + // we build both a string and a number vector so that we can + // seperately sort them before concating them. NOTE that numVec + // actually holds strings representing numbers, rather than the + // numbers themselves - we don't want rounding & conversions errors + Vector stringVec = new Vector(); + Vector numVec = new Vector(); + int start = 0; + for( int i = 0; i < len; i++ ) + { + if( list.charAt(i) == ',' ) + { + String name = list.substring(start,i); + if( name.length() > 0 && ! name.equals(_propEnumeratorFunctionName) ) + { + char c0 = name.charAt(0); + if( c0 == '-' || Character.isDigit(c0) ) + { + // insertion sort of number + try + { + Double n = new Double(name); + double val = n.doubleValue(); + int j; + int count = numVec.size(); + for(j = 0; j < count; j++) + { + if( val < new Double((String)numVec.elementAt(j)).doubleValue() ) + { + numVec.insertElementAt(name,j); + break; + } + } + if( j == count ) + numVec.addElement(name); + } + catch(NumberFormatException e) + { + if(ASS)ER.T(false,"failed to parse property name as number: "+name,this); + stringVec.addElement("["+name+"]"); + } + } + else + { + // the below deals with cases where the property + // name is not a number, but is not a valid + // identifier either. + // e.g. window["foo/bar"] + // the navigator.mimeTypes array has such properties + String nameToAdd = null; + if(Character.isJavaIdentifierStart(c0)) + { + int name_len = name.length(); + int j; + for(j = 0; j < name_len; j++) + if(!Character.isJavaIdentifierPart(name.charAt(j))) + break; + if(j == name_len) + nameToAdd = name; + } + if(nameToAdd == null) + nameToAdd = "[\""+name+"\"]"; + stringVec.addElement(nameToAdd); + } + } + start = i+1; + } + } + + int stringVecLen = stringVec.size(); + int numVecLen = numVec.size(); + + if( (stringVecLen + numVecLen) > 0 ) + { + retval = new String[stringVecLen + numVecLen]; + int i; + for( i = 0; i < numVecLen; i++ ) + retval[i] = "["+(String) numVec.elementAt(i)+"]"; + + if( stringVecLen > 0 ) + stringVec.sortStrings(true,true); + + for( i = 0; i < stringVecLen; i++ ) + retval[numVecLen+i] = (String) stringVec.elementAt(i); + } + + } + return retval; + } + + public String eval(String input) + { + if( null == input ) + return null; + + String eval = input; + + // currently don't allow eval when not stopped. + if( ControlTyrant.STOPPED != _controlTyrant.getState() ) + return "[error unable to evaluate while running]"; + + JSStackFrameInfo frame = (JSStackFrameInfo) _stackTyrant.getCurrentFrame(); + if( null == frame ) + return null; + + JSSourceLocation loc = _stackTyrant.getCurrentLocation(); + if( null == loc ) + return null; + + String filename; + if( _emperor.isPre40b6() || + Emperor.REMOTE_SERVER == _emperor.getHostMode() ) + filename = "inspector"; + else + filename = loc.getURL(); + + PrivilegeManager.enablePrivilege("Debugger"); + + String result = ""; + _errorString = null; + + JSErrorReporter oldER = null; + + if( ! _emperor.isCorbaHostConnection() ) + oldER = _controlTyrant.setErrorReporter(this); + + DebugController dc = _emperor.getDebugController(); + if( null != dc && null != frame ) + { + ExecResult fullresult = + dc.executeScriptInStackFrame(frame,eval,filename,1); + result = fullresult.getResult(); + + if( fullresult.getErrorOccured() ) + { + _errorString = fullresult.getErrorMessage(); + } + } + + if( ! _emperor.isCorbaHostConnection() ) + _controlTyrant.setErrorReporter(oldER); + + if( null != _errorString ) + result = "[error "+_errorString+"]"; + else if( null == result ) + result = "[null]"; + // else + // result = result; + + return result; + } + + /* + * NOTE: this ErrorReporter may be called on a thread other than + * the IFC UI thread + */ + + // implement JSErrorReporter interface + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + _errorString = msg; + return JSErrorReporter.RETURN; + } + + // implement observer interface + public void update(Observable o, Object arg) + { + if ( o == _controlTyrant ) + { + if( ControlTyrant.RUNNING == _controlTyrant.getState() ) + setNewRootNode( null == _rootNode ? null : _rootNode.getName() ); + } + else if( o == _stackTyrant ) + { + // force re-eval in new frame + setNewRootNode( null == _rootNode ? null : _rootNode.getName() ); + } + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + } + + // for now the notification just means: "rootNode changed" + private void _notifyObservers() + { + setChanged(); + notifyObservers(null); + } + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + private StackTyrant _stackTyrant; + private String _errorString; + private InspectorNodeModel _rootNode; + + private static final boolean ASS = true; // enable ASSERT support? +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorView.java new file mode 100644 index 00000000000..2d9005eb1f4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/InspectorView.java @@ -0,0 +1,806 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 10/30/97 jband added this file +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; + +public class InspectorView + extends InternalWindow + implements Observer, Target, TextFilter +{ + private static final int _editDY = 24; + private static final int _buttonWidth = 74; + private static final int _buttonHeight = 24; + private static final int _spacerDY = 5; + private static final int _spacerDX = 5; + + private int _nextButtonX; + private int _nextButtonY; + + public InspectorView( Emperor emperor, Rect rect ) + { + super(rect); + + _emperor = emperor; + _inspectorTyrant = emperor.getInspectorTyrant(); + _controlTyrant = emperor.getControlTyrant(); + _commandTyrant = emperor.getCommandTyrant(); + + if(ASS)ER.T(null!=_inspectorTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_commandTyrant,"emperor init order problem", this); + + _editKeyTextFilter = new EditKeyTextFilter(_commandTyrant); + + _drawer = new InspectorItemDrawer(_emperor.getFixedFont()); + + _listview = new InspectorListView(this); + + Size size = contentSize(); + int listwidth = size.width - (_buttonWidth + (_spacerDX * 3)); + int listtop = _editDY + (_spacerDY * 2); + _listheight = size.height - (listtop + _spacerDY); + + Rect rectEdit = new Rect(_spacerDX, _spacerDY, listwidth, _editDY); + Rect rectSG = new Rect(_spacerDX, listtop, listwidth, _listheight); + + _nextButtonX = listwidth + (_spacerDX * 2); + _nextButtonY = _spacerDY; + + _inspectButton = _addButton( "Inspect", INSPECT_CMD ); + _nextButtonY += _spacerDY * 2; + _evalButton = _addButton( "Eval", EVAL_CMD ); + _addButton( "Add Watch", ADD_WATCH_CMD); + _addButton( "Copy Name", COPY_NAME_CMD); + _addButton( "Copy Value", COPY_VALUE_CMD); + _nextButtonY += _spacerDY * 4; + _addButton( "Done", DONE_CMD); + + _textfield = new TextField(rectEdit); + _textfield.setStringValue(""); + _textfield.setFont(_emperor.getFixedFont()); + _textfield.setFilter(this); // to catch return key and edit cmds + addSubview(_textfield); + + ScrollGroup sg = new ScrollGroup(rectSG); + sg.setHorizScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg.setVertScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg.setContentView( _listview ); + sg.setAutoResizeSubviews(true); + sg.contentView().setLayoutManager( new MarginLayout() ); + sg.setBackgroundColor(_emperor.getBackgroundColor()); + + setCloseable( false ); + setResizable( false ); + setTitle( "Inspector" ); + addSubview(sg); + setAutoResizeSubviews(true); + + _listview.setAllowsEmptySelection(true); + _listview.setAllowsMultipleSelection(false); + + _listview.setTarget(this); + _listview.setCommand(HIGHLIGHT_CMD); + _listview.setDoubleCommand(INSPECT_CMD); + + _listview.setBackgroundColor(_emperor.getBackgroundColor()); + + setLayer(InternalWindow.PALETTE_LAYER); + + _textfield.setFocusedView(); + + boolean stopped = ControlTyrant.STOPPED == _controlTyrant.getState(); + _inspectButton.setEnabled(stopped); + _evalButton.setEnabled(stopped); + + _inspectorTyrant.addObserver(this); + _controlTyrant.addObserver(this); + + refresh(); + + layoutView(1,1); + layoutView(-1,-1); + } + + private Button _addButton( String title, String cmd ) + { + Button button = new Button(_nextButtonX,_nextButtonY, + _buttonWidth,_buttonHeight); + button.setTitle(title); + button.setTarget(this); + button.setCommand(cmd); + addSubview(button); + _nextButtonY += _buttonHeight + _spacerDY; + return button; + } + + // implement observer interface + public void update(Observable o, Object arg) + { + if ( o == _inspectorTyrant ) + { + // always refresh if visible... + if( isVisible() ) + refresh(); + } + else if ( o == _controlTyrant ) + { + boolean stopped = ControlTyrant.STOPPED == _controlTyrant.getState(); + _inspectButton.setEnabled(stopped); + _evalButton.setEnabled(stopped); + } + } + + // implement TextFilter interface + public boolean acceptsEvent(Object o, KeyEvent ke , Vector vec) + { + if( ke.isReturnKey() ) + { + Application.application().performCommandLater(this, INSPECT_CMD, null); + return false; + } + return _editKeyTextFilter.acceptsEvent(o, ke , vec); + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(HIGHLIGHT_CMD) ) + { + InspectorListItem item = (InspectorListItem)_listview.selectedItem(); + InspectorNodeModel model = item.getModel(); + String fullname = model.getFullName(); + _textfield.cancelEditing(); + _textfield.setStringValue( fullname ); + } + else if( cmd.equals(INSPECT_CMD) ) + { + if( ControlTyrant.STOPPED != _controlTyrant.getState() ) + return; + + String s = _textfield.stringValue(); + if( null != s ) + { + s = s.trim(); + if( 0 != s.length() ) + _inspectorTyrant.setNewRootNode(s); + } + // update done on notification... + } + else if( cmd.equals(EVAL_CMD) ) + { + if( ControlTyrant.STOPPED != _controlTyrant.getState() ) + return; + + String s = _textfield.stringValue(); + if( null != s ) + { + s = s.trim(); + if( 0 != s.length() ) + { + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.EVAL_STRING), + s ); + } + } + } + else if( cmd.equals(ADD_WATCH_CMD) ) + { + String s = _textfield.stringValue(); + if( null != s ) + { + s = s.trim(); + if( 0 != s.length() ) + { + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.WATCH_STRING), + s ); + } + } + } + else if( cmd.equals(COPY_NAME_CMD) ) + { + InspectorListItem item = (InspectorListItem)_listview.selectedItem(); + if( null != item ) + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.COPY_STRING), + item.getModel().getFullName() ); + } + else if( cmd.equals(COPY_VALUE_CMD) ) + { + InspectorListItem item = (InspectorListItem)_listview.selectedItem(); + if( null != item ) + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.COPY_STRING), + item.getModel().getValue() ); + } + else if( cmd.equals(DONE_CMD) ) + { + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.INSPECTOR_SHOW_HIDE), + this ); + } + } + + public synchronized void refresh() + { + _emperor.setWaitCursor(true); + + _listview.removeAllItems(); + + InspectorNodeModel model = _inspectorTyrant.getRootNode(); + + String text = null; + if( null != model ) + { + text = model.getName(); + InspectorListItem item = new InspectorListItem( _drawer, model ); + item.setSelectedColor(_emperor.getSelectionColor()); + _listview.addItem( item ); + + if( model.hasProperties() ) + expandItem(0,false); + + _listview.selectItemAt(0); + } + + _textfield.cancelEditing(); + _textfield.setStringValue(text); + _textfield.setInsertionPoint(null == text ? 0 : text.length()); + _textfield.setFocusedView(); + + if( _fixupSizes() ) + layoutView(0,0); + _listview.draw(); + + _emperor.setWaitCursor(false); + } + + private boolean _fixupSizes() + { + int minLeft = 0; + int minRight = 0; + + int count = _listview.count(); + + for( int i = 0; i < count; i++ ) + { + InspectorListItem next = (InspectorListItem) _listview.itemAt(i); + minLeft = Math.max(minLeft, next.minLeftWidth()); + minRight = Math.max(minRight, next.minRightWidth()); + } + _drawer.setLeftWidth(minLeft); + _listview.setBounds(0,0,minLeft+1+minRight,0); + _listview.sizeToMinSize(); + return true; + } + + private void _pushItemToTop(int index) + { + Rect rectitem = _listview.rectForItemAt(index); + // if(ASS)System.out.println("rectitem.y "+rectitem.y); + ((ScrollView)(_listview.superview())).scrollBy( 0, -rectitem.y ); + } + + + public void expandItem(int index, boolean draw) + { + _emperor.setWaitCursor(true); + + InspectorListItem item = (InspectorListItem) _listview.itemAt(index); + InspectorNodeModel parent = item.getModel(); + + parent.expand(); + + InspectorNodeModel child = parent.getFirstChild(); + boolean anyChildren = null != child; + int cur = index; + while( null != child ) + { + item.setCollapsed(false); + InspectorListItem newitem = new InspectorListItem( _drawer, child ); + _listview.insertItemAt( newitem, ++cur ); + newitem.setSelectedColor(_emperor.getSelectionColor()); + child = child.getNextSib(); + } + + if( draw && anyChildren ) + { + if( _fixupSizes() ) + layoutView(0,0); + _pushItemToTop(index); + _listview.draw(); + } + + _emperor.setWaitCursor(false); + } + + public void collapseItem(int index, boolean draw) + { + InspectorListItem item = (InspectorListItem) _listview.itemAt(index); + InspectorNodeModel parent = item.getModel(); + + item.setCollapsed(true); + + int count = _listview.count(); + + for( int i = index+1; i < count; i++ ) + { + InspectorListItem next = (InspectorListItem) _listview.itemAt(index+1); + if( ! next.getModel().isAncestor(parent) ) + break; + _listview.removeItemAt(index+1); + } + + if( draw ) + { + if( _fixupSizes() ) + layoutView(0,0); + _listview.scrollItemAtToVisible(index); + _listview.draw(); + } + } + + /******************************************/ + + public boolean canCopy() + { + if( null == _textfield ) + return false; + if( ! _textfield.isEditable() ) + return false; + if( ! isMain() ) + return false; + // the problem with this is that we're not getting notified when + // a selection does happen. Rather than failing to notify commandTyrant + // when we later become copyable, we'd rather lie and say that we're + // copyable even if we aren't really (yet)... + // + // XXX fixing this with a proper notification would be good. + // +// return _textfield.hasSelection(); + return true; + } + + public String copy() + { + if( ! canCopy() ) + return null; + return _textfield.stringForRange( _textfield.selectedRange() ); + } + + public String cut() + { + if( ! canCopy() ) + return null; + Range r = _textfield.selectedRange(); + String retval = _textfield.stringForRange(r); + _textfield.replaceRangeWithString(r, ""); + _textfield.setInsertionPoint(r.index); + return retval; + } + + public boolean canPaste() + { + if( null == _textfield ) + return false; + if( ! _textfield.isEditable() ) + return false; + if( ! isMain() ) + return false; + return true; + } + + public void paste(String s) + { + if( null == s || 0 == s.length() ) + return; + if( ! canPaste() ) + return; + Range r = _textfield.selectedRange(); + _textfield.replaceRangeWithString(r, s); + _textfield.setInsertionPoint(r.index + s.length()); + } + + /******************************************/ + + private Emperor _emperor; + private InspectorTyrant _inspectorTyrant; + private ControlTyrant _controlTyrant; + private CommandTyrant _commandTyrant; + private InspectorListView _listview; + private TextField _textfield; + private InspectorItemDrawer _drawer; + private int _listheight; + private EditKeyTextFilter _editKeyTextFilter; + + private Button _inspectButton; + private Button _evalButton; + + private static final String HIGHLIGHT_CMD = "HIGHLIGHT_CMD"; + private static final String INSPECT_CMD = "INSPECT_CMD"; + private static final String EVAL_CMD = "EVAL_CMD"; + private static final String ADD_WATCH_CMD = "ADD_WATCH_CMD"; + private static final String COPY_NAME_CMD = "COPY_NAME_CMD"; + private static final String COPY_VALUE_CMD = "COPY_VALUE_CMD"; + private static final String DONE_CMD = "DONE_CMD"; + + private static final boolean ASS = true; // enable ASSERT support? +} + +/***************************************************************************/ + +final class InspectorListView extends SmartItemListView +{ + public InspectorListView( InspectorView iv ) + { + _iv = iv; + } + public InspectorView getInspectorView() {return _iv;} + + public void setMousedItem(InspectorListItem item ) {_mousedItem = item;} + public InspectorListItem getMousedItem() {return _mousedItem;} + + private InspectorView _iv; + private InspectorListItem _mousedItem; + + private static final boolean ASS = true; // enable ASSERT support? +} + +/***************************************************************************/ + +final class InspectorListItem extends SmartListItem +{ + + public InspectorListItem( InspectorItemDrawer drawer, + InspectorNodeModel model ) + { + _drawer = drawer; + _model = model; + + Size sz = _drawer.sizeForRightText(_model.getValue()); + _height = sz.height; + _rightWidth = sz.width; + _leftWidth = _drawer.widthForLeftText(_model.getName(),_model.getDepth()); + } + + public void drawInRect(Graphics g, Rect boundsRect) + { + drawBackground(g, boundsRect); + + _drawer.draw( g, boundsRect, this, _model ); + } + + // make this public to be called by our drawer helper + public void drawStringInRect( Graphics g, String title, + Font titleFont, Rect textBounds, + int justification) + { + super.drawStringInRect(g,title,titleFont,textBounds,justification); + } + + public int minLeftWidth() {return _leftWidth;} + public int minRightWidth() {return _rightWidth;} + + public boolean getCollapsed() {return _collapsed;} + public void setCollapsed(boolean b) {_collapsed = b;} + + public InspectorNodeModel getModel() {return _model;} + + + // override SmartListItem + public boolean mouseDown(MouseEvent me) + { + if( 1 != me.clickCount() || + me.isAltKeyDown() || + me.isControlKeyDown() || + me.isMetaKeyDown() || + me.isShiftKeyDown() || + ! _hitBox(me) ) + { + parent().setMousedItem(null); + } + else + parent().setMousedItem(this); + return super.mouseDown(me); + } + public void mouseUp(MouseEvent me) + { + if( 1 != me.clickCount() || + me.isAltKeyDown() || + me.isControlKeyDown() || + me.isMetaKeyDown() || + me.isShiftKeyDown() || + ! _hitBox(me) || + this != parent().getMousedItem() ) + + { + parent().setMousedItem(null); + super.mouseUp(me); + return; + } + + InspectorView iv = parent().getInspectorView(); + + if( _collapsed ) + iv.expandItem( parent().indexOfItem(this), true ); + else + iv.collapseItem( parent().indexOfItem(this), true ); + + parent().setMousedItem(null); + super.mouseUp(me); + } + + private boolean _hitBox(MouseEvent me) + { + if( ! _model.hasProperties() ) + return false; + Rect r = myRect(); + Rect box = _drawer.boxForDepth( _model.getDepth() ); + box.moveBy(r.x, r.y); + return box.contains(me.x, me.y); + } + + // override ListItem + public int minWidth() + { + return _leftWidth + _rightWidth + 1; // XXX + } + + + // override ListItem + public int minHeight() + { + return _height; + } + + private InspectorListView parent() + { + return (InspectorListView) listView(); + } + + + private boolean _collapsed = true; + private int _height; + private int _leftWidth; + private int _rightWidth; + private InspectorItemDrawer _drawer; + private InspectorNodeModel _model; + + private static final boolean ASS = true; // enable ASSERT support? +} + +/***************************************************************************/ + +final class InspectorItemDrawer +{ + + public InspectorItemDrawer( Font font) + { + _font = font; + + // calc sizes + + _fm = _font.fontMetrics(); + _fontDX = _fm.charWidth('X'); + _fontDY = _fm.height(); + _fontSpacingDY = 1; + _singleLineItemDY = _fontDY + (_fontSpacingDY*1); + + _lineCenterY = _singleLineItemDY / 2; + _boxY = _lineCenterY - (_boxDim / 2); + +// System.out.println("_fontDY " + _fontDY); +// System.out.println("_fontSpacingDY " + _fontSpacingDY); +// System.out.println("_singleLineItemDY " + _singleLineItemDY); +// System.out.println("_lineCenterY " + _lineCenterY); +// System.out.println("_boxY " + _boxY ); + + } + + public void draw( Graphics g, + Rect boundsRect, + InspectorListItem item, + InspectorNodeModel model ) + { + Rect r = new Rect(); + int depth = model.getDepth(); + + + // draw grids + g.setColor(_gridColor); + int horizGridY = boundsRect.y + boundsRect.height - 1; + int vertGridX = boundsRect.x + _leftDX; + g.drawLine( boundsRect.x, + horizGridY, + boundsRect.x + boundsRect.width, + horizGridY); + + g.drawLine( vertGridX, + boundsRect.y, + vertGridX, + boundsRect.y + boundsRect.height); + + + // draw box + + if( model.hasProperties() ) + { + g.setColor(_boxColor); + int lineX = boundsRect.x + _boxX(depth); + int lineY = _lineCenterY + boundsRect.y; + g.drawRect( lineX, _boxY + boundsRect.y , _boxDim, _boxDim ); + g.drawLine( lineX + 2, lineY, lineX + _boxDim - 3, lineY ); + if( item.getCollapsed() ) + { + int armlen = (_boxDim / 2) - 2; + lineX += _boxDim / 2; + g.drawLine( lineX, lineY - armlen, lineX, lineY + armlen ); + } + } + + // draw lines + + g.setColor(_lineColor); + if( null != model.getParent() ) + { + int x0 = (boundsRect.x + _boxX(depth-1)) + (_boxDim/2); + int x1 = (boundsRect.x + _boxX(depth)) - 2; + int x2 = (boundsRect.x + _boxX(depth)) + _boxDim; + int y = _lineCenterY + boundsRect.y; + + if( model.hasProperties() ) + g.drawLine( x0, y, x1, y ); + else + g.drawLine( x0, y, x2, y ); + + if( null == model.getNextSib() ) + g.drawLine( x0, boundsRect.y, x0, y ); + else + g.drawLine( x0, boundsRect.y, x0, boundsRect.y + boundsRect.height); + } + if( null != model.getFirstChild() ) + { + int x = boundsRect.x + _boxX(depth) + (_boxDim/2); + int y0 = boundsRect.y + _boxY + _boxDim; + int y1 = boundsRect.y + boundsRect.height; + g.drawLine( x, y0, x, y1 ); + } + + // draw in other crossing lines here... + + int crosslineDepth = depth-2; + InspectorNodeModel p = model.getParent(); + while(null != p) + { + if( null != p.getNextSib() ) + { + int x = boundsRect.x + _boxX(crosslineDepth) + (_boxDim/2); + g.drawLine( x, boundsRect.y, x, boundsRect.y + boundsRect.height ); + } + crosslineDepth-- ; + p = p.getParent(); + } + + // draw left text + + String name = model.getName(); + if( null != name && 0 != name.length() ) + { + int x = _boxX(depth) + _boxDim + _fontDX; + r.setBounds( boundsRect.x + x, + boundsRect.y + _fontSpacingDY, + boundsRect.width - x, + boundsRect.height - _fontSpacingDY ); + + if( r.intersects( g.clipRect() ) ) + { + item.setTextColor(_leftTextColor); + item.drawStringInRect(g,name,_font,r,Graphics.LEFT_JUSTIFIED); + } + } + + // draw right text + + String value = model.getValue(); + if( null != value && 0 != value.length() ) + { + int x = _leftDX + _spacerDX; + r.setBounds( boundsRect.x + x, + boundsRect.y + _fontSpacingDY, + boundsRect.width - x, + boundsRect.height - _fontSpacingDY ); + + if( r.intersects( g.clipRect() ) ) + { + if( "function".equals(model.getType()) ) + item.setTextColor(_rightTextFunctionColor); + else + item.setTextColor(_rightTextColor); + item.drawStringInRect(g,value,_font,r,Graphics.LEFT_JUSTIFIED); + } + } + + + } + + public int getLeftWidth() {return _leftDX;} + public void setLeftWidth(int n) {_leftDX = n;} + public int getRightWidth() {return _rightDX;} + public void setRightWidth(int n) {_rightDX = n;} + + public int widthForLeftText( String s, int depth ) + { + return _boxX(depth) + _boxDim + _fontDX + _fm.stringWidth(s) + _fontDX ; + } + + public Size sizeForRightText( String s ) + { + return new Size(_fontDX + _fm.stringWidth(s), _singleLineItemDY); // XXX + } + + public Rect boxForDepth( int depth ) + { + return new Rect( _boxX(depth), _boxY, _boxDim, _boxDim ); + } + + private final int _boxX( int depth ) {return _spacerDX + (_boxDim * depth);} + + /***********/ + + private Font _font; + private FontMetrics _fm; + private int _leftDX; + private int _rightDX; + private int _fontDX; + private int _fontDY; + private int _fontSpacingDY; + private int _singleLineItemDY; + private int _boxY; + private int _lineCenterY; + + private static final Color _leftTextColor = Color.black; + private static final Color _rightTextColor = Color.red; + private static final Color _rightTextFunctionColor = Color.blue; + private static final Color _fontColor = Color.black; + private static final Color _gridColor = Color.blue; + private static final Color _lineColor = Color.gray; + private static final Color _boxColor = Color.black; + + private static final int _spacerDX = 5; + private static final int _spacerDY = 3; + + private static final int _boxDim = 11; + + private static final boolean ASS = true; // enable ASSERT support? +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/JSDebuggerApp.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/JSDebuggerApp.java new file mode 100644 index 00000000000..cbc03cd04b5 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/JSDebuggerApp.java @@ -0,0 +1,709 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.io.*; +import java.awt.Dimension; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.api.*; +import netscape.javascript.*; +import netscape.security.PrivilegeManager; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.toolbar.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.toolTip.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.PopupButton; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.util.AssertFailureHandler; + + +public class JSDebuggerApp + extends Application + implements Target, AssertFailureHandler, EmperorOwner +{ + private static final boolean WILL_EXPIRE = false; + private static final boolean IS_INTERNAL_RELEASE = true; + private static final boolean ALWAYS_SHOW_BUILD_DATE = true; + + // "15 Sep 1997" -> 874306800000L // PR1 date + // "31 Oct 1997" -> 878284800000L // PR2 date + // "31 Mar 1998" -> 891331200000L // 1.1 PR1 Date (proposed) + private static final long _deathTime = 891331200000L; + + public static final int MAJOR_VERSION = 1; + public static final int MINOR_VERSION = 2; + public static final int PREVIEW_VERSION = 1; + + private static final String _mainTitleLocal = "Netscape JavaScript Debugger"; +// private static final String _mainTitleLocal = "(CLIENT) Netscape JavaScript Debugger"; + private static final String _mainTitleServer = "(SERVER) Netscape JavaScript Debugger"; + private static final String _mainTitleRhino = "Netscape JavaScript for Java Debugger"; + + // this is usually the string literal version of Emperor 'modes' + // -- parsed below -- + public void setMode(String s) + { + if(ASS)ER.T(null==_emperor, "attempt to setMode while running", this); + _modeString = s; + } + public void setHost(String s) + { + if(ASS)ER.T(null==_emperor, "attempt to setHost while running", this); + _host = s; + } + + // override Application.init() + public void init() + { + super.init(); + initForReal(); + } + + private void initForReal() + { +// System.out.println("++++ initForReal() start" ); + + // Let's ask for everything upfront to get this all out of the + // way (from the user's point of view) + try + { + PrivilegeManager.enablePrivilege("Debugger"); + PrivilegeManager.enablePrivilege("UniversalFileRead"); + + // It doesn't really matter that much if the user says no to + // these (at this point) + try + { + PrivilegeManager.enablePrivilege("UniversalFileWrite"); + PrivilegeManager.enablePrivilege("UniversalTopLevelWindow"); + } + catch(Exception e) + { + // just eat these + } + + } + catch(Exception e) + { + performCommandLater( this, LOAD_FAILED_CMD, null ); + return; + } + + if(ASS) + { + Thread t = Thread.currentThread(); + _uiThreadForAssertCheck = t; + ER.setFailureHandler(t,this); + } + + // set some static globals... + Env.Init(); + + // we don't want to spit this info to the console if not an applet + if( isApplet() ) + { + int platform = Env.getCoursePlatformType(); + + System.out.println("JSD platform is " + + (platform == Env.ENV_WIN ? + "Windows" : + platform == Env.ENV_MAC ? + "Mac" : + "Unix" )); + System.out.println("JSD install directory: " + Env.getCodebaseDir()); + System.out.println("JSD prefs directory: " + Env.getPrefsDir()); + } + + // set mode + if(null == _modeString) + _modeString = parameterNamed( "DebugHostMode" ); + + if(null != _modeString) + { + if( _modeString.equals("LOCAL") ) + _mode = Emperor.LOCAL; + else if( _modeString.equals("REMOTE_SERVER") ) + _mode = Emperor.REMOTE_SERVER; + else if( _modeString.equals("RHINO") ) + _mode = Emperor.RHINO; + else + _mode = Emperor.LOCAL; + } + else + _mode = Emperor.LOCAL; + + // set host (this may be further massaged below... + + if(null == _host) + _host = parameterNamed( "DebugHost" ); + + // init the system that will allow us access to the startup prefs file + // this needs to be done after our mode is established + _initStartupPrefs(); + + if(ASS) + { + if( Emperor.LOCAL == _mode ) + Log.setFilename("jsdclog.log", true); + else + Log.setFilename("jsdslog.log", true); + Log.setEnabled(true); + Log.setEnabledType(Log.ERROR, true); + Log.setEnabledType(Log.WARN, true); + Log.setEnabledType(Log.TRACE, false); + Log.setShowDate(true); + Log.setShowThreadName(true); + Log.setLogToFile(true); + Log.setLogToConsole(false); + Log.log(null, "+++++++++++++++ startup begin +++++++++++++++" ); + // we don't want to spit this info to the console if not an applet + if( isApplet() ) + System.out.println("JSD is using log file: " + Log.getFilename()); + } + else + { + Log.setEnabled(false); + } + + _mainWindow = new ToolTipExternalWindow(); + + Dimension res = AWTCompatibility.awtToolkit().getScreenSize(); + _mainWindow.setBounds(0, 0, 525, res.height - 50); + + if( Emperor.REMOTE_SERVER == _mode ) + _mainWindow.setTitle(_mainTitleServer); + else if( Emperor.RHINO == _mode ) + _mainWindow.setTitle(_mainTitleRhino); + else + _mainWindow.setTitle(_mainTitleLocal); + + setMainRootView(_mainWindow.rootView()); + + _mainWindow.show(); + setWaitCursor(true); + + StatusWindow statusWindow = new StatusWindow(); + statusWindow.setText("Loading..."); + statusWindow.show(); + + if( WILL_EXPIRE && daysTillDeath() <= 0 ) + { + setWaitCursor(false); + Alert.runAlertInternally( Alert.warningImage(), + "Error", + "This Preview copy of Netscape JavaScript Debugger has expired\n" + + "Please go to the Netscape home site to get a new version\n" + + "\n" + + " The debugger will exit now...", + "OK", null, null ); + performCommandLater( this, LOAD_FAILED_CMD, null ); + return; + } + + if( staleTwisterClassesFound() ) + { + setWaitCursor(false); + Alert.runAlertInternally( Alert.warningImage(), + "Error", + "Conflict with obsolete Java classes detected.\n" + + "\n" + + "Netscape Visual JavaScript Preview Release 1 must be uninstalled\n" + + "before the Netscape JavaScript Debugger can be run.\n" + + "\n" + + "Please see the Debugger release notes for additional information\n" + + "\n" + + " The debugger will exit now...", + "OK", null, null ); + performCommandLater( this, LOAD_FAILED_CMD, null ); + return; + } + +// statusWindow.setText("Checking License..."); +// if( ! userHasAgreedToLicense() ) +// { +// performCommandLater( this, LOAD_FAILED_CMD, null ); +// return; +// } +// statusWindow.setText("Loading..."); + + if( Emperor.REMOTE_SERVER == _mode && null == _host ) + { + String hostname = _readHostName(); + HostNameDialog dlg = new + HostNameDialog("Choose Server", + "Enter Hostname or ip address of Server", + hostname); + while(true) + { + statusWindow.hide(); + setWaitCursor(false); + dlg.showModally(); + setWaitCursor(true); + + if( HostNameDialog.OK == dlg.getKeyPressed() ) + { + statusWindow.show(); + statusWindow.setText("Looking for Server..."); + hostname = dlg.getHostName(); + _host = "http://" + hostname; + if( isDebuggingSupported() ) + break; + + setWaitCursor(false); + if( Alert.DEFAULT_OPTION == + Alert.runAlertInternally( Alert.warningImage(), + "Error", + "JavaScript Debugger support was not found in "+ _host+"\n" + + "\n" + + "Try a different Server?", + "Yes", "No", null ) ) + { + setWaitCursor(true); + continue; + } + setWaitCursor(true); + _host = null; + break; + } + else if( HostNameDialog.LOCALHOST == dlg.getKeyPressed() ) + { + statusWindow.show(); + hostname = "127.0.0.1"; + _host = "http://" + hostname; + break; + } + else // if( HostNameDialog.CANCEL == dlg.getKeyPressed() ) + { + statusWindow.show(); + _host = null; + break; + } + } + + if( null == _host ) + { + performCommandLater( this, LOAD_FAILED_CMD, null ); + return; + } + statusWindow.setText("Looking for Server..."); + _writeHostName(hostname); + } + + if( ! isDebuggingSupported() ) + { + String core_msg; + String suggestion; + + if( Emperor.LOCAL == _mode ) + { + core_msg = "JavaScript Debugger support was not found in this copy of Navigator"; + suggestion = ""; + } + + else + { + core_msg = "JavaScript Debugger support was not found in "+ _host; + suggestion = "If the server has been restarted, then it may be necessary\n" + + "to restart Navigator in order to re-establish the connection\n\n"; + } + + setWaitCursor(false); + Alert.runAlertInternally( Alert.warningImage(), + "Error", + core_msg + + "\n\n" + + suggestion + + "Please see the Debugger release notes for troubleshooting information\n" + + "\n" + + " The debugger will exit now...", + "OK", null, null ); + performCommandLater( this, LOAD_FAILED_CMD, null ); + return; + } + + if( Emperor.REMOTE_SERVER == _mode ) + statusWindow.setText("Found Server..."); + + Menu mainMenu = new Menu(true); + MenuView menuView = new MenuView(mainMenu); + MenuItem fileMenu = mainMenu.addItemWithSubmenu("File"); + MenuItem item; + + _emperor = new Emperor( this, _mainWindow, mainMenu, fileMenu, + menuView, _mode, _host, statusWindow ); + + addSeparator(fileMenu); + item = fileMenu.submenu().addItem("Exit", EXIT_APP_CMD, this); + + MenuItem helpMenu = mainMenu.addItemWithSubmenu("Help"); + item = helpMenu.submenu().addItem("About", SHOW_ABOUT_CMD, this); + + menuView.sizeToMinSize(); + _mainWindow.setMenuView(menuView); + _mainWindow.menuView().setDirty(true); + + statusWindow.hide(); + setWaitCursor(false); + + if(ASS)Log.log(null, "startup success" ); + _signalInitSuccessToHTMLPage(); +// System.out.println("++++ initForReal() end" ); + } + + + /* + * Temporary method to add menu item separators until IFC gets a native one.... + */ + private static void addSeparator(MenuItem item) + { + item.submenu().addSeparator(); +// AWTCompatibility.awtMenuForMenu(item.submenu()).addSeparator(); + } + + // implement Target interface + public void performCommand( String cmd, Object theObject ) + { + if( cmd.equals(EXIT_APP_CMD) ) + { + if( null != _mainWindow ) + _mainWindow.hide(); + } + else if( cmd.equals(LOAD_FAILED_CMD) ) + { + if( null != _mainWindow ) + _mainWindow.hide(); + // close the applet that owns us + try + { + JSObject jso = JSObject.getWindow( AWTCompatibility.awtApplet() ); + if( null != jso ) + jso.eval( "window.close()" ); + } + catch(Throwable t){} // eat failure + } + else if( cmd.equals(SHOW_ABOUT_CMD) ) + { + showAboutDialog(); + } + } + + // assumes that wait cursor is showing!!! + private boolean userHasAgreedToLicense() + { + if(ASS)ER.T(_waitCount == 1,"hasUserAgreedToLicense() called when _waitCount != 1"); + + String baseDir = Env.getCodebaseDir(); + if( null == baseDir ) + { + System.err.println( "failed to get CodebaseDir, can't show license"); + return false; + } + + String acceptFilename = baseDir + + "accept_"+MAJOR_VERSION+""+MINOR_VERSION + + (PREVIEW_VERSION != 0 ? ("_pr"+PREVIEW_VERSION):"") + + ".txt"; + + if( new java.io.File(acceptFilename).exists() ) + return true; + + String licenseHtmlFilename = baseDir+"license.html"; + + LicenseViewer v = + new LicenseViewer("Netscape JavaScript Debugger License", licenseHtmlFilename); + + if( ! v.HtmlLoadedSuccesfully() ) + { + setWaitCursor(false); + int answer = Alert.runAlertInternally( Alert.warningImage(), + "Error", + "Unable to load license text from\n" + + licenseHtmlFilename + + "\n" + + "\n" + + "license.html should be in the same directory as the debugger start page.\n" + + "\n" + + " Do you accept the terms of the license?", + "I Accept", "Cancel", null ); + setWaitCursor(true); + return Alert.DEFAULT_OPTION == answer; + } + + setWaitCursor(false); + v.showModally(); + setWaitCursor(true); + + if(v.userPressedAccept()) + { + try + { + // write a zero length file + new FileOutputStream(acceptFilename).close(); +// DataOutputStream dos = +// new DataOutputStream(new FileOutputStream(acceptFilename)); +// dos.writeBytes("accepted"); +// if( null != dos ) +// dos.close(); + } + catch(Exception e) + { + // eat it... + } + return true; + } + return false; + } + + private void showAboutDialog() + { + String title = "About"; + String msg; + + msg = "Netscape JavaScript Debugger\n"; + msg += "Version "+MAJOR_VERSION+"."+MINOR_VERSION; + if( PREVIEW_VERSION != 0 ) + msg += " Preview Release "+PREVIEW_VERSION; + msg += "\n\n"; + if(ASS || IS_INTERNAL_RELEASE || ALWAYS_SHOW_BUILD_DATE) + msg += "Built: "+BuildDate.display()+"\n\n"; + if( WILL_EXPIRE ) + msg += "This software will expire in "+ daysTillDeath() +" days\n\n"; + msg += "This software is subject to the terms\n"; + msg += "of the accompanying license agreement.\n"; + + Alert.runAlertInternally( title, msg, "OK", null, null ); + + } + + public boolean isDebuggingSupported() + { + return Emperor.isDebuggingSupported(_mode, _host); + } + + private void _initStartupPrefs() + { + String prefsDir = Env.getPrefsDir(); + if( null == prefsDir ) + return; + + String startupPrefsFullFilename; + if( Emperor.LOCAL == _mode ) + startupPrefsFullFilename = prefsDir + _startupPrefsFilenameClient; + else + startupPrefsFullFilename = prefsDir + _startupPrefsFilenameServer; + + _startupPrefsFile = new java.io.File(startupPrefsFullFilename); + } + + + // NOTE: this is destructive write of just this one key=value pair + // This system will have to be improved if further pairs are needed. + private void _writeHostName(String hostname) + { + if( null == _startupPrefsFile ) + return; + + try + { + DataOutputStream dos = + new DataOutputStream(new FileOutputStream(_startupPrefsFile)); + dos.writeBytes(_LastServerHostNameKey+"="+hostname); + if( null != dos ) + dos.close(); + } + catch(Exception e) + { + // eat it... + } + } + + private String _readHostName() + { + String retval = "127.0.0.1"; + + if( null == _startupPrefsFile ) + return retval; + + // any existing prefs? + if( ! _startupPrefsFile.exists() ) + return retval; + + try + { + DataInputStream dis = + new DataInputStream(new FileInputStream(_startupPrefsFile)); + + String line; + String key = _LastServerHostNameKey+"="; + while( null != (line = dis.readLine()) ) + { + if( line.startsWith(key) ) + { + retval = line.substring(key.length()).trim(); + break; + } + } + if( null != dis ) + dis.close(); + } + catch(Exception e) + { + // eat it... + } + return retval; + } + + /* + * The scheme is that if the applet tag has a PARAM called "AppletInitProp", + * then we will use it to get the name of the window property to be set. + * We then set that window property to "1". + */ + + private void _signalInitSuccessToHTMLPage() + { + String initProp = parameterNamed( "AppletInitProp" ); + if( null == initProp ) + return; + + String expression = "window."+initProp+"=1"; + try + { + JSObject jso = JSObject.getWindow( AWTCompatibility.awtApplet() ); + if( null != jso ) + { +// System.out.println( "writing: " + expression ); + jso.eval( expression ); + } + } + catch(Throwable t){} // eat failure + } + + private int daysTillDeath() + { + long millisecondsTillDeath = _deathTime - new java.util.Date().getTime(); + return 1 + (int) (millisecondsTillDeath / (1000*60*60*24)); + } + + // this tries to run a method which was not present in Twister PR1 but + // is present in our jar. If this fails, then Twister PR1 is in the + // classpath (which is very bad for us). + private boolean staleTwisterClassesFound() + { + try + { + new com.netscape.jsdebugging.ifcui.palomar.widget.PopupButton(null,null,null,null,null).showLabel(false); + } + catch(Throwable t) + { + return true; + } + return false; + } + + // override Application.cleanup + public void cleanup() + { + if( null != _emperor ) + _emperor.IFC_cleanupCalled(); + super.cleanup(); + } + + // implement AssertFailureHandler + public int assertFailed( String msgRaw, String msgCooked, Object ob ) + { + if(ASS) + { + // All these single use vars are here because the code + // used to allow for internal or external dlgs (and may again) + Image img = Alert.questionImage(); + String title = "Assertion failed"; + String msg = msgCooked + "\n\n" + "(set debugger to catch \"com.netscape.jsdebugging.ifcui.palomar.util.DebuggerCaughtException\")"; + String opt1 = "Continue"; + String opt2 = "Abort"; + String opt3 = "Debug"; + + Log.error("Assertion failed", msgCooked ); + + int choice = Alert.runAlertExternally(img,title,msg,opt1,opt2,opt3); + + switch(choice) + { + case Alert.DEFAULT_OPTION: return AssertFailureHandler.CONTINUE; + case Alert.SECOND_OPTION: return AssertFailureHandler.ABORT; + case Alert.THIRD_OPTION: return AssertFailureHandler.DEBUG; + } + } + return AssertFailureHandler.DEBUG; + } + + // implement EmperorOwner + public void setWaitCursor(boolean set) + { + _waitCount += set ? 1 : -1; + + if(ASS)ER.T(_waitCount >= 0,"_waitCount went negative", this ); + if(ASS)ER.T(Thread.currentThread()==_uiThreadForAssertCheck,"setWaitCursor() called on non-UI thread",this); + + if( (1 == _waitCount && set) || (0 == _waitCount && !set) ) + { + Vector windows = externalWindows(); + int size = windows.size(); + for (int i= 0; i < size; i++) + { + ExternalWindow window = (ExternalWindow)windows.elementAt(i); + FoundationPanel panel = window.panel(); + + if (set) + panel.setCursor(View.WAIT_CURSOR); + else + panel.setCursor(View.ARROW_CURSOR); + } + } + } + + + /****************************************************/ + + // data... + + private ToolTipExternalWindow _mainWindow; + private InternalWindow _toolBarWindow; + private Emperor _emperor; + private String _modeString; + private int _mode; + private String _host; + private Thread _uiThreadForAssertCheck = null; + private int _waitCount = 0; + + private static final String _startupPrefsFilenameServer = "jsdsstrt.txt"; + private static final String _startupPrefsFilenameClient = "jsdcstrt.txt"; + private java.io.File _startupPrefsFile; + + private static final String _LastServerHostNameKey = "LastHost0"; + + private static final String EXIT_APP_CMD = "EXIT_APP_CMD"; + private static final String LOAD_FAILED_CMD = "LOAD_FAILED_CMD"; + private static final String SHOW_ABOUT_CMD = "SHOW_ABOUT_CMD"; + + private static final boolean ASS = true; // enable ASSERT support? +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/JSDebuggerApplet.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/JSDebuggerApplet.java new file mode 100644 index 00000000000..d47093377ac --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/JSDebuggerApplet.java @@ -0,0 +1,75 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import netscape.security.PrivilegeManager; + +public class JSDebuggerApplet extends FoundationApplet { + /** This method must be implemented by the applet developer because + * there is no way in the standard Java API for system classes (such as, + * netscape.application) to look up an applet's class by name. The + * static method Class.forName() simply looks up one level in the + * stack and gets the ClassLoader associated with the method block of the + * caller. + *

+ * When the netscape.application classes are installed as + * system classes, the ClassLoader is null. Thus, when code in + * netscape.application calls Class.forName() it can only find + * other system classes. + *

+ * The solution is an API that allows code to + * find the ClassLoader for an applet by URL, and a public API on + * ClassLoader to ask it to load classes by name. Until those + * enhancements can be made and distributed to all the world's Java + * systems, applets must subclass FoundationApplet and + * implement the following one-line method: + *

+      *     public abstract Class classForName(String className)
+      *         throws ClassNotFoundException {
+      *         return Class.forName(className);
+      *     }
+      * 
+ */ + public Class classForName(String className) + throws ClassNotFoundException { + return Class.forName(className); + } + + public void run() { + try { +// +// At one time I needed to have this priv. early on in the loading. +// +// I believe it was an issue when I was explicitly loading the native +// code from the debugger. +// +// This is no longer the case +// +// System.out.println( "first priv req start" ); +// PrivilegeManager.enablePrivilege("Debugger"); +// System.out.println( "first priv req end (success)" ); + super.run(); + } catch (Exception e) { + System.out.println("failed to enable Priv in JSDebuggerApplet.run"); + e.printStackTrace(System.out); + } + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/LicenseViewer.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/LicenseViewer.java new file mode 100644 index 00000000000..cf7f7651ae6 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/LicenseViewer.java @@ -0,0 +1,138 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 11/10/97 jband added this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import java.io.FileInputStream; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; + +class LicenseViewer + extends InternalWindow + implements Target +{ + private static final int _editDX = 400; + private static final int _editDY = 400; + private static final int _buttonDX = 80; + private static final int _buttonDY = 24; + private static final int _spacerDX = 5; + private static final int _spacerDY = 5; + + public LicenseViewer(String title, String licenseFilename) + { + setTitle(title); + setCloseable(true); + setResizable(false); + + int contentDX = _editDX + _spacerDX * 2; + int contentDY = _editDY + _buttonDY + _spacerDY * 3; + int labelY = _spacerDY; + int editY = _spacerDY * 1; + int buttonY = _editDY + _spacerDY * 2; + int editX = _spacerDX; + + int buttonX2 = contentDX - _spacerDX - _buttonDX; + int buttonX1 = buttonX2 - _spacerDX - _buttonDX; + + Size size = windowSizeForContentSize(contentDX, contentDY); + setBounds(0,0,size.width,size.height); + + _textView = new TextView(); + _textView.setEditable(false); + _textView.setSelectable(false); + try + { + FileInputStream fis = new FileInputStream(licenseFilename); + _textView.importHTMLInRange(fis, new Range(0,1),null); + } + catch(Exception e) + { + return; + } + + ScrollGroup sg = new ScrollGroup(new Rect(editX,editY,_editDX,_editDY)); + sg.setVertScrollBarDisplay(ScrollGroup.ALWAYS_DISPLAY); + sg.setHorizScrollBarDisplay(ScrollGroup.NEVER_DISPLAY); + sg.setContentView(_textView); + sg.setAutoResizeSubviews(true); + sg.contentView().setLayoutManager( new MarginLayout() ); + addSubview(sg); + + _textView.setBounds(0,0, + _editDX + - sg.border().leftMargin() + - sg.border().rightMargin() + - sg.vertScrollBar().width(), + 0); + + _HtmlLoadedSuccesfully = true; + + Button button; + + button = new Button(buttonX1,buttonY,_buttonDX,_buttonDY); + button.setTitle("I Accept"); + button.setTarget(this); + button.setCommand(ACCEPT_CMD); + addSubview(button); + + button = new Button(buttonX2,buttonY,_buttonDX,_buttonDY); + button.setTitle("Cancel"); + button.setTarget(this); + button.setCommand(CANCEL_CMD); + addSubview(button); + + center(); + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(ACCEPT_CMD) ) + { + _userPressedAccept = true; + hide(); + } + else if( cmd.equals(CANCEL_CMD) ) + { + hide(); + } + } + + public void showModally() + { + _userPressedAccept = false; + super.showModally(); + } + + public boolean userPressedAccept() {return _userPressedAccept;} + public boolean HtmlLoadedSuccesfully() {return _HtmlLoadedSuccesfully;} + + private boolean _userPressedAccept = false; + private boolean _HtmlLoadedSuccesfully = false; + private TextView _textView; + + private static final String CANCEL_CMD = "CANCEL_CMD"; + private static final String ACCEPT_CMD = "ACCEPT_CMD"; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Location.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Location.java new file mode 100644 index 00000000000..890c0d6bb3b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Location.java @@ -0,0 +1,126 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.api.JSSourceLocation; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; + +// XXX implementation note: we currently maintain a string representaion for +// quick lookups. This will change when the Breakpoint becomes more complex... + +import netscape.util.*; + +public class Location + implements Comparable, Codable +{ + + public Location( JSSourceLocation jssl ) + { + this( jssl.getURL(), jssl.getLine() ); + if(ASS)ER.T(null!=jssl,"null JSSourceLocation passed to Location ctor",this); + } + + public Location( String url, + int line ) + { + if(ASS)ER.T(null!=url,"null url in Location ctor",this); + if(ASS)ER.T(line >=0,"negative line in Location ctor",this); + + _url = url; + _line = line; + _stringRep = new String( _url + "#" + _line ); + } + + // for Codable + public Location() {} + + public String getURL() {return _url; } + public int getLine() {return _line;} + + // override Object + public String toString() + { + return _stringRep; + } + + // override Object + public boolean equals(Object obj) + { + if(ASS)ER.T(obj!=null,"null obect handed to Location equals",this); + if(ASS)ER.T(obj instanceof Location,"non-Location obect handed to Location equals",this); + + Location other = (Location) obj; + if( _stringRep.equals(other._stringRep) ) + return true; + return false; + } + + // override Object + public int hashCode() + { + return 13*_url.hashCode() + 17*_line; + } + + // implement Comparable + public int compareTo(Object obj) + { + if(ASS)ER.T(obj!=null,"null obect handed to Location compareTo",this); + if(ASS)ER.T(obj instanceof Location,"non-Location object handed to Location compareTo",this); + + Location other = (Location) obj; + int retval = _url.compareTo( other._url ); + if( 0 == retval ) + retval = _line - other._line; + return retval; + } + + // implement Codable + public void describeClassInfo(ClassInfo info) + { + info.addField("_url", STRING_TYPE); + info.addField("_line", INT_TYPE); + } + public void encode(Encoder encoder) throws CodingException + { + encoder.encodeString("_url", _url); + encoder.encodeInt("_line", _line); + } + public void decode(Decoder decoder) throws CodingException + { + _url = decoder.decodeString("_url"); + _line = decoder.decodeInt("_line"); + } + public void finishDecoding() throws CodingException + { + _stringRep = new String( _url + "#" + _line ); + } + + private String _url; + private int _line; + private String _stringRep; + + private static final boolean ASS = true; // enable ASSERT support? +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Log.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Log.java new file mode 100644 index 00000000000..4cc2ed3a11b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Log.java @@ -0,0 +1,242 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 09/30/97 jband created file +// + +package com.netscape.jsdebugging.ifcui; + +import java.io.*; +import java.util.Date; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; + +public final class Log +{ + public static final int ERROR = 0; // must start at 0 and be contiguous + public static final int WARN = 1; + public static final int TRACE = 2; + public static final int LOG = 3; + public static final int TYPE_COUNT = 4; // count of above + + + public static void error(String poster, String msg) + { + if( _enabled && _typeEnabled[ERROR] ) + _write( ERROR, poster, msg ); + } + + public static void warn(String poster, String msg) + { + if( _enabled && _typeEnabled[WARN] ) + _write( WARN, poster, msg ); + } + + public static void trace(String poster, String msg) + { + if( _enabled && _typeEnabled[TRACE] ) + _write( TRACE, poster, msg ); + } + + public static void log(String poster, String msg) + { + if( _enabled && _typeEnabled[LOG] ) + _write( LOG, poster, msg ); + } + + public static synchronized void _write(int type, String poster, String msg) + { + String buf = ""; + if( _showDate ) + buf += "[" + new Date().toString() + "] "; + buf += "\"" + _typeName[type] + "\": "; + if( null != poster ) + buf += "poster: " + "\"" + poster + "\" "; + if( _showThreadName ) + buf += "thread: " + "\"" + Thread.currentThread().getName() + "\" "; + buf += "msg: " + "\"" + msg + "\""; + + if( _logToFile ) + _writeToLogfile(buf+"\n"); + if( _logToConsole ) + System.out.println(buf); + } + + public static boolean getEnabled() + { + return _enabled; + } + + public static synchronized void setEnabled(boolean enabled) + { + _enabled = enabled; + } + + public static boolean getEnabledType(int type) + { + return _typeEnabled[type]; + } + + public static synchronized void setEnabledType(int type, boolean enabled) + { + _typeEnabled[type] = enabled; + } + + public static boolean getShowDate() + { + return _showDate; + } + + public static synchronized void setShowDate(boolean b) + { + _showDate = b; + } + + public static boolean getShowThreadName() + { + return _showThreadName; + } + + public static synchronized void setShowThreadName(boolean b) + { + _showThreadName = b; + } + + public static String getFilename() + { + return _fullFilename; + } + public static synchronized void setFilename(String filename, boolean useCodebase) + { + if(ASS)ER.T(null==_fullFilename,"tried to set filename after first log entry written"); + _baseFilename = filename; + _useCodebase = useCodebase; + _generateFilename(); + } + + public static boolean getLogToFile() + { + return _logToFile; + } + public static synchronized void setLogToFile(boolean logToFile) + { + _logToFile = logToFile; + } + + public static boolean getLogToConsole() + { + return _logToConsole; + } + public static synchronized void setLogToConsole(boolean logToConsole) + { + _logToConsole = logToConsole; + } + + private static synchronized void _writeToLogfile(String s) + { + try + { + PrivilegeManager.enablePrivilege("UniversalFileWrite"); + PrivilegeManager.enablePrivilege("UniversalFileRead"); + _start(); + if( null != _out ) + _out.writeBytes(s); + _finish(); + } + catch( ForbiddenTargetException e ) + { + // eat it; + } + catch( IOException e ) + { + // eat it; + } + } + + private static boolean _start() + { + if( ! _generateFilename() ) + return false; + if( null == _out ) + { + try + { + _out = new DataOutputStream(new FileOutputStream(_fullFilename,true)); + } + catch( IOException e ) + { + // eat it + _out = null; + } + } + + return null != _out; + } + + private static void _finish() + { + if( null != _out ) + { + try + { + _out.flush(); + } + catch( IOException e ) + { + // eat it + } + } + } + + private static boolean _generateFilename() + { + if( null != _fullFilename ) + return true; + + if( _useCodebase ) + { + String dir = Env.getPrefsDir(); + + if( null == dir ) + return false; + _fullFilename = dir + _baseFilename; + } + else + _fullFilename = _baseFilename; + return true; + } + + + private static boolean _typeEnabled[] = {false,false,false,true}; + private static final String _typeName[] = {"error","warning","trace","log"}; + + private static boolean _enabled = true; + private static boolean _showDate = true; + private static boolean _showThreadName = false; + private static boolean _logToFile = true; + private static boolean _logToConsole = false; + private static DataOutputStream _out = null; + private static boolean _useCodebase = false; + private static String _fullFilename = null; + private static String _baseFilename = "jsdlog.log"; + + private static final boolean ASS = true; // enable ASSERT support? +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/MouseMenuView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/MouseMenuView.java new file mode 100644 index 00000000000..8c6e348c722 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/MouseMenuView.java @@ -0,0 +1,309 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Jennifer Lateiner + + +/** +* +* jband 11/1/97 +* +* Shamelessly stolen from com.netscape.jsdebugging.ifcui.palomar.widget.mdi +* We will use the 'real' version when it comes time to rely on +* that mdi code +*/ + +// package com.netscape.jsdebugging.ifcui.palomar.widget.mdi; +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; + +/** + * MouseMenuView.java + *

+ * Menu subclass for context menus, + * Defaults to Vertical + * + * NOTE: Fixed problem where mouseUp in bottom 5 pixels of menu + * were causing a null pointer exception by moving mouseEvent + * on MouseUp up 5 pixels when the event was in that region. + * + * Also note: getTitle on a menu displayed by MouseMenuView + * will have 4 leading spaces. + * + *

+ *  History:
+ *  07/30/97:  Created by Jenni
+ *  
+ * Comments to:
jenni@netscape.com
+ */ +public class MouseMenuView extends MenuView { + InternalWindow _window; + BezelBorder _border; + Font _menuFont; + final static Color winBlue = new Color(0, 0, 128); + + /** Constructs a MenuView with origin (0, 0) and zero width and height. + * This MenuView will create its own top-level Menu, will be of type + * HORIZONTAL, and will have no owner. + */ + public MouseMenuView() { + this(0, 0, 0, 0, null, null); + } + + /** Constructs a MouseMenuView with origin (0, 0) and zero width and height. + * This MouseMenuView will use aMenu to define its structure. This + * MouseMenuView's owner will be null. + */ + public MouseMenuView(Menu aMenu) { + this(0, 0, 0, 0, aMenu, null); + } + + /** Constructs a MouseMenuView with bounds (x, y, width, + * height). + */ + public MouseMenuView(int x, int y, int width, int height) { + this(x, y, width, height, null, null); + } + + /** Constructs a MouseMenuView with bounds (x, y, width, + * height). This MouseMenuView will use aMenu to define + * its structure, and will determine its type by whether or not + * aMenu is top-level. This MouseMenuView's owner will be null. + */ + public MouseMenuView(int x, int y, int width, int height, Menu aMenu) { + this(x, y, width, height, aMenu, null); + } + + + /** Creates a MouseMenuView with anOwner. + */ + public MouseMenuView(int x, int y, int width, int height, Menu aMenu, + MenuView anOwner) { + super(x, y, width, height, aMenu, anOwner); + + // Get menufont from preferences + // jband -- removed reliance on class I don't want... +// _menuFont = com.netscape.jsdebugging.ifcui.palomar.widget.Preferences.textFont; + _menuFont = Font.defaultFont(); + setType(VERTICAL); + } + + /** Creates the InternalWindow that is used by this MouseMenuView for + * displaying its Menu's MenuItems. We create the MenuWindow so that + * we can track it. + */ + protected InternalWindow createMenuWindow() { + + _window = new InternalWindow(0, 0, 0, 0); + _window.setType(InternalWindow.BLANK_TYPE); + _window.setLayer(InternalWindow.IGNORE_WINDOW_CLIPVIEW_LAYER+11); + _window.setCanBecomeMain(false); + _window.setScrollsToVisible(true); + + //window.setResizable(true); + return _window; + } + + /** Overridden to receive mouse up events; IFC was creating + * null pointer exceptions if there was a mouse up between the + * extreme bottom edge and the bottom of the last menu item. + * So we trap and translate for this case. + */ + public void mouseUp(MouseEvent event) { + try{ + if (event.y > bounds.height - 5) { + event.y -= 5; + } + /* + * This assumes that there was no clicked item because the up + * occured in a child. We trap an IFC 1.1.1 bug in Menus here. + */ + if(owner() == null && itemForPoint(event.x, event.y) == null) { + MenuView menuView = child; + MenuView tView; + + if(menuView != null) + tView = menuView; + else + tView = this; + + while (menuView != null) { + menuView = menuView.child; + if(menuView != null) + tView = menuView; + } + + if(tView != this) { + try { + if(rootView() != null) + tView.mouseUp(convertEventToView(tView, event)); + } catch (netscape.util.InconsistencyException e) { + // See note below about the mouseUp and being removed + // before events are processed. + return; + } + } + return; + } + + super.mouseUp(event); + } catch (java.lang.NullPointerException e) { + // There are cases when during the mouse up (which also removes the + // menuView) whereby the event isn't processed before the menu is + // removed. If this happens, the safest thing to do is to return + // without attempting to process. + // -Jenni + + //System.out.println("Menu already removed, returning without event"); + return; + } + } + + + /** Other menu views want this, but we dont! + * There is a quirk whereby autoscroll events can be sent + * after we are removed from the view hierarchy. + */ + public boolean wantsAutoscrollEvents() { + return false; + } + + + /** Displays the menu in its own InternalWindow + */ + public void show(RootView rootView, MouseEvent event) { + boolean canRightFlip=true; + int count; + Menu menu=menu(); + String tString; + + count = menu.itemCount(); + + _window.setRootView(rootView); + + /* Somewhat of a hack to set colors (and fonts?) + * quickly and easily. It was faster to do it here than + * elsewhere. + * + */ + +// jband 11/1/97 I don't want to have it do this... +// for (int i = 0; i < count; i++) { +// menu.itemAt(i).setSelectedColor(winBlue); +// menu.itemAt(i).setSelectedTextColor(Color.white); +// menu.itemAt(i).setFont(_menuFont); +// if(!menu.itemAt(i).isSeparator()) { +// if(!(tString = menu.itemAt(i).title()).startsWith(" ")) { +// menu.itemAt(i).setTitle(" "+tString); +// } +// } +// } + + if(!(menu().border() instanceof BezelBorder)){ + menu().setBorder(new BezelBorder(BezelBorder.RAISED_BUTTON)); + + } + + sizeToMinSize(); + + super.show(rootView, event); + + /* Move the menu over and to the left a little from the + * mouse event (which is the standard IFC + if(owner() == null) { + _window.setBounds(_window.bounds.x-5, _window.bounds.y-5, + _window.bounds.width, + _window.bounds.height); + } + */ + + if(_window.bounds.x + _window.bounds.width > + rootView.bounds.width) { + if(owner() == null) { + _window.setBounds(rootView.bounds.width - + _window.bounds.width, + _window.bounds.y, + _window.bounds.width, + _window.bounds.height); + } else if(owner() instanceof MouseMenuView) { + InternalWindow tWin=((MouseMenuView)(owner())).getWindow(); + _window.setBounds(tWin.bounds.x - + _window.bounds.width +3, + _window.bounds.y, + _window.bounds.width, + _window.bounds.height); + + canRightFlip = false; + + } + } + + if(_window.bounds.x < 0) { + if(owner() == null) { + _window.setBounds(0, + _window.bounds.y, + _window.bounds.width, + _window.bounds.height); + } else if(canRightFlip && owner() instanceof MouseMenuView) { + InternalWindow tWin=((MouseMenuView)(owner())).getWindow(); + _window.setBounds(tWin.bounds.x + + _window.bounds.width -3, + _window.bounds.y, + _window.bounds.width, + _window.bounds.height); + } + } + + if(_window.bounds.y + _window.bounds.height > + rootView.bounds.height) { + _window.setBounds(_window.bounds.x, + rootView.bounds.height - + _window.bounds.height, + _window.bounds.width, + _window.bounds.height); + } + + if(_window.bounds.y < 0) { + _window.setBounds(_window.bounds.x, + 0, + _window.bounds.width, + _window.bounds.height); + } + + } + + /** Returns the InternalWindow used to house the MouseMenuView + */ + public InternalWindow getWindow() { + return _window; + } + + + /** Overridden to provide a MouseMenuView. + */ + protected MenuView createMenuView(Menu theMenu) { + MenuView retval = ((MenuView) (new MouseMenuView(0, 0, 0, 0, theMenu, this))); +// retval.window(); + return retval; + } + + +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/PageListView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/PageListView.java new file mode 100644 index 00000000000..ba9aff32d06 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/PageListView.java @@ -0,0 +1,248 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import com.netscape.jsdebugging.api.*; + +public class PageListView + extends InternalWindow + implements Observer, Target +{ + public PageListView( Emperor emperor, Rect rect ) + { + super(rect); + + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + _sourceTyrant = emperor.getSourceTyrant(); + _commandTyrant = emperor.getCommandTyrant(); + _stackTyrant = emperor.getStackTyrant(); + + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_sourceTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_commandTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_stackTyrant ,"emperor init order problem", this); + + _listview = new BackgroundHackListView(); + + Size size = contentSize(); + Rect rectSG = new Rect(0, 0, size.width, size.height-40); + + int buttonWidth = 64; + int buttonHeight = 24; + int buttonY = rectSG.height + 40/2 - 24/2; + int button1X = rectSG.width - (buttonWidth*2 + 4*2); + int button2X = rectSG.width - (buttonWidth + 4); + + Button button; + button = new Button(button1X,buttonY,buttonWidth,buttonHeight); + button.setTitle("Open"); + button.setTarget(this); + button.setCommand(OPEN_CMD); + addSubview(button); + + button = new Button(button2X,buttonY,buttonWidth,buttonHeight); + button.setTitle("Done"); + button.setTarget(this); + button.setCommand(CLOSE_CMD); + addSubview(button); + + ScrollGroup sg = new ScrollGroup(rectSG); + sg.setHorizScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg.setVertScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg.setContentView( _listview ); + sg.setAutoResizeSubviews(true); + sg.contentView().setLayoutManager( new MarginLayout() ); + sg.setBackgroundColor(_emperor.getBackgroundColor()); + + setCloseable( false ); + setResizable( false ); + setTitle( "Open" ); + addSubview(sg); + setAutoResizeSubviews(true); +// contentView().setLayoutManager( new MarginLayout() ); + + _listview.setAllowsEmptySelection(true); + _listview.setAllowsMultipleSelection(false); + + _listview.setTarget(_commandTyrant); + _listview.setCommand(_commandTyrant.cmdString(CommandTyrant.PAGELIST_CLICK)); + _listview.setDoubleCommand(_commandTyrant.cmdString(CommandTyrant.PAGELIST_DBLCLICK)); + + _listview.setBackgroundColor(_emperor.getBackgroundColor()); + + _sourceTyrant.addObserver(this); + _controlTyrant.addObserver(this); + + setLayer(InternalWindow.PALETTE_LAYER); + + _refresh(); + + layoutView(1,1); + layoutView(-1,-1); + +// show(); + } + + // implement observer interface + public void update(Observable o, Object arg) + { + if( o == _sourceTyrant ) + { + SourceTyrantUpdate update = (SourceTyrantUpdate)arg; + switch( update.type ) + { + case SourceTyrantUpdate.VECTOR_CHANGED : + _refresh(); + break; + default: + break; // ignore any other types + } + } + else if ( o == _controlTyrant ) + { + // XXX update list on stop + } + + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(OPEN_CMD) ) + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.PAGELIST_DBLCLICK), + _listview ); + else if( cmd.equals(CLOSE_CMD) ) + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.PAGELIST_SHOW_HIDE), + this ); + } + + + public synchronized void _refresh() + { + boolean sort = _emperor.getHostMode() != Emperor.LOCAL; + + _listview.removeAllItems(); + + SourceTextItem[] array = _sourceTyrant.getSourceTextItemArray(); + + Font linefont = Font.defaultFont(); + int maxlinelen = 0; + + // if stopped, then try to select url of current frame + // else try to reselect current selection + String selectedURL = null; + if( ControlTyrant.STOPPED == _controlTyrant.getState() ) + { + JSSourceLocation loc = _stackTyrant.getCurrentLocation(); + if( null != loc ) + selectedURL = loc.getURL(); + } + if( null == selectedURL ) + { + SourceTextItem sel_item = _sourceTyrant.getSelectedSourceItem(); + if( null != sel_item ) + selectedURL = sel_item.getURL(); + } + + if( null != array ) + { + synchronized( array ) + { + for (int i = 0; i < array.length; i++) + { + SourceTextItem src = array[i]; + ListItem item = new ListItem(); + + String text = src.getURL(); + maxlinelen = Math.max( maxlinelen, text.length() ); + item.setTitle( text ); + item.setData( src ); + item.setFont( linefont ); + item.setSelectedColor(_emperor.getSelectionColor()); + + if(sort) + { + // do an insertion sort... + int count = _listview.count(); + int j; + for(j = 0; j < count; j++) + { + SourceTextItem other = (SourceTextItem)_listview.itemAt(j).data(); + if( text.compareTo(other.getURL()) < 0 ) + { + _listview.insertItemAt(item,j); + break; + } + } + if( j == count ) + _listview.addItem(item); + } + else + { + _listview.addItem(item); + } + + if( null != selectedURL && selectedURL.equals(src.getURL()) ) + _listview.selectItem(item); + } + } + } + FontMetrics fm = linefont.fontMetrics(); + _listview.setBounds( 0, 0, (maxlinelen+1) * fm.charWidth('X'),0 ); + _listview.sizeToMinSize(); + + layoutView(0,0); + _listview.draw(); + } + + public static SourceTextItem sourceTextItemForListItem( ListItem li ) + { + return (SourceTextItem)li.data(); + } + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + private SourceTyrant _sourceTyrant; + private StackTyrant _stackTyrant; + private CommandTyrant _commandTyrant; + private ListView _listview; + + private static final String CLOSE_CMD = "CLOSE_CMD"; + private static final String OPEN_CMD = "OPEN_CMD"; + + private static final boolean ASS = true; // enable ASSERT support? +} + + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/PrefsSupport.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/PrefsSupport.java new file mode 100644 index 00000000000..48c333e504f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/PrefsSupport.java @@ -0,0 +1,33 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 08/01/97 jband created this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; + + +public interface PrefsSupport +{ + public void prefsWrite(Archiver archiver) throws CodingException; + public void prefsRead(Unarchiver unarchiver) throws CodingException; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/README b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/README new file mode 100644 index 00000000000..c134505e66b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/README @@ -0,0 +1,11 @@ +/* jband - 09/14/98 - */ + +com.netscape.jsdebugging.ifcui is the graphical Netscape JavaScript Debugger. +This is the same code that previously lived in netscape.jsdebugger and was +shipped in 1.1 form. That *tested* product for Navigator 4.x can be downloaded +from: + + http://developer.netscape.com/software/jsdebug.html + +This code can be used to run in Navigator or with the standalone JS engines. + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SmartItemListView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SmartItemListView.java new file mode 100644 index 00000000000..df67e803cad --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SmartItemListView.java @@ -0,0 +1,77 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 10/31/97 jband added this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; + +public class SmartItemListView extends BackgroundHackListView +{ + public SmartItemListView() + { + super(); + } + + // pass these events along to the item + + public boolean mouseDown(MouseEvent me) + { + SmartListItem sli = smartItemFromEvent(me); + if(null!=sli) + return sli.mouseDown(me); + return false; + } + public void mouseDragged(MouseEvent me) + { + SmartListItem sli = smartItemFromEvent(me); + if(null!=sli) + sli.mouseDragged(me); + } + public void mouseUp(MouseEvent me) + { + SmartListItem sli = smartItemFromEvent(me); + if(null!=sli) + sli.mouseUp(me); + } + + // these provide an easy way to ask for default behavior + public boolean superMouseDown(MouseEvent me) + { + return super.mouseDown(me); + } + public void superMouseDragged(MouseEvent me) + { + super.mouseDragged(me); + } + public void superMouseUp(MouseEvent me) + { + super.mouseUp(me); + } + + private final SmartListItem smartItemFromEvent(MouseEvent me) + { + return (SmartListItem) itemForPoint(me.x, me.y); + } +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SmartListItem.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SmartListItem.java new file mode 100644 index 00000000000..096400a575e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SmartListItem.java @@ -0,0 +1,64 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 10/31/97 jband added this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; + +public class SmartListItem extends ListItem +{ + public SmartListItem() + { + super(); + } + + // these defaults can be overridden + public boolean mouseDown(MouseEvent me) {return superMouseDown(me);} + public void mouseDragged(MouseEvent me) {superMouseDragged(me);} + public void mouseUp(MouseEvent me) {superMouseUp(me);} + + // these provide an easy way to ask for default behavior + public boolean superMouseDown(MouseEvent me) + { + return ((SmartItemListView)listView()).superMouseDown(me); + } + public void superMouseDragged(MouseEvent me) + { + ((SmartItemListView)listView()).superMouseDragged(me); + } + public void superMouseUp(MouseEvent me) + { + ((SmartItemListView)listView()).superMouseUp(me); + } + + protected final Rect myRect() + { + ListView lv = listView(); + if(ASS)ER.T(lv!=null,"ListItem with no parent called myRect()",this); + return lv.rectForItem(this); + } + private static final boolean ASS = true; // enable ASSERT support? +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceLineItemModel.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceLineItemModel.java new file mode 100644 index 00000000000..2037394e5f8 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceLineItemModel.java @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.api.*; + +class SourceLineItemModel +{ + // possible values for type + public static final int NO_SCRIPT = 0; + public static final int TOP_LEVEL_SCRIPT = 1; + public static final int FUNCTION_BODY = 2; + + public int lineNumber; // zero based + public String text; + public int type; + public Breakpoint bp; + public boolean executing; // is this line currently executing? + public String adjustmentChar; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceTyrant.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceTyrant.java new file mode 100644 index 00000000000..800b7711f81 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceTyrant.java @@ -0,0 +1,356 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; +import com.netscape.jsdebugging.api.*; + +public class SourceTyrant + extends Observable + implements Observer +{ + public SourceTyrant(Emperor emperor) throws ForbiddenTargetException + { + super(); + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + + PrivilegeManager.enablePrivilege("Debugger"); + _sourceTextProvider = _emperor.getSourceTextProvider(); + + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_sourceTextProvider,"no SourceTextProvider found",this); + + _controlTyrant.addObserver(this); + } + + + public void refreshSourceTextItemVector() + { + _emperor.setWaitCursor(true); + + String selectedURL = null; + + if( null != _selectedSourceTextItem ) + selectedURL = _selectedSourceTextItem.getURL(); + + PrivilegeManager.enablePrivilege("Debugger"); + synchronized(this) + { + _sourceTextProvider.refreshAll(); + } + + if( null != selectedURL ) + { + setSelectedSourceItem(_sourceTextProvider.findItem(selectedURL)); + } + _notifyObservers( SourceTyrantUpdate.VECTOR_CHANGED, null ); + + _emperor.setWaitCursor(false); + } + + public SourceTextItem findSourceItem(String url) + { + PrivilegeManager.enablePrivilege("Debugger"); + SourceTextItem sti = _sourceTextProvider.findItem(url); + // if not found then refresh the provider and retry + if( null == sti ) + { + refreshSourceTextItemVector(); + sti = _sourceTextProvider.findItem(url); + } + return sti; + } + + public SourceTextItem[] getSourceTextItemArray() + { + PrivilegeManager.enablePrivilege("Debugger"); + return _sourceTextProvider.getItems(); + } + public SourceTextItem getSelectedSourceItem() {return _selectedSourceTextItem;} + public void setSelectedSourceItem(SourceTextItem s) + { + if( _selectedSourceTextItem == s ) + return; + +// if(ASS)System.out.println("sel changed to " + s.getURL() ); + + _selectedSourceTextItem = s; + _notifyObservers( SourceTyrantUpdate.SELECT_CHANGED, s ); + } + + private void _notifyObservers( int type, SourceTextItem item ) + { + setChanged(); + notifyObservers( new SourceTyrantUpdate(type,item) ); + } + + // implement observer interface + public void update(Observable o, Object arg) + { + if ( o == _controlTyrant ) + { + if( ControlTyrant.STOPPED == _controlTyrant.getState() ) + refreshSourceTextItemVector(); + } + } + + public void SetSelectedUrlLineText( String url, int line, String text ) + { + _urlOfSelectedLine = url; + _lineNumberOfSelectedLine = line; + _selectedText = text; + + _notifyObservers( SourceTyrantUpdate.SEL_URL_LINE_TEXT_CHANGED, null ); + + // the below is for debugging only... + if(false) + { + if( null == url ) + { + System.out.println( "+++++++++++++++++++++" ); + System.out.println( "selected urllinetext set to null" ); + System.out.println( "---------------------" ); + } + else + { + System.out.println( "+++++++++++++++++++++" ); + System.out.println( "Selection in:" + "\n " + url ); + System.out.println( "Sel line:" + "\n " + line); + System.out.println( "Changed to:" + "\n " + text ); + System.out.println( "---------------------" ); + } + } + } + + public String getUrlOfSelectedLine() {return _urlOfSelectedLine;} + public int getLineNumberOfSelectedLine() {return _lineNumberOfSelectedLine;} + public String getSelectedText() {return _selectedText;} + + + ////////////////////////////////////////////////////////////////// + /* jband - 06/04/97 - new scheme for user souce line adjustment */ + + public synchronized void clearAllAdjustmentsForItem( SourceTextItem sti ) + + { + if( null == _adjustments ) + return; + _adjustments = null; + _notifyObservers( SourceTyrantUpdate.ADJUSTMENTS_CHANGED, null ); + } + + public synchronized void makeAdjustment( SourceTextItem sti, int line, int offset ) + { + if(ASS)ER.T(null!=sti,"bad SourceTextItem in makeAdjustment",this); + if(ASS)ER.T(line >=0,"bad line in makeAdjustment",this); + + if( null == _adjustments ) + { + if( 0 == offset ) + return; + _adjustments = new Hashtable(); + } + + Vector v = (Vector) _adjustments.get(sti); + if( null == v ) + { + if( 0 == offset ) + return; + v = new Vector(); + _adjustments.put( sti, v ); + } + +// System.out.println( "make adjustment at " + line +" "+ offset ); + + int count = v.count(); + for(int i = 0; i < count; i++) + { + AdjustmentItem adj = (AdjustmentItem) v.elementAt(i); + if( adj.line == line ) + { + if( 0 != offset ) + adj.offset = offset; + else + v.removeElementAt(i); + _fixupAdjustmentVector(v); + _notifyObservers( SourceTyrantUpdate.ADJUSTMENTS_CHANGED, null ); + return; + } + if( adj.line > line ) + { + if( 0 != offset ) + v.insertElementAt(new AdjustmentItem(line,offset),i); + _fixupAdjustmentVector(v); + _notifyObservers( SourceTyrantUpdate.ADJUSTMENTS_CHANGED, null ); + return; + } + } + if( 0 != offset ) + v.addElement(new AdjustmentItem(line,offset)); + _fixupAdjustmentVector(v); + _notifyObservers( SourceTyrantUpdate.ADJUSTMENTS_CHANGED, null ); + } + + public int getAdjustment( SourceTextItem sti, int line ) + { + if(ASS)ER.T(null!=sti,"bad SourceTextItem in getAdjustment",this); + if(ASS)ER.T(line >=0,"bad line in getAdjustment",this); + + if( null == _adjustments ) + return 0; + Vector v = (Vector) _adjustments.get(sti); + if( null == v ) + return 0; + int count = v.count(); + for(int i = 0; i < count; i++) + { + AdjustmentItem adj = (AdjustmentItem) v.elementAt(i); + if( adj.line == line ) + { +// System.out.println( "get adjustment at " + line +" "+ adj.offset ); + return adj.offset; + } + } + return 0; + } + + public int userLine2SystemLine( SourceTextItem sti, int line ) + { + if(ASS)ER.T(null!=sti,"bad SourceTextItem in userLine2SystemLine",this); + if(ASS)ER.T(line >=0,"bad line in userLine2SystemLine",this); + + if( null == _adjustments ) + return line; + Vector v = (Vector) _adjustments.get(sti); + if( null == v ) + return line; + + int count = v.count(); + for(int i = count-1; i >= 0; i--) + { + AdjustmentItem adj = (AdjustmentItem) v.elementAt(i); + if( (adj.line + adj.cummulative_offset) <= line ) + return line - adj.cummulative_offset; + } + return line; + } + + public int systemLine2UserLine( SourceTextItem sti, int line ) + { + if(ASS)ER.T(null!=sti,"bad SourceTextItem in userLine2SystemLine",this); + if(ASS)ER.T(line >=0,"bad line in userLine2SystemLine",this); + + if( null == _adjustments ) + return line; + Vector v = (Vector) _adjustments.get(sti); + if( null == v ) + return line; + + int adj_line = line; + int count = v.count(); + for(int i = 0; i < count; i++) + { + AdjustmentItem adj = (AdjustmentItem) v.elementAt(i); + if( adj.line > line ) + break; + adj_line += adj.offset; + } + if( adj_line < 0 ) + return 0; + return adj_line; + } + + public int[] getUserAdjustedLineArray( SourceTextItem sti ) + { + if(ASS)ER.T(null!=sti,"bad SourceTextItem in getUserAdjustedLineArray",this); + + if( null == _adjustments ) + return null; + Vector v = (Vector) _adjustments.get(sti); + if( null == v ) + return null; + + int count = v.count(); + int[] a = new int[count]; + for(int i = 0; i < count; i++) + { + AdjustmentItem adj = (AdjustmentItem) v.elementAt(i); + int val = adj.line + adj.cummulative_offset; + if( adj.offset < 0 ) + val *= -1; + a[i] = val; + } + return a; + } + + + private void _fixupAdjustmentVector( Vector v ) + { + int cummulative_offset = 0; + int count = v.count(); + for(int i = 0; i < count; i++) + { + AdjustmentItem adj = (AdjustmentItem) v.elementAt(i); + if(ASS)ER.T(adj.offset!=0,"adj.offset == 0",this); + cummulative_offset += adj.offset; + adj.cummulative_offset = cummulative_offset; + } + } + + ////////////////////////////////////////////////////////////////// + + + // data... + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + private SourceTextProvider _sourceTextProvider; + private SourceTextItem _selectedSourceTextItem; + + private String _urlOfSelectedLine = null; + private int _lineNumberOfSelectedLine = 0; + private String _selectedText = null; + + private Hashtable _adjustments = null; + + private static final boolean ASS = true; // enable ASSERT support? +} + +class AdjustmentItem +{ + AdjustmentItem(int line, int offset) + { + this.line = line; + this.offset = offset; + } + public int line; + public int offset; + public int cummulative_offset; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceTyrantUpdate.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceTyrantUpdate.java new file mode 100644 index 00000000000..1db7a2331ce --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceTyrantUpdate.java @@ -0,0 +1,43 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.api.*; + +class SourceTyrantUpdate +{ + public static final int SELECT_CHANGED = 0; + public static final int VECTOR_CHANGED = 1; + public static final int ITEM_CHANGED = 2; + public static final int SEL_URL_LINE_TEXT_CHANGED = 3; + public static final int ADJUSTMENTS_CHANGED = 4; + public SourceTyrantUpdate( int type, SourceTextItem item ) + { + this.type = type; + this.item = item; + } + public int type; + public SourceTextItem item; +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceView.java new file mode 100644 index 00000000000..4796c5c1944 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceView.java @@ -0,0 +1,1204 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import java.io.StringBufferInputStream; +import java.io.DataInputStream; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import com.netscape.jsdebugging.api.*; + +// XXX deal with window closing -- remove as Observer + +public class SourceView extends InternalWindow + implements Observer +{ + + public SourceView( Rect rect, + Emperor emperor, + SourceTextItem item ) + { + super(rect); + + _item = item; + + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + _sourceTyrant = emperor.getSourceTyrant(); + _breakpointTyrant = emperor.getBreakpointTyrant(); + _sourceViewManager = emperor.getSourceViewManager(); + _stackTyrant = emperor.getStackTyrant(); + + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_sourceTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_breakpointTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_sourceViewManager,"emperor init order problem", this); + if(ASS)ER.T(null!=_stackTyrant,"emperor init order problem", this); + + _sourceLineVectorModel = + new SourceLineVectorModel(this, _controlTyrant, _stackTyrant, + _sourceTyrant, item); + _listview = new SourceTextListView(this); + + Rect rectSG = new Rect(rect); + rectSG.moveBy(-rect.x, -rect.y); + ScrollGroup sg = new ScrollGroup(rectSG); + sg.setHorizScrollBarDisplay( ScrollGroup.ALWAYS_DISPLAY ); + sg.setVertScrollBarDisplay( ScrollGroup.ALWAYS_DISPLAY ); + sg.setContentView( _listview ); + sg.setAutoResizeSubviews(true); + sg.contentView().setLayoutManager( new MarginLayout() ); + sg.setBackgroundColor(_emperor.getBackgroundColor()); + + setCloseable( true ); + setResizable( true ); +// setTitle( "Source for: " + item.getURL() ); + setTitle( item.getURL() ); + addSubview(sg); + setAutoResizeSubviews(true); + contentView().setLayoutManager( new MarginLayout() ); + + _listview.setAllowsEmptySelection(true); + _listview.setAllowsMultipleSelection(false); + + _listview.setBackgroundColor(_emperor.getBackgroundColor()); + + _sourceTyrant.addObserver(this); + _controlTyrant.addObserver(this); + _breakpointTyrant.addObserver(this); + + _refresh(true); + + layoutView(1,1); + layoutView(-1,-1); + + show(); + } + + public void ensureSourceLineVisible( int line ) + { + int userline = _sourceTyrant.systemLine2UserLine(_item,line); + if(userline >= 1 && userline <= _listview.count()) + _listview.scrollItemAtToVisible(userline-1); + } + + // implement observer interface + public void update(Observable o, Object arg) + { + if( o == _sourceTyrant ) + { + SourceTyrantUpdate update = (SourceTyrantUpdate) arg; + switch( update.type ) + { + case SourceTyrantUpdate.VECTOR_CHANGED: + _refresh(false); + updateMarks(); + break; + case SourceTyrantUpdate.ITEM_CHANGED: + if( update.item == _item ) + { + _refresh(false); + updateMarks(); + } + break; + case SourceTyrantUpdate.ADJUSTMENTS_CHANGED: + updateMarks(); + break; + default: + break; // ignore any other types + } + } + else if ( o == _breakpointTyrant ) + { + BreakpointTyrantUpdate update = (BreakpointTyrantUpdate) arg; + switch( update.type ) + { + case BreakpointTyrantUpdate.ADD_ONE: + case BreakpointTyrantUpdate.REMOVE_ONE: + case BreakpointTyrantUpdate.MODIFIED_ONE: + if( update.bp.getURL().equals(_item.getURL()) ) + updateMarks(); +// _refreshMarksForSingleLine(update.bp.getLine()); + break; + case BreakpointTyrantUpdate.REMOVE_ALL_FOR_URL: + if( ! (update.bp.getURL().equals(_item.getURL())) ) + break; + // else... FALL THROUGH + case BreakpointTyrantUpdate.REMOVE_ALL: + case BreakpointTyrantUpdate.REFRESH_ALL: + updateMarks(); + break; + default: + break; // ignore any other types + } + } + else if ( o == _controlTyrant ) + { + // update all dirty views on stop + if( ControlTyrant.STOPPED == _controlTyrant.getState() ) + _refresh(false); + updateMarks(); + } + + } + + public void forceRefresh() + { + _refresh(true); + } + + public void updateMarks() + { + _sourceLineVectorModel.updateLineItemVector(); + _listview.drawMarks(); + } + +/* + private synchronized void _refreshSingleLine( int line, Breakpoint bp ) + { + if( null == _sourceLineVectorModel || null == _listview ) + return; + _sourceLineVectorModel.updateSingleLineItem(line); + // XXX This will change with 'selective text' + _listview.drawItemAt(line-1); + } + private synchronized void _refreshMarksForSingleLine(int line) + { + if( null == _sourceLineVectorModel || null == _listview ) + return; + _sourceLineVectorModel.updateSingleLineItem(line); + // XXX This will change with 'selective text' + _listview.drawMarksOfItemAt(line-1); + } +*/ + + private synchronized void _refresh(boolean force) + { + if( _item.getDirty() || force ) + { + _emperor.setWaitCursor(true); + +// System.out.println(" _refreshing: " + _item.getURL() + +// " _item.getDirty() returned: " + +// (_item.getDirty() ? "true" : "false") + +// "_item.getAlterCount() returned: " + +// _item.getAlterCount() + +// " force == " + +// (force ? "true" : "false") ); + // refill all + _listview.removeAllItems(); + _sourceLineVectorModel.rebuildLineItemVector(); + setSelection(null,0); + + Vector vec = _sourceLineVectorModel.getLineItemVector(); +// System.out.println( "vec size = " + vec.size() ); + + Font linefont = _emperor.getFixedFont(); + + boolean showNumbers = _sourceViewManager.getShowLineNumbers(); + SourceTextItemDrawer drawer = new SourceTextItemDrawer(); + + _listview.setItemDrawer(drawer); + + int maxwidth = 0; + int itemHeight = 0; + for (int i = 0; i < vec.size(); i++) + { + SourceLineItemModel lineitem = (SourceLineItemModel) vec.elementAt(i); + String text = lineitem.text; + + SourceTextListItem newlistitem = new SourceTextListItem(drawer,text.length()); + newlistitem.setTitle( text ); + newlistitem.setData( lineitem ); + newlistitem.setFont( linefont ); + newlistitem.setSelectedColor(_emperor.getSelectionColor()); + + _listview.addItem( newlistitem ); + + if( 0 == i ) + { + itemHeight = _listview.rectForItem(newlistitem).height; + drawer.init( linefont, showNumbers, vec.size(), itemHeight ); + } + maxwidth = Math.max( maxwidth, newlistitem.minWidth() ); + } + + _listview.setBounds(0,0,maxwidth,0); + _listview.sizeToMinSize(); + + layoutView(0,0); + _listview.draw(); + + _item.setDirty(false); + + JSSourceLocation loc = _stackTyrant.getCurrentLocation(); + if( null != loc && loc.getURL().equals(getURL()) ) + ensureSourceLineVisible( loc.getLine() ); + + _emperor.setWaitCursor(false); + } + } + + public String getSelectedText() {return _selectedText;} + public int getSelectedLineNumber() {return _selectedLineNumber;} + public void setSelection(String s, int lineNumber) + { + if( _selectedLineNumber == lineNumber && s != null && s.equals(_selectedText) ) + return; + _selectedText = s; + _selectedLineNumber = lineNumber; + _sourceViewManager.selectionInSourceViewChanged(this,s,lineNumber); + } + + public SourceViewManager getSourceViewManager() {return _sourceViewManager;} + public BreakpointTyrant getBreakpointTyrant() {return _breakpointTyrant;} + public Emperor getEmperor() {return _emperor;} + public SourceTyrant getSourceTyrant() {return _sourceTyrant;} + + public SourceTextItem getSourceItem() {return _item;} + public String getURL() {return _item.getURL();} + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + private SourceTyrant _sourceTyrant; + private StackTyrant _stackTyrant; + private BreakpointTyrant _breakpointTyrant; + private SourceViewManager _sourceViewManager; + private SourceLineVectorModel _sourceLineVectorModel; + private SourceTextItem _item; + private SourceTextListView _listview; + private String _selectedText = null; + private int _selectedLineNumber = 0; + + private static final boolean ASS = true; // enable ASSERT support? +} + +/***************************************************************************/ + +final class SourceTextListView extends SmartItemListView +{ + public SourceTextListView( SourceView sourceView ) + { + super(); + _sourceView = sourceView; + } + + + public boolean mouseDown(MouseEvent me) + { + _dragOrigin = -1; + + // middle click + if( me.isAltKeyDown() && _isInMarksZone(me) ) + { + SourceTyrant st = getSourceView().getSourceTyrant(); + SourceTextItem sti = _sourceView.getSourceItem(); + st.clearAllAdjustmentsForItem(sti); + return false; + } + + // right click + if( me.isMetaKeyDown() && _isInMarksZone(me) ) + { + SourceTyrant sourceTyrant = getSourceView().getSourceTyrant(); + + _dragLast = _dragOrigin = _itemNumberAtPoint(me); + SourceTextItem sti = _sourceView.getSourceItem(); + int sysline = sourceTyrant.userLine2SystemLine(sti,_dragOrigin); + _dragAdjLineOrigin = sysline; +// System.out.println( "original line = " + _dragOrigin ); +// System.out.println( "sys line = " + sysline ); +// System.out.println( "\n" ); + return true; + } + return super.mouseDown(me); + } + + + public void mouseDragged(MouseEvent me) + { + if( -1 != _dragOrigin ) + { + int curIndex = _itemNumberAtPoint(me); + if( _dragLast == curIndex ) + return; + _extendAdjLine(me); + } + else + super.mouseDragged(me); + } + public void mouseUp(MouseEvent me) + { + if( -1 != _dragOrigin ) + { + _extendAdjLine(me); + _dragAdjLineOrigin = -1; + } + else + super.mouseUp(me); + } + + private final boolean _isInMarksZone(MouseEvent me) + { + return me.x < _drawer.marksWidth(); + } + private final int _itemNumberAtPoint(MouseEvent me) + { + return 1 + indexOfItem(itemForPoint(me.x,me.y)); + } + + private void _extendAdjLine(MouseEvent me) + { + int curIndex = _itemNumberAtPoint(me); + if( _dragLast == curIndex ) + return; + int offset = curIndex - _dragLast; + _dragLast = curIndex; + + SourceTyrant st = getSourceView().getSourceTyrant(); + SourceTextItem sti = _sourceView.getSourceItem(); + int old_offset = st.getAdjustment(sti,_dragAdjLineOrigin); + st.makeAdjustment(sti, _dragAdjLineOrigin, old_offset + offset); + } + + protected void ancestorWillRemoveFromViewHierarchy(View removedView) + { + if( removedView == _sourceView ) + { + _sourceView.getSourceViewManager().viewBeingRemoved(_sourceView); + } + + super.ancestorWillRemoveFromViewHierarchy(removedView); + } + + public void setItemDrawer(SourceTextItemDrawer drawer) {_drawer = drawer;} + + public void drawMarks() + { + if(ASS)ER.T(null!=_drawer,"SourceTextListView has null drawer",this); + if( null == _drawer || null == _drawer.marksRect()) + { + draw(); + return; + } + // calc marks rect and call draw() + Rect r = new Rect( 0,0, _drawer.marksRect().width, height() ); +// System.out.println( "draw marks rect: " + r ); + draw(r); + } + + public void drawMarksOfItemAt(int i) + { + if(ASS)ER.T(null!=_drawer,"SourceTextListView has null drawer",this); + if( null == _drawer ) + { + drawItemAt(i); + return; + } + // calc marks rect for item and call draw() + Rect rItem = rectForItemAt(i); + Rect r = new Rect( rItem.x, + rItem.y, + _drawer.marksRect().width, + rItem.height ); +// System.out.println( "draw marks rect for single item: " + r ); + draw(r); + } + + public SourceTextListItem getItemWithSel() {return _itemWithSel;} + public int getSelStart() {return _selStart;} + public int getSelEnd() {return _selEnd;} + public void setItemWithSel(SourceTextListItem i) {_itemWithSel=i;} + public void setSelRange(int start, int end) {_selStart=start;_selEnd=end;} + + public void selChangeCompleted() + { + int lineNumber = 0; + _selString = null; + + if( null != _itemWithSel ) + { + _selString = _itemWithSel.stringInRange(_selStart,_selEnd); + lineNumber = indexOfItem(_itemWithSel) + 1; + } + _sourceView.setSelection(_selString, lineNumber ); + } + + public SourceView getSourceView() {return _sourceView;} + + private SourceView _sourceView; + private SourceTextItemDrawer _drawer; + private SourceTextListItem _itemWithSel; + private int _selStart; + private int _selEnd; + private String _selString; + private int _dragOrigin = -1; + private int _dragLast; + private int _dragAdjLineOrigin; + private static final boolean ASS = true; // enable ASSERT support? +} + +/***************************************************************************/ + +final class SourceTextItemDrawer +{ + public SourceTextItemDrawer() {} + + public void init( Font font, boolean showLineNumbers, + int lineCount, int itemHeight ) + { + _font = font; + _showLineNumbers = showLineNumbers; + + _lineNumberColumnCount = String.valueOf(lineCount).length(); +// _height = font.fontMetrics().stringHeight(); + _height = itemHeight; + _charWidth = font.fontMetrics().charWidth('0'); + + _rectBP = new Rect( 0, 0, + _height, _height); + Rect rectExec = new Rect( _rectBP.x + _rectBP.width, 0, + _height/2, _height); + Rect rectNum = new Rect( rectExec.x + rectExec.width, 0, + _showLineNumbers ? _charWidth*(_lineNumberColumnCount+1) : 0, _height); + + _width = rectNum.x + rectNum.width; + + _ptLineNumbers = new Point(rectNum.x, rectNum.y); + + int margin = _height / 4; + + // size before shrink + _rectExecPointBackground = new Rect( rectExec ); + _rectBPBackground = new Rect( _rectBP ); + _rectMarks = Rect.rectFromUnion(rectExec, _rectBP); + if( null == _rectMarks ) + _rectMarks = new Rect(); + + _rectBP.growBy( -margin, - margin ); + rectExec.growBy( -(margin/2), -margin ); + +// _rectBP.moveBy( 0, -margin/2 ); +// rectExec.moveBy( 0, -margin/4 ); + + _polyExecPoint = new Polygon(); + _polyExecPoint.addPoint( rectExec.x, rectExec.y ); + _polyExecPoint.addPoint( rectExec.x, rectExec.y + rectExec.height); + _polyExecPoint.addPoint( rectExec.x+rectExec.width, rectExec.midY()); + _polyExecPoint.addPoint( rectExec.x, rectExec.y ); + + _ptText = new Point( _width, 0 ); + } + + public void draw( Graphics g, + Rect boundsRect, + SourceTextListItem item, + int lineNumber, + boolean hasBreakpoint, + boolean hasConditionalBreakpoint, + int scriptType, + boolean isExecPoint, + String adjustmentChar ) + { + SourceLineItemModel itemModel = (SourceLineItemModel) item.data(); + + Rect r = new Rect(); + + // draw the main text + + String text = item.title(); + if( null != text && 0 != text.length() ) + { + r.setBounds( boundsRect.x + _ptText.x, + boundsRect.y + _ptText.y, + boundsRect.width - _ptText.x, + boundsRect.height - _ptText.y ); + + if( r.intersects( g.clipRect() ) ) + item.drawStringInRect(g,text,_font,r,Graphics.LEFT_JUSTIFIED); + } + + if( hasBreakpoint ) + { + r.setBounds( boundsRect.x + _rectBP.x, + boundsRect.y + _rectBP.y, + _rectBP.width, + _rectBP.height ); + + if( r.intersects( g.clipRect() ) ) + { + if( hasConditionalBreakpoint ) + g.setColor( Color.orange ); + else + g.setColor( Color.red ); + g.fillOval( r ); + } + } + + if( null != adjustmentChar ) + { + r.setBounds( boundsRect.x + _rectBPBackground.x, + boundsRect.y + _rectBPBackground.y, + _rectBPBackground.width, + _rectBPBackground.height ); + + if( r.intersects( g.clipRect() ) ) + { + g.setColor( Color.black ); + g.setFont(_font); + g.drawStringInRect(adjustmentChar,r,Graphics.LEFT_JUSTIFIED); + } + } + + if( scriptType != SourceLineItemModel.NO_SCRIPT ) + { + r.setBounds( boundsRect.x + _rectExecPointBackground.x, + boundsRect.y + _rectExecPointBackground.y, + _rectExecPointBackground.width, + _rectExecPointBackground.height ); + + if( r.intersects( g.clipRect() ) ) + { + if( scriptType == SourceLineItemModel.FUNCTION_BODY ) + g.setColor( Color.orange ); + else + g.setColor( Color.yellow ); + + g.fillRect( r ); + } + } + + if( isExecPoint ) + { + int count = 4; + int[] x = new int[count]; + int[] y = new int[count]; + + for( int i = 0; i < count; i++ ) + { + x[i] = _polyExecPoint.xPoints[i] + boundsRect.x; + y[i] = _polyExecPoint.yPoints[i] + boundsRect.y; + } + + g.setColor( Color.blue ); + g.fillPolygon( x,y,count); + + } + if( _showLineNumbers ) + { + r.setBounds( boundsRect.x + _ptLineNumbers.x, + boundsRect.y + _ptLineNumbers.y, + boundsRect.width - _ptLineNumbers.x, + boundsRect.height - _ptLineNumbers.y ); + + if( r.intersects( g.clipRect() ) ) + { + g.setColor( Color.darkGray ); + g.setFont(_font); + g.drawStringInRect(lineNumberString(lineNumber),r,Graphics.LEFT_JUSTIFIED); + } + } + } + + public int width() {return _width;} + public int height() {return _height;} + public int charWidth() {return _charWidth;} + public Rect breakpointRect() {return _rectBPBackground;} + public Rect marksRect() {return _rectMarks;} + public Point textOrigin() {return _ptText;} + public int marksWidth() {return _rectMarks.width;} + + private String lineNumberString( int number ) + { + StringBuffer buf = new StringBuffer(); + String s = String.valueOf(number); + int len = s.length(); + if(ASS)ER.T(len<=_lineNumberColumnCount,"lineNumberColumnCount screwed up",this); + + for( int i = 0; i < _lineNumberColumnCount-len; i++ ) + buf.append('0'); + buf.append(s); + buf.append(':'); + + return buf.toString(); + } + + private int _width; + private int _height; + + private int _lineNumberColumnCount; + private Font _font; + + private Rect _rectBP; + private Rect _rectBPBackground; + private Polygon _polyExecPoint; + private Rect _rectExecPointBackground; + private Rect _rectMarks; + private Point _ptLineNumbers; + private Point _ptText; + private boolean _showLineNumbers; + private int _charWidth; + + private static final boolean ASS = true; // enable ASSERT support? +} + +final class SourceTextListItem extends SmartListItem +{ + public SourceTextListItem(SourceTextItemDrawer drawer, int charCount) + { + super(); + _drawer = drawer; + _charCount = charCount; + } + + public boolean mouseDown(MouseEvent me) + { +/* + System.out.println("......................."); + System.out.println("mousedown x=" + me.x + " y=" + me.y); + System.out.println(myRect()); + System.out.println("......................."); +*/ + + _dragOrigin = -1; + + // middle click + if( me.isAltKeyDown() ) + return false; + + // right click + if( me.isMetaKeyDown() ) + { + // evaluate selected text + SourceTextListView v = (SourceTextListView) listView(); + if( v.getItemWithSel() != this ) + return false; + + Rect rectText = textRect(); + if( ! rectText.contains(me.x,me.y) ) + return false; + + Emperor emperor = v.getSourceView().getEmperor(); + CommandTyrant ct = emperor.getCommandTyrant(); + Menu menu = new Menu(true); + + if( ControlTyrant.STOPPED == emperor.getControlTyrant().getState() ) + { + menu.addItem("Eval", ct.cmdString(CommandTyrant.EVAL_SEL_STRING), ct); + menu.addItem("Inspect...", ct.cmdString(CommandTyrant.INSPECT_SEL_STRING), ct); + menu.addItem("Copy to Watch", ct.cmdString(CommandTyrant.COPY_TO_WATCH), ct); + menu.addSeparator(); + } + + menu.addItem("Copy", ct.cmdString(CommandTyrant.COPY), ct); + menu.addSeparator(); + + CmdState cs = ct.findCmdState(CommandTyrant.TOGGLE_BREAKPOINT); + if( null != cs && cs.enabled ) + { + if( cs.checked ) + { + menu.addItem("Clear Breakpoint", ct.cmdString(CommandTyrant.TOGGLE_BREAKPOINT), ct); + menu.addItem("Edit Breakpoint...", ct.cmdString(CommandTyrant.EDIT_BREAKPOINT), ct); + } + else + menu.addItem("Set Breakpoint", ct.cmdString(CommandTyrant.TOGGLE_BREAKPOINT), ct); + } + +// String cmd = ct.cmdString( CommandTyrant.EVAL_STRING ); +// String str = stringInRange(v.getSelStart(), v.getSelEnd()); +// Application.application().performCommandLater( ct, cmd, str ); + + ListView lv = listView(); + RootView rv = lv.rootView(); + MouseEvent tme = lv.convertEventToView(rv, me); + MouseMenuView mmv = new MouseMenuView(menu); + mmv.show(rv, tme); + + return false; + } + + Rect rectBP = breakpointRect(); + if( rectBP.contains(me.x,me.y) ) + { + // toggle breakpoint + SourceLineItemModel model = (SourceLineItemModel) data(); + SourceView sv = ((SourceTextListView)listView()).getSourceView(); + BreakpointTyrant bpt = sv.getBreakpointTyrant(); + SourceTyrant sourceTyrant = sv.getSourceTyrant(); + SourceTextItem sti = sv.getSourceItem(); + + int sysline = sourceTyrant.userLine2SystemLine(sti,model.lineNumber); + + Location loc = new Location( sv.getURL(), sysline ); + + Breakpoint bp = bpt.findBreakpoint(loc); + if( null == bp ) + bpt.addBreakpoint(loc); + else + bpt.removeBreakpoint(bp); + + // redraw done on notification... + } + else + { + // start select (or select word) + Rect rectText = textRect(); + if( rectText.contains(me.x,me.y) ) + { + int start, end; + SourceTextListView v = (SourceTextListView) listView(); + start = end = charIndexAtPointInRect( me.x, rectText ); + + SourceTextListItem oldItem = v.getItemWithSel(); + v.setItemWithSel(this); + + if( me.clickCount() > 1 ) + { + Range r = wordAtIndex(start); + if( null != r ) + { + start = r.index; + end = start + r.length-1; + } + _dragOrigin = -1; + } + else + _dragOrigin = start; + + v.setSelRange(start, end); + + if( null != oldItem ) + v.drawItemAt( v.indexOfItem(oldItem) ); + v.draw( rectOfRangeInRect(start, end, rectText) ); + + if( _dragOrigin == -1 ) // i.e. was double click + v.selChangeCompleted(); + } + } + return true; + } + + public void mouseDragged(MouseEvent me) + { + SourceTextListView v = (SourceTextListView) listView(); + if( -1 != _dragOrigin && v.getItemWithSel() == this ) + _extendSelection(me, v); + } + + public void mouseUp(MouseEvent me) + { + SourceTextListView v = (SourceTextListView) listView(); + if( -1 != _dragOrigin && v.getItemWithSel() == this ) + { + _extendSelection(me, v); + v.selChangeCompleted(); + _dragOrigin = -1; + } + } + + private void _extendSelection(MouseEvent me, SourceTextListView v) + { + Rect rectText = textRect(); + if( rectText.contains(me.x,me.y) ) + { + int cur = charIndexAtPointInRect( me.x, rectText ); + int oldStart = v.getSelStart(); + int oldEnd = v.getSelEnd(); + + int start; + int end; + + if( cur > _dragOrigin ) + { + start = _dragOrigin; + end = cur; + } + else + { + start = cur; + end = _dragOrigin; + } + if( start == oldStart && end == oldEnd ) + return; + + v.setSelRange(start, end); + + // redraw only changed parts (not worried about overlap)... + int x1, x2; + x1 = Math.min(oldStart, start); + x2 = Math.max(oldStart, start); + if( x1 != x2 ) + v.draw( rectOfRangeInRect(x1, x2, rectText) ); + x1 = Math.min(oldEnd, end); + x2 = Math.max(oldEnd, end); + if( x1 != x2 ) + v.draw( rectOfRangeInRect(x1, x2, rectText) ); + } + } + + public int minWidth() {return super.minWidth() + _drawer.width();} + + + public Range wordAtIndex(int index) + { + String text = ((SourceLineItemModel)data()).text; + int len = text.length(); + int start = -1; + int end; + int i; + + // search for first char... + for( i = 0; i <= index; i++ ) + { + char c = text.charAt(i); + if( -1 == start ) + { + if( Character.isJavaIdentifierStart(c) ) + start = i; + } + else + { + if( ! Character.isJavaIdentifierPart(c) ) + start = -1; + } + } + if( -1 == start ) + return null; + + for(; i < len; i++ ) + { + char c = text.charAt(i); + if( ! Character.isJavaIdentifierPart(c) ) + break; + } + + return new Range(start, i-start); + } + + public String stringInRange(int start, int end) + { + return ((SourceLineItemModel)data()).text.substring(start,end+1); + } + + + + protected void drawBackground(Graphics g, Rect boundsRect) + { + SourceTextListView v = (SourceTextListView) listView(); + + if( v.getItemWithSel() == this ) + { + Rect r = rectOfRangeInRect(v.getSelStart(),v.getSelEnd(),textRect()); + r.intersectWith(boundsRect); + if( ! r.isEmpty() ) + { + g.setColor(selectedColor()); + g.fillRect(r); + } + } + } + + public void drawInRect(Graphics g, Rect boundsRect) + { + drawBackground(g, boundsRect); + + SourceLineItemModel model = (SourceLineItemModel) data(); + _drawer.draw( g, boundsRect, this, + model.lineNumber, + model.bp != null, + model.bp != null?model.bp.getBreakCondition()!=null:false, + model.type, + model.executing, + model.adjustmentChar ); + } + + // make this public to be called by our drawer helper + public void drawStringInRect( Graphics g, String title, + Font titleFont, Rect textBounds, + int justification) + { + super.drawStringInRect(g,title,titleFont,textBounds,justification); + } + + public Rect breakpointRect() + { +// Rect r = new Rect( _drawer.breakpointRect() ); + Rect r = new Rect( _drawer.marksRect() ); + Rect myRect = myRect(); + r.moveBy(myRect.x, myRect.y); + return r; + } + + public Rect textRect() + { + Rect r = new Rect( _drawer.textOrigin().x, + _drawer.textOrigin().y, + _drawer.charWidth() * _charCount, + _drawer.height() ); + Rect myRect = myRect(); + r.moveBy(myRect.x, myRect.y); + return r; + } + + // ASSUMES that point is in rect -- caller beware! + protected int charIndexAtPointInRect( int x, Rect r ) + { + return (x - r.x) / _drawer.charWidth(); + } + + protected Rect rectOfRangeInRect( int start, int end, Rect r ) + { + int cw = _drawer.charWidth(); + return new Rect((start*cw)+r.x, r.y, (1+end-start)*cw, r.height); + } + + private int _dragOrigin = -1; + private int _charCount; + private SourceTextItemDrawer _drawer; + private static final boolean ASS = true; // enable ASSERT support? +} + +/***************************************************************************/ + +final class SourceLineVectorModel +{ + public SourceLineVectorModel( SourceView sourceView, + ControlTyrant controlTyrant, + StackTyrant stackTyrant, + SourceTyrant sourceTyrant, + SourceTextItem sourceTextItem ) + { + _sourceView = sourceView; + _controlTyrant = controlTyrant; + _stackTyrant = stackTyrant; + _sourceTextItem = sourceTextItem; + _sourceTyrant = sourceTyrant; + _sourceLineItemVector = new Vector(); + } + + public synchronized void rebuildLineItemVector() + { + Vector vec = new Vector(); + try + { + DataInputStream s = new DataInputStream( + new StringBufferInputStream( + getSourceTextItem().getText() )); + if( null != s ) + { + String linetext; + int lineNumber = 1; + while( null != (linetext = s.readLine()) ) + { + SourceLineItemModel item = new SourceLineItemModel(); + + item.lineNumber = lineNumber; + item.text = Util.expandTabs(linetext,8); + item.type = SourceLineItemModel.NO_SCRIPT; + item.bp = null; // XXX + item.executing = false; + item.adjustmentChar = null; + + vec.addElement( item ); + lineNumber++ ; + } + s.close(); + } + } + catch( Exception e ) {} + + _sourceLineItemVector = vec; + updateLineItemVector(); + } + + public synchronized void updateLineItemVector() + { +/* + // XXX script stuff must change... + ScriptProvider sp = JSDScriptProvider.getScriptProvider(); + if( null == sp ) + return; +*/ + + int i; + int count; + + // clear all line + + int maxLineItemIndex = _sourceLineItemVector.size() - 1; + + count = _sourceLineItemVector.size(); + if( 0 == count ) + return; + for( i = 0; i < count; i++ ) + { + SourceLineItemModel item = + (SourceLineItemModel) _sourceLineItemVector.elementAt(i); + item.type = SourceLineItemModel.NO_SCRIPT; + item.bp = null; + item.executing = false; + item.adjustmentChar = null; + } + + // walk through the scripts and mark lines with scripts + + String url = _sourceTextItem.getURL(); + BreakpointTyrant bpt = _sourceView.getBreakpointTyrant(); + + Vector vecScripts = bpt.getScriptsVectorForURL(url); + count = vecScripts.size(); + for( i = 0; i < count; i++ ) + { + Script script = (Script) vecScripts.elementAt(i); + + if( ! script.isValid() ) + continue; + + boolean fun = null != script.getFunction(); + + ScriptSection[] sections = script.getSections(); + for( int n = 0; n < sections.length; n++ ) + { + int base = sections[n].getBaseLineNumber(); + int extent = sections[n].getLineExtent(); + + for( int k = base; k < (base+extent); k++ ) + { + if( k > maxLineItemIndex+1 ) + continue; + int j = _sourceTyrant.systemLine2UserLine(_sourceTextItem,k); + if( j > maxLineItemIndex+1 ) + continue; + SourceLineItemModel item = + (SourceLineItemModel) _sourceLineItemVector.elementAt(j-1); + + // don't overwrite function with top level script + + if( fun ) + item.type = SourceLineItemModel.FUNCTION_BODY; + else if( item.type != SourceLineItemModel.FUNCTION_BODY ) + item.type = SourceLineItemModel.TOP_LEVEL_SCRIPT; + } + } + + } + + // set breakpoints + Vector vecBP = bpt.getBreakpointsForURL( _sourceTextItem.getURL() ); + count = vecBP.size(); + for( i = 0; i < count; i++ ) + { + Breakpoint bp = (Breakpoint)vecBP.elementAt(i); + int line = bp.getLine(); + line = _sourceTyrant.systemLine2UserLine(_sourceTextItem,line); + + if( line > maxLineItemIndex+1 ) + continue; + + SourceLineItemModel item = (SourceLineItemModel) + _sourceLineItemVector.elementAt(line-1); + item.bp = bp; + } + + // set executing lines + + if( ControlTyrant.STOPPED == _controlTyrant.getState() ) + { + JSSourceLocation loc = _stackTyrant.getCurrentLocation(); + if( null != loc && loc.getURL().equals(url) ) + { + int index = loc.getLine(); + index = _sourceTyrant.systemLine2UserLine(_sourceTextItem,index); + + if( index > maxLineItemIndex+1 ) + index = maxLineItemIndex+1; + if( index < 1 ) + index = 1; + + SourceLineItemModel item = (SourceLineItemModel) + _sourceLineItemVector.elementAt(index-1); + item.executing = true; + } + } + + // set adjustment chars + + int[] adjArray = _sourceTyrant.getUserAdjustedLineArray(_sourceTextItem); + if( null != adjArray ) + { + String adjChar; + for( int k = 0; k < adjArray.length; k++ ) + { + int line = adjArray[k]; + if( line < 0 ) + { + line *= -1; + adjChar = "-"; + } + else + adjChar = "+"; + SourceLineItemModel item = (SourceLineItemModel) + _sourceLineItemVector.elementAt(line-1); + item.adjustmentChar = adjChar; + } + } + } + + + // This is out of date. If anyone wants to reserect it then they + // had better update this to do the right things! +/* + public synchronized void updateSingleLineItem( int lineNumber ) + { + BreakpointTyrant bpt = _sourceView.getBreakpointTyrant(); + Breakpoint bp = bpt.findBreakpoint( + new Location(_sourceTextItem.getURL(),lineNumber)); + + int maxLineItemIndex = _sourceLineItemVector.size() - 1; + if( lineNumber > maxLineItemIndex+1 ) + lineNumber = maxLineItemIndex+1; + + SourceLineItemModel item = (SourceLineItemModel) + _sourceLineItemVector.elementAt(lineNumber-1); + item.bp = bp; + } +*/ + + public Vector getLineItemVector() {return _sourceLineItemVector;} + public SourceTextItem getSourceTextItem() {return _sourceTextItem;} + + private SourceView _sourceView; + private SourceTyrant _sourceTyrant; + private ControlTyrant _controlTyrant; + private StackTyrant _stackTyrant; + private SourceTextItem _sourceTextItem; // has url, text, and fullness status + private Vector _sourceLineItemVector; +} + + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceViewManager.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceViewManager.java new file mode 100644 index 00000000000..8527765852f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceViewManager.java @@ -0,0 +1,288 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.api.*; + +public class SourceViewManager + implements Observer, Target, WindowOwner, PrefsSupport +{ + public SourceViewManager(Emperor emperor) + { + super(); + + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + _sourceTyrant = emperor.getSourceTyrant(); + _stackTyrant = emperor.getStackTyrant(); + + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_sourceTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_stackTyrant,"emperor init order problem", this); + + _sourceViews = new Hashtable(); + _preferedNewViewRect = new Rect(0,0,100,100); + + _controlTyrant.addObserver(this); + _stackTyrant.addObserver(this); + + _updateMarksTimer = new Timer(this, null, 1000 ); // 1 second wait + _updateMarksTimer.setCommand(UPDATE_MARKS); + _updateMarksTimer.setRepeats(false); + _updateMarksTimer.setCoalesce(true); + } + + // implement observer interface + public void update(Observable o, Object arg) + { + // XXX perhaps this object need do nothing? + if( o == _sourceTyrant ) + { + SourceTyrantUpdate update = (SourceTyrantUpdate)arg; + switch( update.type ) + { + case SourceTyrantUpdate.SELECT_CHANGED : + // ignore for now + break; + case SourceTyrantUpdate.VECTOR_CHANGED : + // XXX update all views + break; + case SourceTyrantUpdate.ITEM_CHANGED : + // XXX update particular view + break; + default: + // ignore any other types + break; + } + } + else if ( o == _stackTyrant ) + { + if( ControlTyrant.STOPPED == _controlTyrant.getState() ) + { + JSSourceLocation loc = _stackTyrant.getCurrentLocation(); + if(null == loc ) + return; + + SourceTextItem sti = + _sourceTyrant.findSourceItem( loc.getURL() ); + if(ASS)ER.T(null!=sti,"could not find SourceTextItem for " + loc.getURL(),this); + if(null == sti) + return; + + SourceView view = findView(sti); + if( null != view ) + activateView(view); + else + view = createView(sti); + + view.updateMarks(); + view.ensureSourceLineVisible( loc.getLine() ); + } + } + else if ( o == _controlTyrant ) + { + if( ControlTyrant.RUNNING == _controlTyrant.getState() ) + { + // set timer to refresh marks on visible windows after a bit + _updateMarksTimer.start(); + } + } + } + + // implement Target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(UPDATE_MARKS) ) + { + if( _controlTyrant.getEnabled() && + ControlTyrant.RUNNING == _controlTyrant.getState() ) + { + Object[] views = _sourceViews.elementsArray(); + for( int i = 0; i < views.length; i++ ) + { + SourceView view = (SourceView) views[i]; + if( view.isVisible() ) + view.updateMarks(); + } + } + } + } + + public SourceView findView(String url) + { + return (SourceView)_sourceViews.get(url); + } + + public SourceView findView(SourceTextItem item) + { + return findView(item.getURL()); + } + + private synchronized SourceView _createViewAtRect( Rect rect, SourceTextItem item ) + { + if(ASS)ER.T(null!=rect,"null rect in _createViewAtRect", this); + + if( null != findView(item.getURL()) ) + { + if(ASS)ER.T( false, "tried to create second SourceView for:" + item.getURL(), this); + return null; + } + + SourceView v = new SourceView( rect, _emperor, item ); + _sourceViews.put(item.getURL(),v); + return v; + } + + public synchronized SourceView createView( SourceTextItem item ) + { + // XXX add smarter way of determining location for new source view + Rect rect = _preferedNewViewRect; + SourceView view = _createViewAtRect( rect, item ); + if( null != view ) + view.setOwner(this); + _setSelDataForMainSourceView(view); + return view; + } + + public synchronized void activateView( SourceView view ) + { + view.show(); + } + + public synchronized void viewBeingRemoved( SourceView view ) + { + _sourceViews.remove(view.getURL()); + } + + public void setPreferedNewViewRect( Rect rect ){_preferedNewViewRect = rect;} + + public boolean getShowLineNumbers() {return _showLineNumbers;} + + public void setShowLineNumbers(boolean b) + { + if( _showLineNumbers == b ) + return; + _showLineNumbers = b; + + // force redraw of all visible views + Object[] views = _sourceViews.elementsArray(); + if( null == views ) + return; + for( int i = 0; i < views.length; i++ ) + { + SourceView view = (SourceView) views[i]; + if( view.isVisible() ) + view.forceRefresh(); + } + } + + public void selectionInSourceViewChanged( SourceView sv, String s, int lineno) + { + if( _mainSourceView != sv ) + return; + + _setSelDataForMainSourceView(sv); + + } + + // implement WindowOwner interface + public boolean windowWillShow(Window aWindow) {return true;} + public void windowDidShow(Window aWindow) {} + public boolean windowWillHide(Window aWindow) {return true;} + public void windowDidHide(Window aWindow) {} + public void windowWillSizeBy(Window aWindow, Size deltaSize) {} + public void windowDidBecomeMain(Window aWindow) + { + _setSelDataForMainSourceView((SourceView) aWindow); + } + public void windowDidResignMain(Window aWindow) + { + _setSelDataForMainSourceView(null); + } + + private void _setSelDataForMainSourceView(SourceView sv) + { + _mainSourceView = sv; + + if( null == sv ) + { + _selectedLineInMainSourceView = 0; + _selectedTextInMainSourceView = null; + _sourceTyrant.SetSelectedUrlLineText(null,0,null); + } + else + { + _selectedLineInMainSourceView = sv.getSelectedLineNumber(); + _selectedTextInMainSourceView = sv.getSelectedText(); + _sourceTyrant.SetSelectedUrlLineText( sv.getURL(), + _selectedLineInMainSourceView, + _selectedTextInMainSourceView ); + } + } + + // implement PrefsSupport interface + public void prefsWrite(Archiver archiver) throws CodingException + { + SourceViewSaver svs = new SourceViewSaver(); + svs.getFromManager(this); + archiver.archiveRootObject(svs); + } + public void prefsRead(Unarchiver unarchiver) throws CodingException + { + int id = Util.RootIdentifierForClassName(unarchiver.archive(), + "com.netscape.jsdebugging.ifcui.SourceViewSaver" ); + if( -1 != id ) + { + SourceViewSaver svs = (SourceViewSaver) + unarchiver.unarchiveIdentifier(id); + svs.sendToManager(this); + } + } + + // data... + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + private SourceTyrant _sourceTyrant; + private StackTyrant _stackTyrant; + private Hashtable _sourceViews; + private Rect _preferedNewViewRect; + private Timer _updateMarksTimer; + private boolean _showLineNumbers = false; + + private SourceView _mainSourceView = null; + private int _selectedLineInMainSourceView = 0; + private String _selectedTextInMainSourceView = null; + + private static final String UPDATE_MARKS = "UPDATE_MARKS"; + + private static final boolean ASS = true; // enable ASSERT support? +} + + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceViewSaver.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceViewSaver.java new file mode 100644 index 00000000000..75ed9db3c4b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/SourceViewSaver.java @@ -0,0 +1,64 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 08/01/97 jband created this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; + +public class SourceViewSaver + implements Codable +{ + // public ctor with no params necessary for Codable + public SourceViewSaver() {} + + // implement Codable + public void describeClassInfo(ClassInfo info) + { + info.addField("_showLineNumbers", BOOLEAN_TYPE); + } + public void encode(Encoder encoder) throws CodingException + { + encoder.encodeBoolean("_showLineNumbers", _showLineNumbers ); + } + public void decode(Decoder decoder) throws CodingException + { + _showLineNumbers = decoder.decodeBoolean("_showLineNumbers"); + } + public void finishDecoding() throws CodingException + { + } + + // interaction with 'owner' + + public void sendToManager( SourceViewManager svm ) + { + svm.setShowLineNumbers(_showLineNumbers); + } + + public void getFromManager( SourceViewManager svm ) + { + _showLineNumbers = svm.getShowLineNumbers(); + } + + private boolean _showLineNumbers; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StackTyrant.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StackTyrant.java new file mode 100644 index 00000000000..e80f024da60 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StackTyrant.java @@ -0,0 +1,177 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.api.*; + +public class StackTyrant + extends Observable + implements Observer +{ + public StackTyrant(Emperor emperor) + { + super(); + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + + _controlTyrant.addObserver(this); + } + + // implement observer interface + public void update(Observable o, Object arg) + { + if ( o == _controlTyrant ) + { + if( ControlTyrant.STOPPED == _controlTyrant.getState() ) + { + // fill list + + // invert the order from the DebugController + StackFrameInfo[] stack = null; + + try + { + stack = _controlTyrant.getThreadState().getStack(); + } + catch(InvalidInfoException e) + { + if(ASS)ER.T(false,"InvalidInfoException in StackTyrant",this); + } + + if(ASS)ER.T(null!=stack,"stack is null!",this); + if(ASS)ER.T(0!=stack.length,"stack is empty!",this); + + if( null != stack ) + { + _frameArray = new StackFrameInfo[stack.length]; + + for(int i = 0; i < stack.length; i++) + _frameArray[i] = stack[stack.length-(i+1)]; + } + + // set selected and notify + + _currentFrameIndex = 0; + _notifyArrayChanged(); + } + else + { + // clear and notify + _frameArray = null; + setCurrentFrame(0); + } + } + } + + public StackFrameInfo[] getFrameArray() {return _frameArray;} + public int getCurrentFrameIndex() {return _currentFrameIndex;} + public StackFrameInfo getCurrentFrame() + { + if( null == _frameArray ) + return null; +// if(ASS)ER.T(null!=_frameArray,"getCurrentFrame called when no frameArray!",this); + + return _frameArray[_currentFrameIndex]; + } + + + public JSSourceLocation getCurrentLocation() + { + if( null == _frameArray ) + return null; + if( ControlTyrant.STOPPED != _controlTyrant.getState() ) + return null; + + // if(ASS)ER.T(null!=_frameArray,"getCurrentLocation called when no frameArray!",this); + + StackFrameInfo rawframe = _frameArray[_currentFrameIndex]; + if( null == rawframe || ! (rawframe instanceof JSStackFrameInfo) ) + return null; + + JSPC pc; + try + { + pc = (JSPC) rawframe.getPC(); + } + catch(InvalidInfoException e) + { + if(ASS)ER.T(false,"InvalidInfoException in StackTyrant",this); + return null; + } + return (JSSourceLocation)pc.getSourceLocation(); + } + + public void setCurrentFrame( int i ) + { + if(ASS)ER.T(null==_frameArray||i>=0,"setCurrentFrame index out of bounds!",this); + if(ASS)ER.T(null==_frameArray||i<_frameArray.length,"setCurrentFrame index out of bounds!",this); + _currentFrameIndex = i; + _notifyCurrentFrameChanged(); + } + + private void _notifyCurrentFrameChanged() + { + setChanged(); + notifyObservers(new StackTyrantUpdate(StackTyrantUpdate.SELECT_CHANGED,_currentFrameIndex)); + } + + private void _notifyArrayChanged() + { + setChanged(); + notifyObservers(new StackTyrantUpdate(StackTyrantUpdate.ARRAY_CHANGED,_currentFrameIndex)); + } + + + // data... + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + + private int _currentFrameIndex; + private StackFrameInfo[] _frameArray; + + private static final boolean ASS = true; // enable ASSERT support? +} + +class StackTyrantUpdate +{ + public static final int SELECT_CHANGED = 0; + public static final int ARRAY_CHANGED = 1; + + public StackTyrantUpdate( int type, int sel ) + { + this.type = type; + this.sel = sel; + } + public int type; + public int sel; +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StackView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StackView.java new file mode 100644 index 00000000000..7bd7ad0783e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StackView.java @@ -0,0 +1,311 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import com.netscape.jsdebugging.api.*; + +public class StackView extends InternalWindow + implements Observer +{ + public StackView( Emperor emperor, + Rect rect ) + { + super(rect); + + _emperor = emperor; + _stackTyrant = emperor.getStackTyrant(); + _controlTyrant = emperor.getControlTyrant(); + _commandTyrant = emperor.getCommandTyrant(); + _sourceTyrant = emperor.getSourceTyrant(); + + if(ASS)ER.T(null!=_stackTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_commandTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_sourceTyrant,"emperor init order problem", this); + + _listview = new BackgroundHackListView(); + + Rect rectSG = new Rect(rect); + rectSG.moveBy(-rect.x, -rect.y); + ScrollGroup sg = new ScrollGroup(rectSG); + sg.setHorizScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg.setVertScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg.setContentView( _listview ); + sg.setAutoResizeSubviews(true); + sg.contentView().setLayoutManager( new MarginLayout() ); + sg.setBackgroundColor(_emperor.getBackgroundColor()); + + setCloseable( false ); + setResizable( true ); + setTitle( "Call Stack" ); + addSubview(sg); + setAutoResizeSubviews(true); + contentView().setLayoutManager( new MarginLayout() ); + + _listview.setAllowsEmptySelection(true); + _listview.setAllowsMultipleSelection(false); + + _listview.setTarget(_commandTyrant); + _listview.setCommand(_commandTyrant.cmdString(CommandTyrant.STACKVIEW_CLICK)); + _listview.setDoubleCommand(_commandTyrant.cmdString(CommandTyrant.STACKVIEW_DBLCLICK)); + _listview.setBackgroundColor(_emperor.getBackgroundColor()); + + _stackTyrant.addObserver(this); + _controlTyrant.addObserver(this); + _sourceTyrant.addObserver(this); + + _refresh(); + + layoutView(1,1); + layoutView(-1,-1); + +// show(); + + } + + private synchronized void _refresh() + { + // refill all + + _listview.removeAllItems(); + + if( ControlTyrant.STOPPED != _controlTyrant.getState() ) + { + _listview.draw(); + return; + } + + StackFrameInfo[] array = _stackTyrant.getFrameArray(); + + if( null != array && 0 != array.length ) + { + StackViewItemDrawer drawer = new StackViewItemDrawer(Font.defaultFont()); + + int maxwidth = 0; + for (int i = 0; i < array.length; i++) + { + ListItem newlistitem = new StackViewListItem(drawer); + + StackFrameInfo frame = array[i]; + + String text; + + if( frame instanceof JSStackFrameInfo ) + { + JSPC pc = null; + + try + { + pc = (JSPC) frame.getPC(); + } + catch(InvalidInfoException e) + { + if(ASS)ER.T(false,"InvalidInfoException in StackViewView",this); + } + if( null != pc ) + { + JSSourceLocation loc = (JSSourceLocation)pc.getSourceLocation(); + String function = pc.getScript().getFunction(); + int lineno = loc.getLine(); + + SourceTextItem sti = _sourceTyrant.findSourceItem(pc.getScript().getURL()); + lineno = _sourceTyrant.systemLine2UserLine(sti, lineno); + + if( null != function ) + text = new String( function + "() line " + lineno ); + else + text = new String( "line" + " " + lineno ); + } + else + { + text = new String( "BAD_FRAME" ); + } + } + else + { + text = new String( "FORIGN_FRAME" ); + } + newlistitem.setTitle( text ); + newlistitem.setSelectedColor(_emperor.getSelectionColor()); + + // item for current frame will have non-null data + if( _stackTyrant.getCurrentFrameIndex() == i ) + newlistitem.setData( this ); // anything non-null + else + newlistitem.setData( null ); + + maxwidth = Math.max( maxwidth, newlistitem.minWidth() ); + _listview.addItem( newlistitem ); + } + _listview.selectItemAt( _stackTyrant.getCurrentFrameIndex() ); + _listview.setBounds(0,0,maxwidth,0); + _listview.sizeToMinSize(); + layoutView(0,0); + } + _listview.draw(); + } + + + // implement observer interface + public void update(Observable o, Object arg) + { + if ( o == _stackTyrant ) + { + _refresh(); + } + else if( o == _commandTyrant ) + { + if( ControlTyrant.STOPPED != _controlTyrant.getState() ) + _refresh(); + } + else if( o == _sourceTyrant ) + { + int msg = ((SourceTyrantUpdate)arg).type; + if( SourceTyrantUpdate.ADJUSTMENTS_CHANGED == msg ) + _refresh(); + } + } + + + // data... + + private Emperor _emperor; + private StackTyrant _stackTyrant; + private ControlTyrant _controlTyrant; + private CommandTyrant _commandTyrant; + private SourceTyrant _sourceTyrant; + + private ListView _listview; + + private static final boolean ASS = true; // enable ASSERT support? +} + +class StackViewListItem extends ListItem +{ + public StackViewListItem(StackViewItemDrawer drawer) + { + super(); + _drawer = drawer; + } + + public int minWidth() {return super.minWidth() + _drawer.width();} + + public void drawInRect(Graphics g, Rect boundsRect) + { + drawBackground(g, boundsRect); + _drawer.draw( g, boundsRect, this, null != data() ); + } + + // make this public to be called by our drawer helper + public void drawStringInRect( Graphics g, String title, + Font titleFont, Rect textBounds, + int justification) + { + super.drawStringInRect(g,title,titleFont,textBounds,justification); + } + + private StackViewItemDrawer _drawer; + + private static final boolean ASS = true; // enable ASSERT support? +} + +class StackViewItemDrawer +{ + public StackViewItemDrawer( Font font ) + { + _font = font; + + _height = font.fontMetrics().stringHeight(); + int charWidth = font.fontMetrics().charWidth('0'); + + Rect rectExec = new Rect( 0, 0, _height/2, _height); + + _width = rectExec.x + rectExec.width; + int margin = _height / 4; + + rectExec.growBy( -(margin/2), -margin ); + rectExec.moveBy( 0, margin/2 ); + + _polyExecPoint = new Polygon(); + _polyExecPoint.addPoint( rectExec.x, rectExec.y ); + _polyExecPoint.addPoint( rectExec.x, rectExec.y + rectExec.height); + _polyExecPoint.addPoint( rectExec.x+rectExec.width, rectExec.midY()); + _polyExecPoint.addPoint( rectExec.x, rectExec.y ); + + _ptText = new Point( _width, 0 ); + } + + public void draw( Graphics g, + Rect boundsRect, + StackViewListItem item, + boolean isExecPoint ) + { +// SourceLineItemModel itemModel = (SourceLineItemModel) item.data(); + + Rect r = new Rect(); + + // draw the main text + + String text = item.title(); + if( null != text && 0 != text.length() ) + { + r.setBounds( boundsRect.x + _ptText.x, + boundsRect.y + _ptText.y, + boundsRect.width - _ptText.x, + boundsRect.height - _ptText.y ); + + item.drawStringInRect(g,text,_font,r,Graphics.LEFT_JUSTIFIED); + } + if( isExecPoint ) + { + int count = 4; + int[] x = new int[count]; + int[] y = new int[count]; + + for( int i = 0; i < count; i++ ) + { + x[i] = _polyExecPoint.xPoints[i] + boundsRect.x; + y[i] = _polyExecPoint.yPoints[i] + boundsRect.y; + } + + g.setColor( Color.blue ); + g.fillPolygon( x,y,count); + } + } + + public int width() {return _width;} + + private Font _font; + private int _width; + private int _height; + private Polygon _polyExecPoint; + private Point _ptText; + + private static final boolean ASS = true; // enable ASSERT support? +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StatusWindow.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StatusWindow.java new file mode 100644 index 00000000000..c4f30404696 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StatusWindow.java @@ -0,0 +1,80 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 11/10/97 jband added this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; + +class StatusWindow + extends InternalWindow +{ + private static final int _labelDX = 300; + private static final int _labelDY = 24; + private static final int _spacerDX = 5; + private static final int _spacerDY = 5; + + public StatusWindow() + { + super(); + + setBorder(LineBorder.blackLine()); + setCloseable( false ); + setResizable( false ); + + int contentDX = _labelDX + _spacerDX * 2; + int contentDY = _labelDY + _spacerDY * 2; + int labelY = _spacerDY; + int labelX = _spacerDX; + + Size size = windowSizeForContentSize(contentDX, contentDY); + setBounds(0,0,size.width,size.height); + + _label = _newLabel(labelX, labelY, _labelDX, _labelDY, ""); + addSubview(_label); + center(); + } + + + public void setText(String text) + { + _label.setStringValue(text); + draw(); + } + + private TextField _newLabel( int x, int y, int dx, int dy, String text ) + { + TextField label = new TextField(x,y,dx,dy); + label.setStringValue(text); + label.setEditable(false); + label.setSelectable(false); + label.setJustification(Graphics.LEFT_JUSTIFIED); + label.setBackgroundColor(Color.lightGray); + label.setBorder(null); + return label; + } + + private TextField _label; +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepHandler.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepHandler.java new file mode 100644 index 00000000000..6e0c61f30d1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepHandler.java @@ -0,0 +1,37 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.api.*; + +interface StepHandler +{ + public static final int STOP = 0; + public static final int CONTINUE_SEND_INTERRUPT = 1; + public static final int CONTINUE_DONE = 2; + + public int step( JSThreadState threadState, + JSPC pc, + JSSourceLocation sourceLocation, + Hook hook ); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepInto.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepInto.java new file mode 100644 index 00000000000..83d2120925d --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepInto.java @@ -0,0 +1,75 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.api.*; + +class StepInto implements StepHandler +{ + public StepInto(JSSourceLocation startSourceLocation, JSPC startPC ) + { + _startSourceLocation = startSourceLocation; + _startPC = startPC; + } + + // implement StepHandler + public int step( JSThreadState threadState, + JSPC pc, + JSSourceLocation sourceLocation, + Hook hook ) + { + // different script, gotta stop + if( ! pc.getScript().equals(_startPC.getScript()) ) + return STOP; + + // + // NOTE: This little dance is necessary because line numbers for PCs + // are not always acending. e,g, in: + // + // for(i=0;i _startSourceLocation.getLine() ) + return STOP; + + if(ASS){System.out.println( "returning from step_into - not our stop" );} + return CONTINUE_SEND_INTERRUPT; + } + + private JSSourceLocation _startSourceLocation; + private JSPC _startPC; + + private static final boolean ASS = true; // enable ASSERT support? +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepOut.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepOut.java new file mode 100644 index 00000000000..0b9d47bd81a --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepOut.java @@ -0,0 +1,63 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.api.*; + +class StepOut implements StepHandler +{ + public StepOut( JSThreadState startThreadState, + JSPC startPC ) + { + _callChain = new CallChain(startThreadState); + _startPC = startPC; + } + + // implement StepHandler + public int step( JSThreadState threadState, + JSPC pc, + JSSourceLocation sourceLocation, + Hook hook ) + { + switch( _callChain.compare(new CallChain(threadState)) ) + { + case CallChain.EQUAL: + return CONTINUE_SEND_INTERRUPT; + case CallChain.CALLER: + return STOP; + case CallChain.CALLEE: + return CONTINUE_SEND_INTERRUPT; + case CallChain.DISJOINT: + return STOP; + default: + if(ASS)ER.T(false,"coding error in StepOut (missed case)",this); + return STOP; + } + } + + private CallChain _callChain; + private JSPC _startPC; + + private static final boolean ASS = true; // enable ASSERT support? +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepOver.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepOver.java new file mode 100644 index 00000000000..b1ea3ad36ca --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StepOver.java @@ -0,0 +1,77 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.api.*; + +class StepOver implements StepHandler +{ + public StepOver( JSThreadState startThreadState, + JSSourceLocation startSourceLocation, + JSPC startPC ) + { + _callChain = new CallChain(startThreadState); + _startSourceLocation = startSourceLocation; + _startPC = startPC; + } + + // implement StepHandler + public int step( JSThreadState threadState, + JSPC pc, + JSSourceLocation sourceLocation, + Hook hook ) + { + switch( _callChain.compare(new CallChain(threadState)) ) + { + case CallChain.EQUAL: + break; + case CallChain.CALLER: + return STOP; + case CallChain.CALLEE: + return CONTINUE_SEND_INTERRUPT; + case CallChain.DISJOINT: + return STOP; + default: + if(ASS)ER.T(false,"coding error in StepOut (missed case)",this); + break; + } + + // definately jumping back + if( pc.getPC() < _startPC.getPC() && + sourceLocation.getLine() != _startSourceLocation.getLine() ) + return STOP; + + // definately jumping forward + if( sourceLocation.getLine() > _startSourceLocation.getLine() ) + return STOP; + + return CONTINUE_SEND_INTERRUPT; + } + + private CallChain _callChain; + private JSSourceLocation _startSourceLocation; + private JSPC _startPC; + + private static final boolean ASS = true; // enable ASSERT support? +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StringEditorDialog.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StringEditorDialog.java new file mode 100644 index 00000000000..aee9c1d178c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/StringEditorDialog.java @@ -0,0 +1,105 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; + +class StringEditorDialog + extends InternalWindow + implements Target +{ + private static final int _editDX = 300; + private static final int _editDY = 24; + private static final int _buttonDX = 64; + private static final int _buttonDY = 24; + private static final int _spacerDX = 5; + private static final int _spacerDY = 5; + + public StringEditorDialog(String title, String s, Font font) + { + super(); + + setTitle(title); + setCloseable( false ); + setResizable( false ); + + int contentDX = _editDX + _spacerDX * 2; + int contentDY = _editDY + _spacerDY * 3 + _buttonDY; + int buttonY = _editDY + _spacerDY * 2; + int buttonX2 = (_editDX + _spacerDX) - _buttonDX; + int buttonX1 = buttonX2 - _spacerDX - _buttonDX; + + Size size = windowSizeForContentSize(contentDX, contentDY); + setBounds(0,0,size.width,size.height); + _textfield = new TextField(_spacerDX,_spacerDY,_editDX,_editDY); + _textfield.setStringValue(new String(s)); + _textfield.setFont(font); + addSubview(_textfield); + + Button button; + + button = new Button(buttonX1,buttonY,_buttonDX,_buttonDY); + button.setTitle("OK"); + button.setTarget(this); + button.setCommand(OK_CMD); + addSubview(button); + + button = new Button(buttonX2,buttonY,_buttonDX,_buttonDY); + button.setTitle("Cancel"); + button.setTarget(this); + button.setCommand(CANCEL_CMD); + addSubview(button); + + setFocusedView( _textfield ); + center(); + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(OK_CMD) ) + { + _ok = true; + hide(); + } + else if( cmd.equals(CANCEL_CMD) ) + { + hide(); + } + } + + public boolean okPressed() {return _ok;} + + public String getString() + { + return null != _textfield ? _textfield.stringValue() : null; + } + + private TextField _textfield; + private boolean _ok = false; + private static final String OK_CMD = "OK_CMD"; + private static final String CANCEL_CMD = "CANCEL_CMD"; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Test.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Test.java new file mode 100644 index 00000000000..9e1ea68ecf6 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Test.java @@ -0,0 +1,581 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui; + +import com.netscape.jsdebugging.api.*; +import java.io.DataInputStream; +import netscape.util.Hashtable; +import netscape.util.Enumeration; + +class ErrorEater implements JSErrorReporter +{ + // implement JSErrorReporter interface + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + // eat it + System.out.print(msg); + return JSErrorReporter.RETURN; + } +} + +class HintMgr +{ + // To statically add hits: + // 1) add a "String[] XXX_hints" Object + // 2) add a {"XXX", XXX_hintsString} pair to "_hintSets" + + static final String[] Arguments_hints = + {"length", "callee", "caller"}; + + static final String[] Call_hints = + {"arguments", "__callee__", "__caller__", "__call__"}; + + static final String[] Function_hints = + {"arguments", "__arity__", "length", "__caller__", "__name__", "__call__"}; + + static final String[] Object_hints = + {"__proto__", "__parent__", "__count__"}; + + static final String[] RegExp_hints = + {"source", "global", "ignoreCase", "lastIndex"}; + + static final String[] String_hints = + {"length"}; + + static final Object[] _hintSets = { + "Arguments", Arguments_hints, + "Call", Call_hints, + "Function", Function_hints, + "Object", Object_hints, + "RegExp", RegExp_hints, + "String", String_hints + }; + + /**************************************************************/ + + public HintMgr() { + int count = _hintSets.length; + _table = new Hashtable(count); + for(int i = 0; i < count; i += 2) { + _setHints((String)_hintSets[i], (String[])_hintSets[i+1]); + } + } + + public String[] getHints(String classname) { + return (String[])_table.get(classname); + } + + public void setHints(String classname, String[] hints) { + if(null == classname || 0 == classname.length()) + return; + _table.remove(classname); + if(hints != null) + addHints(classname, hints); + } + + private void _setHints(String classname, String[] hints) { + _table.put(classname, hints); + } + + public void addHints(String classname, String[] hints) { + int newLength = 0; + if(null == classname || 0 == classname.length() || + null == hints || 0 == (newLength = hints.length)) + return; + + String[] oldHints = getHints(classname); + if(null != oldHints) { + int oldLength = oldHints.length; + String[] addHints = new String[newLength]; + int added = 0; + outer: for(int k = 0; k < newLength; k++) { + String hint = hints[k]; + if(null == hint || 0 == hint.length()) + continue; + for(int i = 0; i < oldLength; i++) { + if(hint.equals(oldHints[i])) + continue outer; + } + addHints[added++] = hint; + } + if(0 != added) { + String[] combined = new String[oldLength + added]; + System.arraycopy(oldHints, 0, combined, 0, oldLength); + System.arraycopy(addHints, 0, combined, oldLength, added); + _setHints(classname, combined); + } + } + else { + _setHints(classname, hints); + } + } + + public void addHint(String classname, String hint) { + String[] hints = {hint}; + addHints(classname, hints); + } + + public void dumpHints() { + System.out.println("HintMgr dump:"); + System.out.println(_table); + } + + private Hashtable _table; +} + + +class Test +{ + static HintMgr _hintMgr = new HintMgr(); + + static void doTest(Emperor emperor) + { + dumpPromptedObject(emperor, 1); +// dumpCallScopeThis(emperor); +// getPropTest(emperor); +// hintMgrTest(emperor); + } + + static final String[] helpText = { + "valid commands: #help | #call | #scope | #this | #{0-9}", + "", + "Property flags legend:", + "e...... canEnumerate()", + ".r..... isReadOnly()", + "..p.... isPermanent()", + "...a... hasAlias()", + "....A.. isArgument()", + ".....V. isVariable()", + "......H isHinted()", + "", + "Value flags legend:", + "o.......... isObject()", + ".n......... isNumber()", + "..i........ isInt()", + "...d....... isDouble()", + "....s...... isString()", + ".....b..... isBoolean()", + "......N.... isNull()", + ".......V... isVoid()", + "........p.. isPrimitive()", + ".........f. isFunction()", + "..........n isNative()" + }; + + static void showHelp() { + for(int i = 0; i < helpText.length; i++) + System.out.println(helpText[i]); + System.out.println(); + } + + static void hintMgrTest(Emperor emperor) + { + String[] hints0 = {"foo", "length"}; + String[] hints1 = {"bar", "baz"}; + String[] hints2 = {"length"}; + + // start state: + _hintMgr.dumpHints(); + System.out.println("adding String : foo"); + _hintMgr.addHint("String", "foo"); + _hintMgr.dumpHints(); + System.out.println("adding String : foo, length"); + _hintMgr.addHints("String", hints0); + _hintMgr.dumpHints(); + System.out.println("adding String : bar, baz"); + _hintMgr.addHints("String", hints1); + _hintMgr.dumpHints(); + System.out.println("clearing String"); + _hintMgr.setHints("String", null); + _hintMgr.dumpHints(); + System.out.println("adding String : length"); + _hintMgr.addHints("String", hints2); + _hintMgr.dumpHints(); + System.out.println("clearing String"); + _hintMgr.setHints("String", null); + _hintMgr.dumpHints(); + System.out.println("setting String : length"); + _hintMgr.addHints("String", hints2); + _hintMgr.dumpHints(); + } + + static void getPropTest(Emperor emperor) + { + ControlTyrant controlTyrant = emperor.getControlTyrant(); + if(controlTyrant.getState() != ControlTyrant.STOPPED) + return; + + try { + DebugController dc = emperor.getDebugController(); + JSStackFrameInfo frame = + (JSStackFrameInfo) emperor.getStackTyrant().getCurrentFrame(); + + if( null == dc || null == frame ) + { + System.out.println("dc or frame bad"); + return; + } + + JSErrorReporter oldER = + controlTyrant.setErrorReporter(new ErrorEater()); + + System.out.print("\n"); + + String strToEval = "fun"; + System.out.println(strToEval); + ExecResult r = + dc.executeScriptInStackFrameValue(frame,strToEval,"test",1); + Value the_obj = r.getResultValue(); +// the_obj = frame.getCallObject(); + + printVal(the_obj, 0); +// if(null != the_obj) +// the_obj = the_obj.getPrototype(); + + Property[] props = the_obj.getProperties(); + + if(null == props) + printLine(0, "props is null"); + else if(props.length == 0) + printLine(0, "props.length = 0"); + else + { + printLine(0, "props.length = "+ props.length); + + for(int i = 0; i < props.length; i++) + { + System.out.println(""); + printLine(0, "-------------prop---------------"); + printProp(props[i], 0); + printLine(0, "-------------value---------------"); + printVal(props[i].getValue(), 0); + } + } + + if(null != the_obj) + { + printLine(0, "-------------setPropertyHints ---------------"); + + if(null != the_obj) { + String[] hints = _hintMgr.getHints(the_obj.getClassName()); + if(null != hints) { + the_obj.setPropertyHints(hints); + the_obj.refresh(); + } + } + printVal(the_obj, 0); + + props = the_obj.getProperties(); + + if(null == props) + printLine(0, "props is null"); + else if(props.length == 0) + printLine(0, "props.length = 0"); + else + { + printLine(0, "props.length = "+ props.length); + + for(int i = 0; i < props.length; i++) + { + System.out.println(""); + printLine(0, "-------------prop---------------"); + printProp(props[i], 0); + printLine(0, "-------------value---------------"); + printVal(props[i].getValue(), 0); + } + } + } + + System.out.println(); + + controlTyrant.setErrorReporter(oldER); + } + catch(Exception e) { + System.out.println(e); + e.printStackTrace(); + // eat it... + } + + + } + + + static void dumpCallScopeThis(Emperor emperor) + { + ControlTyrant controlTyrant = emperor.getControlTyrant(); + if(controlTyrant.getState() != ControlTyrant.STOPPED) + return; + + try { + DebugController dc = emperor.getDebugController(); + JSStackFrameInfo frame = + (JSStackFrameInfo) emperor.getStackTyrant().getCurrentFrame(); + + if( null == dc || null == frame ) + { + System.out.println("dc or frame bad"); + return; + } + + JSErrorReporter oldER = + controlTyrant.setErrorReporter(new ErrorEater()); + + System.out.print("\n"); + + System.out.print("Call Object\n"); + Value callObject = frame.getCallObject(); + printVal(callObject, 0); + + Property[] props = callObject.getProperties(); + + if(null == props) + printLine(0, "props is null"); + else if(props.length == 0) + printLine(0, "props.length = 0"); + else + { + printLine(0, "props.length = "+ props.length); + + for(int i = 0; i < props.length; i++) + { + System.out.println(""); + printLine(0, "-------------prop---------------"); + printProp(props[i], 0); + printLine(0, "-------------value---------------"); + printVal(props[i].getValue(), 0); + } + } + + + System.out.print("Scope Chain\n"); + Value scopeChain = frame.getScopeChain(); + printVal(scopeChain, 0); + + System.out.print("this\n"); + Value thisp = frame.getThis(); + printVal(thisp, 0); + + System.out.println(); + + controlTyrant.setErrorReporter(oldER); + } + catch(Exception e) { + System.out.println(e); + e.printStackTrace(); + // eat it... + } + + + } + + static void dumpPromptedObject(Emperor emperor, int maxDepth) + { + ControlTyrant controlTyrant = emperor.getControlTyrant(); + if(controlTyrant.getState() != ControlTyrant.STOPPED) + return; + + while(true) + { + System.out.print("\n"); + System.out.print("eval> "); + try { + String str = new DataInputStream(System.in).readLine(); + if(null == str || 0 == str.length()) + { + System.out.println(); + return; + } + + DebugController dc = emperor.getDebugController(); + JSStackFrameInfo frame = + (JSStackFrameInfo) emperor.getStackTyrant().getCurrentFrame(); + + if( null == dc || null == frame ) + { + System.out.println("dc or frame bad"); + return; + } + + JSErrorReporter oldER = + controlTyrant.setErrorReporter(new ErrorEater()); + + Value val = null; + + if(str.charAt(0) == '#') { + if(str.equals("#help")) { + showHelp(); + continue; + } + else if(str.equals("#call")) + val = frame.getCallObject(); + else if(str.equals("#scope")) + val = frame.getScopeChain(); + else if(str.equals("#this")) + val = frame.getThis(); + else { + try { + maxDepth = Integer.parseInt(str.substring(1).trim()); + System.out.println("maxDepth set to "+maxDepth+"\n"); + + } catch(NumberFormatException e) { + System.out.println("bad input..."); + showHelp(); + } + continue; + } + } + else { + ExecResult r = + dc.executeScriptInStackFrameValue(frame,str,"test",1); + if(r.getErrorOccured()) + { + System.out.println("Error..."); + + System.out.println(r.getErrorMessage() +"\t"+"getErrorMessage()"); + System.out.println(r.getErrorFilename() +"\t"+"getErrorFilename()"); + System.out.println(r.getErrorLineNumber() +"\t"+"getErrorLineNumber()"); + System.out.println(r.getErrorLineBuffer() +"\t"+"getErrorLineBuffer()"); + System.out.println(r.getErrorTokenOffset() +"\t"+"getErrorTokenOffset()"); + System.out.println(); + continue; + } + val = r.getResultValue(); + } + if(null != val && val.isObject()) { + String classname = val.getClassName(); + if(null != classname) { + String[] hints = _hintMgr.getHints(classname); + if(null != hints) { + val.setPropertyHints(hints); + val.refresh(); + } + } + } + printValRecursive(val, 0, maxDepth); + + System.out.println(); + + controlTyrant.setErrorReporter(oldER); + } + catch(Exception e) { + System.out.println(e); + e.printStackTrace(); + // eat it... + } + } + } + + static void printValRecursive(Value val, int indent, int maxDepth) + { + if(null == val) + { + System.out.println("Value is null"); + } + else + { + printVal(val, indent); + Property[] props = val.getProperties(); + + if(null == props) + printLine(indent, "props is null"); + else if(props.length == 0) + printLine(indent, "props.length = 0"); + else + { + printLine(indent, "props.length = "+ props.length); + + for(int i = 0; i < props.length; i++) + { + System.out.println(""); + printLine(indent, "-------------prop---------------"); + printProp(props[i], indent); + printLine(indent, "-------------value---------------"); + printVal(props[i].getValue(), indent); + } + } + if(null != val.getPrototype() && maxDepth-1 > 0) + { + printLine(indent, "====================================="); + printLine(indent, "=============prototype==============="); + printValRecursive(val.getPrototype(), indent+4, maxDepth-1); + } + } + } + + + static void printProp(Property prop, int indent) + { + printLine(indent, ""+prop.toString()); +/** +* printLine(indent, ""+prop.isNameString() +"\t"+"isNameString()"); +* printLine(indent, ""+prop.isAliasString() +"\t"+"isAliasString()"); +* printLine(indent, ""+prop.getNameString() +"\t"+"getNameString()"); +* printLine(indent, ""+prop.getNameInt() +"\t"+"getNameInt()"); +* printLine(indent, ""+prop.getAliasString()+"\t"+"getAliasString()"); +* printLine(indent, ""+prop.getAliasInt() +"\t"+"getAliasInt()"); +* // printLine(indent, ""+prop.getValue() +"\t"+"getValue()"); +* printLine(indent, ""+prop.getValArgSlot() +"\t"+"getValArgSlot()"); +* printLine(indent, ""+prop.getFlags() +"\t"+"getFlags()"); +* printLine(indent, ""+prop.canEnumerate() +"\t"+"canEnumerate()"); +* printLine(indent, ""+prop.isReadOnly() +"\t"+"isReadOnly()"); +* printLine(indent, ""+prop.isPermanent() +"\t"+"isPermanent()"); +* printLine(indent, ""+prop.hasAlias() +"\t"+"hasAlias()"); +* printLine(indent, ""+prop.isArgument() +"\t"+"isArgument()"); +* printLine(indent, ""+prop.isVariable() +"\t"+"isVariable()"); +*/ + } + + static void printVal(Value val, int indent) + { + + printLine(indent, ""+val.toString()); + +/** +* printLine(indent, ""+val.isObject() +"\t"+"isObject()"); +* printLine(indent, ""+val.isNumber() +"\t"+"isNumber()"); +* printLine(indent, ""+val.isInt() +"\t"+"isInt()"); +* printLine(indent, ""+val.isDouble() +"\t"+"isDouble()"); +* printLine(indent, ""+val.isString() +"\t"+"isString()"); +* printLine(indent, ""+val.isBoolean() +"\t"+"isBoolean()"); +* printLine(indent, ""+val.isNull() +"\t"+"isNull()"); +* printLine(indent, ""+val.isVoid() +"\t"+"isVoid()"); +* printLine(indent, ""+val.isPrimitive() +"\t"+"isPrimitive()"); +* printLine(indent, ""+val.isFunction() +"\t"+"isFunction()"); +* printLine(indent, ""+val.isNative() +"\t"+"isNative()"); +* printLine(indent, ""+val.getBoolean() +"\t"+"getBoolean()"); +* printLine(indent, ""+val.getInt() +"\t"+"getInt()"); +* printLine(indent, ""+val.getDouble() +"\t"+"getDouble()"); +* printLine(indent, ""+val.toString() +"\t"+"toString()"); +* printLine(indent, ""+val.getFunctionName()+"\t"+"getFunctionName()"); +* printLine(indent, ""+val.getPrototype() +"\t"+"getPrototype()"); +* printLine(indent, ""+val.getParent() +"\t"+"getParent()"); +* printLine(indent, ""+val.getConstructor() +"\t"+"getConstructor()"); +*/ + } + static void printLine(int indent, String str) { + for(int i=0; i < indent; i++) + System.out.print(" "); + System.out.println(str); + System.out.flush(); + } +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Util.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Util.java new file mode 100644 index 00000000000..8dbaf791feb --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/Util.java @@ -0,0 +1,91 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.io.*; +import netscape.application.*; +import netscape.util.*; + + +/** +* Static util functions... +*/ + +public class Util +{ + public static String expandTabs(String aString, int tabstops) + { + if( -1 == aString.indexOf('\t') ) + return aString; + + StringBuffer sb = new StringBuffer(); + int i,c; + char ch; + int newi; + + for(i=0,newi=0,c=aString.length(); i < c ; i++, newi++ ) + { + ch = aString.charAt(i); + if( ch == '\t' ) + { + int spaces = ((newi+(tabstops-1))%tabstops)+1; + for( int k = 0; k < spaces; k++ ) + sb.append(" "); + newi += spaces-1; + } + else + sb.append(ch); + } + return sb.toString(); + } + + + /** + * Searches IFC Archive for root with given classname. + * returns rootidentifier on success, -1 on failure + * + * NOTE: this makes the assupmtion that there will only be one + * rootidentifier for a given classname. I don't think IFC + * enforces this. If you want to make that convention and + * use this method, then beware. + * + */ + + public static int RootIdentifierForClassName( Archive a, String n ) + { + int[] rootIdentifiers = a.rootIdentifiers(); + if( null != rootIdentifiers && 0 != rootIdentifiers.length ) + { + for( int i = 0; i < rootIdentifiers.length; i++ ) + { + int id = rootIdentifiers[i]; + if( n.equals(a.classTableForIdentifier(id).className()) ) + return id; + } + } + return -1; + } + + + public static final String TEN_ZEROS = "0000000000"; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchSaver.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchSaver.java new file mode 100644 index 00000000000..41d9d53ff17 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchSaver.java @@ -0,0 +1,75 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 09/25/97 jband created this file +// + +package com.netscape.jsdebugging.ifcui; + +import netscape.application.*; +import netscape.util.*; + +public class WatchSaver + implements Codable +{ + // public ctor with no params necessary for Codable + public WatchSaver() {} + + // implement Codable + public void describeClassInfo(ClassInfo info) + { + info.addField("_watches", OBJECT_ARRAY_TYPE); + } + public void encode(Encoder encoder) throws CodingException + { + if( null != _watches && 0 != _watches.length ) + encoder.encodeObjectArray("_watches", _watches, 0, _watches.length); + } + public void decode(Decoder decoder) throws CodingException + { + _watches = decoder.decodeObjectArray("_watches"); + } + public void finishDecoding() throws CodingException + { + } + + // interaction with WatchTyrant + + public void sendToTyrant( WatchTyrant wt ) + { + if( null == _watches || 0 == _watches.length ) + return; + for(int i = 0; i < _watches.length; i++ ) + wt.addWatchString((String)_watches[i]); + } + + public void getFromTyrant( WatchTyrant wt ) + { + _watches = null; + Vector v = wt.getWatchList(); + if( null == v || 0 == v.size() ) + return; + _watches = new Object[v.size()]; + for( int i = 0; i < v.size(); i++ ) + _watches[i] = v.elementAt(i); + } + + private Object[] _watches; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchTyrant.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchTyrant.java new file mode 100644 index 00000000000..ec98dcd5516 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchTyrant.java @@ -0,0 +1,123 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; + +public class WatchTyrant + extends Observable + implements Observer, PrefsSupport +{ + public WatchTyrant(Emperor emperor) + { + super(); + _emperor = emperor; + _controlTyrant = emperor.getControlTyrant(); + _consoleTyrant = emperor.getConsoleTyrant(); + _stackTyrant = emperor.getStackTyrant(); + + if(ASS)ER.T(null!=_controlTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_consoleTyrant,"emperor init order problem", this); + if(ASS)ER.T(null!=_stackTyrant,"emperor init order problem", this); + + _evalStrings = new Vector(); + + // test.... +// _evalStrings.addElement( new String( "local" ) ); +// _evalStrings.addElement( new String( "ob" ) ); +// _evalStrings.addElement( new String( "prop" ) ); +// _evalStrings.addElement( new String( "ob[prop]" ) ); + + _stackTyrant.addObserver(this); + } + + // implement observer interface + public void update(Observable o, Object arg) + { + if ( o == _stackTyrant ) + evalList(); + } + + public Vector getWatchList() + { + return _evalStrings; + } + + public void addWatchString(String s) + { + _evalStrings.addElement(s); + } + + public void evalList() + { + if( null != _stackTyrant.getCurrentFrame() ) + _evalOurList(); + } + + private void _evalOurList() + { + int count = _evalStrings.count(); + for( int i = 0; i < count; i++ ) + { + String s = (String) _evalStrings.elementAt(i); + if( null != s || 0 != s.length() ) + _consoleTyrant.eval(s); + } + } + + // implement PrefsSupport interface + public void prefsWrite(Archiver archiver) throws CodingException + { + WatchSaver ws = new WatchSaver(); + ws.getFromTyrant(this); + archiver.archiveRootObject(ws); + } + public void prefsRead(Unarchiver unarchiver) throws CodingException + { + int id = Util.RootIdentifierForClassName(unarchiver.archive(), + "com.netscape.jsdebugging.ifcui.WatchSaver" ); + if( -1 != id ) + { + WatchSaver ws = (WatchSaver) + unarchiver.unarchiveIdentifier(id); + ws.sendToTyrant(this); + } + } + + // data... + + private Emperor _emperor; + private ControlTyrant _controlTyrant; + private ConsoleTyrant _consoleTyrant; + private StackTyrant _stackTyrant; + private Vector _evalStrings; + + private static final boolean ASS = true; // enable ASSERT support? +} + + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchView.java new file mode 100644 index 00000000000..aba52a4b569 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/WatchView.java @@ -0,0 +1,282 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// when who what +// 06/27/97 jband added this header to my code +// + +package com.netscape.jsdebugging.ifcui; + +import java.util.Observable; +import java.util.Observer; +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.util.ER; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; + +public class WatchView + extends InternalWindow + implements Observer, Target +{ + private static final int _buttonWidth = 70; + private static final int _buttonHeight = 24; + private static final int _buttonYSpace = 5; + private static final int _buttonXSpace = 5; + + private int _nextButtonX; + private int _nextButtonY; + + public WatchView( Emperor emperor, Rect rect ) + { + super(rect); + + _emperor = emperor; + _watchTyrant = emperor.getWatchTyrant(); + _commandTyrant = emperor.getCommandTyrant(); + + if(ASS)ER.T(null!=_watchTyrant ,"emperor init order problem", this); + if(ASS)ER.T(null!=_commandTyrant,"emperor init order problem", this); + + _listview = new BackgroundHackListView(); + + Size size = contentSize(); + int listwidth = size.width - (_buttonWidth + (_buttonXSpace * 2)); + Rect rectSG = new Rect(0, 0, listwidth, size.height); + + _nextButtonX = listwidth + _buttonXSpace; + _nextButtonY = _buttonYSpace; + + _addButton( "New", NEW_CMD ); + _addButton( "Edit", EDIT_CMD); + _addButton( "Move Up", UP_CMD ); + _addButton( "Move Down", DOWN_CMD); + _addButton( "Delete", DEL_CMD ); + _addButton( "Eval", EVAL_CMD); + _nextButtonY += _buttonYSpace * 2; + _addButton( "Done", DONE_CMD); + + ScrollGroup sg = new ScrollGroup(rectSG); + sg.setHorizScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg.setVertScrollBarDisplay( ScrollGroup.AS_NEEDED_DISPLAY ); + sg.setContentView( _listview ); + sg.setAutoResizeSubviews(true); + sg.contentView().setLayoutManager( new MarginLayout() ); + sg.setBackgroundColor(_emperor.getBackgroundColor()); + + setCloseable( false ); + setResizable( false ); + setTitle( "Watches" ); + addSubview(sg); + setAutoResizeSubviews(true); + + _listview.setAllowsEmptySelection(false); + _listview.setAllowsMultipleSelection(false); + + _listview.setTarget(this); + _listview.setCommand(""); + _listview.setDoubleCommand(EDIT_CMD); + + _listview.setBackgroundColor(_emperor.getBackgroundColor()); + + setLayer(InternalWindow.PALETTE_LAYER); + + refresh(); + + layoutView(1,1); + layoutView(-1,-1); + } + + private Button _addButton( String title, String cmd ) + { + Button button = new Button(_nextButtonX,_nextButtonY, + _buttonWidth,_buttonHeight); + button.setTitle(title); + button.setTarget(this); + button.setCommand(cmd); + addSubview(button); + _nextButtonY += _buttonHeight + _buttonYSpace; + return button; + } + + // implement observer interface + public void update(Observable o, Object arg) + { + } + + // implement target interface + public void performCommand(String cmd, Object data) + { + if( cmd.equals(NEW_CMD ) ) + { + StringEditorDialog sed = new StringEditorDialog("New Watch", "", + _emperor.getFixedFont()); + sed.showModally(); + if( sed.okPressed() ) + { + int index = _listview.selectedIndex(); + if( -1 == index ) + index = 0; + + Vector vec = _watchTyrant.getWatchList(); + synchronized( vec ) + { + vec.insertElementAt(sed.getString(),index); + } + refresh(); + _listview.selectItemAt(index); + _watchTyrant.evalList(); + } + } + else if( cmd.equals(EDIT_CMD) ) + { + int index = _listview.selectedIndex(); + if( -1 == index ) + return; + Vector vec = _watchTyrant.getWatchList(); + synchronized( vec ) + { + String str = (String) vec.elementAt(index); + StringEditorDialog sed = new StringEditorDialog("Edit Watch", + str, + _emperor.getFixedFont()); + sed.showModally(); + + if( sed.okPressed() ) + { + vec.setElementAt(sed.getString(),index); + refresh(); + _listview.selectItemAt(index); + _watchTyrant.evalList(); + } + } + } + else if( cmd.equals(UP_CMD ) ) + { + int index = _listview.selectedIndex(); + if( index < 1 ) + return; + Vector vec = _watchTyrant.getWatchList(); + synchronized( vec ) + { + String s = (String) vec.removeElementAt(index); + vec.insertElementAt(s,index-1); + } + refresh(); + _watchTyrant.evalList(); + } + else if( cmd.equals(DOWN_CMD) ) + { + int index = _listview.selectedIndex(); + if( index < 0 || index == _listview.count()-1) + return; + Vector vec = _watchTyrant.getWatchList(); + synchronized( vec ) + { + String s = (String) vec.removeElementAt(index); + vec.insertElementAt(s,index+1); + } + refresh(); + _watchTyrant.evalList(); + } + else if( cmd.equals(DEL_CMD ) ) + { + int index = _listview.selectedIndex(); + if( index < 0 ) + return; + Vector vec = _watchTyrant.getWatchList(); + synchronized( vec ) + { + vec.removeElementAt(index); + } + refresh(); + _watchTyrant.evalList(); + } + else if( cmd.equals(EVAL_CMD) ) + { + _watchTyrant.evalList(); + } + else if( cmd.equals(DONE_CMD) ) + { + Application.application().performCommandLater( + _commandTyrant, + _commandTyrant.cmdString(CommandTyrant.WATCHES_SHOW_HIDE), + this ); + } + } + + public synchronized void refresh() + { + String selText = null; + ListItem selItem = _listview.selectedItem(); + if( null != selItem ) + selText = selItem.title(); + + _listview.removeAllItems(); + + Font linefont = _emperor.getFixedFont(); + int maxlinelen = 0; + + Vector vec = _watchTyrant.getWatchList(); + synchronized( vec ) + { + for (int i = 0; i < vec.size(); i++) + { + String text = (String) vec.elementAt(i); + ListItem item = new ListItem(); + + maxlinelen = Math.max( maxlinelen, text.length() ); + item.setTitle( text ); + item.setFont( linefont ); + item.setSelectedColor(_emperor.getSelectionColor()); + _listview.addItem( item ); + + if( 0 == i ) + _listview.selectItemAt(i); // make sure SOMETHING selected + + if( null != selText && selText.equals(text) ) + { + _listview.selectItemAt(i); + selText = null; // we only want the first match... + } + } + } + FontMetrics fm = linefont.fontMetrics(); + _listview.setBounds( 0, 0, (maxlinelen+1) * fm.charWidth('X'),0 ); + _listview.sizeToMinSize(); + + layoutView(0,0); + _listview.draw(); + } + + private Emperor _emperor; + private WatchTyrant _watchTyrant; + private CommandTyrant _commandTyrant; + private ListView _listview; + + private static final String NEW_CMD = "NEW_CMD"; + private static final String EDIT_CMD = "EDIT_CMD"; + private static final String UP_CMD = "UP_CMD"; + private static final String DOWN_CMD = "DOWN_CMD"; + private static final String DEL_CMD = "DEL_CMD"; + private static final String EVAL_CMD = "EVAL_CMD"; + private static final String DONE_CMD = "DONE_CMD"; + + private static final boolean ASS = true; // enable ASSERT support? +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/launcher/local/LaunchJSDebugger.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/launcher/local/LaunchJSDebugger.java new file mode 100644 index 00000000000..32391280a9f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/launcher/local/LaunchJSDebugger.java @@ -0,0 +1,44 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.launcher.local; + +import com.netscape.jsdebugging.ifcui.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/jsdj/classes/com/netscape/jsdebugging/ifcui/launcher/rhino/LaunchNetscapeJavaScriptDebugger.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/launcher/rhino/LaunchNetscapeJavaScriptDebugger.java new file mode 100644 index 00000000000..d12f0cd9ca0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/launcher/rhino/LaunchNetscapeJavaScriptDebugger.java @@ -0,0 +1,54 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.launcher.rhino; + +import com.netscape.javascript.SourceTextManager; +import com.netscape.javascript.debug.IDebugManager; +import com.netscape.javascript.debug.ILaunchableDebugger; +import com.netscape.jsdebugging.ifcui.JSDebuggerApp; +import com.netscape.jsdebugging.api.rhino.DebugControllerRhino; +import com.netscape.jsdebugging.api.rhino.SourceTextProviderRhino; + +public class LaunchNetscapeJavaScriptDebugger + implements ILaunchableDebugger, Runnable +{ + // implements LaunchableDebugger + public Thread launch(IDebugManager dbm, SourceTextManager stm, + boolean daemon) + { + DebugControllerRhino.setGlobalDebugManager(dbm); + SourceTextProviderRhino.setGlobalSourceTextManager(stm); + + LaunchNetscapeJavaScriptDebugger self = + new LaunchNetscapeJavaScriptDebugger(); + Thread t = new Thread(self); + if(daemon) + t.setDaemon(true); + t.start(); + return t; + } + + // implements Runnable + public void run() + { + JSDebuggerApp app = new JSDebuggerApp(); + app.setMode("RHINO"); + app.run(); + } +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/README b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/README new file mode 100644 index 00000000000..5c66b3f740e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/README @@ -0,0 +1,5 @@ +/* jband - 09/14/98 - */ + +com.netscape.jsdebugging.ifcui.palomar contains the minimal set of classes used +by the IFC based graphical debugger. These classes were originally developed as +a (very) small part of the Netscape Visual JavaScript system. \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/util/AssertFailureHandler.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/util/AssertFailureHandler.java new file mode 100644 index 00000000000..89ed7bf51e1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/util/AssertFailureHandler.java @@ -0,0 +1,40 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.palomar.util; + +/** + * Interface that is called on a given thread to respond to assertion failure. + * + * @see ER + */ + +public interface AssertFailureHandler +{ + public static final int CONTINUE = 0; + public static final int ABORT = 1; + public static final int DEBUG = 3; + + /** + * Called when assertion fails + * @param msgRaw the raw message as passed to ER.T() + * @param msgCooked the message generated in ER (includes msgRaw) + * @param ob the Object (optionally) passed to ER.T(). MAY be null + */ + public int assertFailed( String msgRaw, String msgCooked, Object ob ); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/util/ER.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/util/ER.java new file mode 100644 index 00000000000..c25b6ee04e8 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/util/ER.java @@ -0,0 +1,225 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.palomar.util; + +import java.util.Hashtable; + +/** +* ASSERT support for Java +*

+* usage:
+*     // set flag in your class
+*     private static final boolean ASS = true;    // false to disable ASSERT
+*
+*     // use in your class
+*     if(ASS)ER.T( expr, message, this);
+*
+*     // use in your class
+*     if(ASS)ER.T( i==5, "i is screwed up in foo()", this);
+* 
+* +* There are various versions of the T() method. +* +* Setting "ASS = false" in this class will globally disable +* ASSERT, but the local expressions will still be evaluated. +* +* Debuggers can be set to catch "com.netscape.jsdebugging.ifcui.palomar.util.DebuggerCaughtException" +* exceptions. The effect of a DebugBreak() is thus available. +* +* Handlers can be set on a per thread basis. If present, the handler for +* the given thread will be called on assert failure. This allows the possiblity +* of showing an assert dialog and leting the user decide how to proceed. +* e.g. "Continue", "Abort", "Debug". +* +*/ + +public class ER +{ + + /** + * This class is never instantiated + */ + private ER(){} + + /** + * call with only an expression + */ + public static void T( boolean expr ) + { + if( ASS ) + if( ! expr ) + assert_fail( null, null, true ); + } + + /** + * call with an expression and an object that is either a msg or 'this' + */ + public static void T( boolean expr, Object ob ) + { + if( ASS ) + if( ! expr ) + if( ob instanceof String ) + assert_fail( (String)ob, null, true ); + else + assert_fail( null, ob, true ); + } + + /** + * Runs like the normal T method, except that it is intended to + * work when not on the IFC thread, which would otherwise freeze + * the program. This just throws the DebuggerCaughtException. + * + * Should modify this to promt the user on the command line + * but this is not implemented yet. + */ + public static void T_NO_GUI( boolean expr, String message ) + { + if( ASS ) + if( ! expr ) + assert_fail(message, null, false); + } + + /** + * call with an expression, a msg, and a classname (for use in static methods) + */ + public static void T( boolean expr, String msg, String classname ) + { + if( ASS ) + if( ! expr ) + try + { + assert_fail( msg, Class.forName(classname), true ); + } + catch( ClassNotFoundException e ) + { + assert_fail( msg, null, true ); + } + } + + /** + * call with an expression, a msg, and 'this' (the 'normal' case) + */ + public static void T( boolean expr, String msg, Object ob ) + { + if( ASS ) + if( ! expr ) + assert_fail( msg, ob, true ); + } + + /** + * Set a handler to be used for failures on given thread + */ + public static void setFailureHandler(Thread t, AssertFailureHandler h) + { + if(ASS) + { + if( null == _FailureHandlers ) + _FailureHandlers = new Hashtable(); + if( null != h ) + _FailureHandlers.put(t,h); + else + _FailureHandlers.remove(t); + } + } + + /** + * Get handler for given thread + */ + public static AssertFailureHandler getFailureHandler(Thread t) + { + if(ASS) + { + if( null != _FailureHandlers ) + return (AssertFailureHandler) _FailureHandlers.get(t); + } + return null; + } + + private static void assert_fail(String msg, Object ob, boolean useHandler) + { + if( ASS ) + { + String errMsg = buildString( msg, ob ); + System.out.println( "===============!!!==============" ); + System.out.println( errMsg ); + System.out.println( "===============!!!==============" ); + + int choice = AssertFailureHandler.DEBUG; + + if( useHandler && null != _FailureHandlers ) + { + AssertFailureHandler handler = (AssertFailureHandler) + _FailureHandlers.get(Thread.currentThread()); + if( null != handler ) + choice = handler.assertFailed( msg, errMsg, ob ); + } + + switch(choice) + { + case AssertFailureHandler.CONTINUE: + // do nothing... + break; + case AssertFailureHandler.ABORT: + System.exit(0); + break; + case AssertFailureHandler.DEBUG: + default: + try + { + throw new DebuggerCaughtException(errMsg); + } + catch( DebuggerCaughtException e ) + { + // eat exception (but catch in debugger) + } + } + } + } + + private static String buildString( String msg, Object ob ) + { + String str = null; + if( ASS ) + { + str = "!!!Assertion failed!!!"; + if( null != msg ) + str += "\n " + msg; + if( null != ob ) + { + str += "\n Classname = " + ob.getClass(); + str += "\n Object dump: " + ob; + } + } + return str; + } + + private static Hashtable _FailureHandlers = null; + + private static final boolean ASS = true; // false to diasable +} + +/** +* Set debugger to catch this class of exceptions (use full name) +*/ +class DebuggerCaughtException extends RuntimeException { + DebuggerCaughtException(String msg) { + super(msg); + } +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/BorderView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/BorderView.java new file mode 100644 index 00000000000..5172b778e85 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/BorderView.java @@ -0,0 +1,86 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget; + +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import netscape.application.*; +import netscape.util.*; + +/** + * A class that draw a border arounds }nntent view + */ +public class BorderView extends MarginView +{ + public BorderView() + { + } + + public BorderView(Border border) + { + setBorder(border); + + _border = border; + } + + public void setBorder(Border border) + { + _border = border; + + if (border == null) + { + setLeftMargin(0); + setRightMargin(0); + setTopMargin(0); + setBottomMargin(0); + } else { + setLeftMargin(border.leftMargin()); + setRightMargin(border.rightMargin()); + setTopMargin(border.topMargin()); + setBottomMargin(border.bottomMargin()); + } + } + + public Border getBorder() + { + return _border; + } + + public void drawSubviews(Graphics g) + { + super.drawSubviews(g); + + if (_border != null && _hideBorder == false) + _border.drawInRect(g,0,0,width(),height()); + } + + public void setHideBorder(boolean hide) + { + _hideBorder = hide; + } + + public boolean doesHideBorder() + { + return _hideBorder; + } + + private Border _border; + private boolean _hideBorder = false; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/GrayScaleImageFilter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/GrayScaleImageFilter.java new file mode 100644 index 00000000000..66155c64550 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/GrayScaleImageFilter.java @@ -0,0 +1,64 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.palomar.widget; + +import netscape.application.*; +import java.awt.image.*; + +public class GrayScaleImageFilter extends RGBImageFilter +{ + public GrayScaleImageFilter() { + // The filter's operation does not depend on the + // pixel's location, so IndexColorModels can be + // filtered directly. + canFilterIndexColorModel = true; + } + + public int filterRGB(int x, int y, int rgb) + { + // this routine should be faster if I didn't use colors + // I could just do it with shifts but I don't want to figure it + // out yet. + + int pixel = rgb; + + int alpha = (pixel >> 24) & 0xff; + int red = (pixel >> 16) & 0xff; + int green = (pixel >> 8) & 0xff; + int blue = pixel & 0xff; + + Color c = null; + + // if there is any alpha just leave the color as it is + + if (alpha == 0) { + return rgb; + } else { + // otherwise take the average of the rgb components and + // use that as the color + int a = (red + green + blue)/3; + rgb = ((a & 0xFF) << 16) | ((a & 0xFF) << 8) | ((a & 0xFF) << 0); + + return 0xff000000 | rgb; + } + } + + private static final double FACTOR = 0.7; + +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/HighlightingImageFilter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/HighlightingImageFilter.java new file mode 100644 index 00000000000..c439a2016e8 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/HighlightingImageFilter.java @@ -0,0 +1,83 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.palomar.widget; + +import netscape.application.*; +import java.awt.image.*; + +public class HighlightingImageFilter extends RGBImageFilter +{ + public HighlightingImageFilter() { + // The filter's operation does not depend on the + // pixel's location, so IndexColorModels can be + // filtered directly. + canFilterIndexColorModel = true; + } + + public int filterRGB(int x, int y, int rgb) + { + // this routine should be faster if I didn't use colors + // I could just do it with shifts but I don't want to figure it + // out yet. + + int pixel = rgb; + + int alpha = (pixel >> 24) & 0xff; + int red = (pixel >> 16) & 0xff; + int green = (pixel >> 8) & 0xff; + int blue = pixel & 0xff; + + // if there is any alpha just leave the color as it is + + if (alpha == 0) { + return rgb; + } else { + // lighten + if (red + green + blue > 96*3) + { + /* + red = Math.min((int)(red *(1/(FACTOR))), 255); + green = Math.min((int)(green*(1/FACTOR)), 255); + blue = Math.min((int)(blue*(1/FACTOR)), 255); + */ + + red = Math.min(red + 32,255); + green = Math.min(green + 32,255); + blue = Math.min(blue + 32,255); + + } else { // darken + /* + red = Math.min((int)(red*FACTOR), 255); + green = Math.min((int)(green*FACTOR), 255); + blue = Math.min((int)(blue*FACTOR), 255); + */ + + red = red/2; + green = green/2; + blue = blue/2; + } + + rgb = ((red & 0xFF) << 16) | ((green & 0xFF) << 8) | ((blue & 0xFF) << 0); + return 0xff000000 | rgb; + } + } + + private static final double FACTOR = 0.7; + +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/ImageView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/ImageView.java new file mode 100644 index 00000000000..d7ff878501c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/ImageView.java @@ -0,0 +1,150 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget; + +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import netscape.application.*; + +public class ImageView extends View implements Shapeable +{ + public final static int ALIGN_LEFT = 0; + public final static int ALIGN_RIGHT = 1; + + public final static int ALIGN_TOP = 0; + public final static int ALIGN_BOTTOM = 1; + + public final static int ALIGN_CENTER = 2; + public final static int ALIGN_SCALED = 3; + + public ImageView() + { + this(null); + } + + public ImageView(Image image) + { + setImage(image); + } + + public void setImage(Image image) + { + _image = image; + calculateMinSize(); + } + + private void calculateMinSize() + { + int width = 0; + int height = 0; + + if (_image != null) + { + if (halign != ALIGN_SCALED) + width = _image.width(); + + if (valign != ALIGN_SCALED) + height = _image.height(); + } + + setMinSize(width, height); + } + + public Image getImage() + { + return _image; + } + + public void drawView(Graphics g) + { + if (_image != null) { + + int x = 0; + int y = 0; + int width = _image.width(); + int height = _image.height(); + switch (halign) + { + case ALIGN_CENTER: + x = width()/2-_image.width()/2; + break; + case ALIGN_LEFT: + x = 0; + break; + case ALIGN_RIGHT: + x = bounds.width - _image.width(); + break; + case ALIGN_SCALED: + x = 0; + width = bounds.width; + break; + + } + + switch (valign) + { + case ALIGN_CENTER: + y = height()/2-_image.height()/2; + break; + case ALIGN_TOP: + y = 0; + break; + case ALIGN_BOTTOM: + y = bounds.height - _image.height(); + break; + case ALIGN_SCALED: + y = 0; + height = bounds.height; + break; + } + + _image.drawScaled(g,x,y,width,height); + } + } + + public Size preferredSize() + { + if (_image != null) + return new Size(_image.width(), _image.height()); + else + return minSize(); + } + + public Size maxSize() + { + return new Size(9999,9999); + } + + public void setVerticalAlignment(int align) + { + valign = align; + calculateMinSize(); + } + + public void setHorizontalAlignment(int align) + { + halign = align; + calculateMinSize(); + } + + private Image _image; + private int valign = ALIGN_CENTER; + private int halign = ALIGN_CENTER; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/PopupButton.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/PopupButton.java new file mode 100644 index 00000000000..32c356c588f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/PopupButton.java @@ -0,0 +1,367 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.palomar.widget; + +import netscape.application.*; +import netscape.util.*; +import java.awt.image.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; + +/** + * A special button that pops up when the mouse is moved over it. + */ + +public class PopupButton extends ShapeableView +{ + + /** + * Create a tool with a target and images + * @param name The name of the button + * @param note the note that appears when the mouse moves over the button + * @param target the target to be called when this tool is clicked + * @param command the string command to be called when this tool is clicked + * @param image the image that appears when the mouse is not over the button + * @param altImage the image that appers when the mouse is over the button + */ + public PopupButton(String label, Target clickTarget, String command, Bitmap image, Bitmap altImage) + { + // set the targets + _target = clickTarget; + _command = command; + if (image != null && altImage == null) + altImage = getHighlitedImageFor(image); + + if (_raisedBorder == null) + _raisedBorder = BezelBorder.raisedBezel(); + + if (_loweredBorder == null) + _loweredBorder = BezelBorder.loweredBezel(); + + setLayoutManager(new MarginLayout()); + + _borderView = new BorderView(_raisedBorder); + _borderView.setHideBorder(true); + + _vbox = new BoxView(BoxView.VERT); + + _imageView = new ImageView(); + _labelView = new StringView(); + + _vbox.addFixedView(_imageView); + _vbox.addSpring(0); + _vbox.addFixedView(_labelView); + _bottomSpring = _vbox.addStrut(0); + _borderView.addSubview(_vbox); + addSubview(_borderView); + + setImage(image); + setAlternateImage(altImage); + setLabel(label); + } + + public void setImage(Bitmap image) + { + _image = image; + _imageView.setImage(image); + if (_image == null) + _bottomSpring.setSpringConstant(1); + else + _bottomSpring.setSpringConstant(0); + + } + + public void setAlternateImage(Bitmap image) + { + _altImage = image; + } + + public void showLabel(boolean show) + { + if (_showLabel != show) + { + _showLabel = show; + if (_showLabel) + _labelView.setLabel(_label); + else + _labelView.setLabel(null); + + _vbox.resize(); + } + } + + public void setLabel(String label) + { + _label = label; + if (_showLabel) { + _labelView.setLabel(label); + _vbox.resize(); + } + } + + public void setCommand(String command) + { + _command = command; + } + + public void setTarget(Target target) + { + _target = target; + } + + public boolean mouseDown(MouseEvent event) + { + if (_enabled == false) + return true; + + _pressed = true; + _inside = true; + + _borderView.setBorder(_loweredBorder); + + draw(); + return true; + } + + public void mouseUp(MouseEvent event) + { + _pressed = false; + + Rect r = bounds(); + boolean mouseInside = r.contains(r.x + event.x, r.y + event.y); + + if (mouseInside && _enabled) + { + if( _canToggle ) + _checked = ! _checked; + if (_target != null) + _target.performCommand(_command, this); + } + + if( _canToggle && _checked ) + _borderView.setBorder(_loweredBorder); + else + _borderView.setBorder(_raisedBorder); + + draw(); + _inside = false; + } + + public void mouseDragged(MouseEvent event) + { + Rect r = bounds(); + + boolean mouseInside = r.contains(r.x + event.x, r.y + event.y); + + if (_pressed == true) + if (_inside == true && mouseInside == false) + { + _inside = false; + // draw(); + } else if (_inside == false && mouseInside == true) { + _inside = true; + // draw(); + } + } + + public void mouseEntered(MouseEvent event) + { + // if we are enabled then show our alternate image + if (_enabled == true) + { + // System.out.println("Entered"); + _highlighted = true; + _borderView.setHideBorder(false); + + _borderView.layoutView(0,0); + + if (_altImage != null) + _imageView.setImage(_altImage); + + draw(); + } + } + + public void mouseExited(MouseEvent event) + { + // if we are enabled then show our alternate image + if (_enabled == true) + { + // System.out.println("Exited"); + + _highlighted = false; + _imageView.setImage(_image); + } + + // hide border even if we are disabled (but not if checked) + if( ! _canToggle || ! _checked ) + _borderView.setHideBorder(true); + + draw(); + } + + public View viewForMouse(int x, int y) + { + if (containsPoint(x,y)) + return this; + + return null; + } + + public String getLabel() + { + return _label; + } + + public void setEnabled(boolean enabled) + { + _enabled = enabled; + + if (_enabled==false) { + if (_disabledImage == null && _image != null) + _disabledImage = getDisabledImageFor(_image); + + _imageView.setImage(_disabledImage); + _labelView.setColor(Color.gray); + + } else { + _imageView.setImage(_image); + _labelView.setColor(Color.black); + } + + _imageView.setDirty(true); + _labelView.setDirty(true); + setDirty(true); + } + + public boolean isEnabled() + { + return _enabled; + } + + + public void setChecked(boolean checked) + { + if( ! _canToggle ) + return; + if( _checked == checked ) + return; + + _checked = checked; + + if (_checked==false) { + _borderView.setBorder(_raisedBorder); + _borderView.setHideBorder(true); + } else { + _borderView.setBorder(_loweredBorder); + _borderView.setHideBorder(false); + } + + _imageView.setDirty(true); + _labelView.setDirty(true); + setDirty(true); + } + + public boolean isChecked() + { + return _checked; + } + + public boolean canToggle() + { + return _canToggle; + } + + public void setCanToggle(boolean b) + { + _canToggle = b; + } + + public void drawView(Graphics g) + { + if (isTransparent() == false) { + g.setColor(Color.lightGray); + g.fillRect(0,0,width(),height()); + } + + super.drawView(g); + } + + /** + * Given a bitmap returns a grayscale equivalent. + */ + public static Bitmap getDisabledImageFor(Bitmap image) + { + // create a grayscale image filter + GrayScaleImageFilter filter = new GrayScaleImageFilter(); + + // get the image's producer + ImageProducer producer = AWTCompatibility.awtImageProducerForBitmap(image); + + // create a filtered source that filters the producer through the grayscale image filter + FilteredImageSource source = new FilteredImageSource(producer, filter); + + // create a bitmap that uses our new filtered producer + return AWTCompatibility.bitmapForAWTImageProducer(source); + } + + /** + * Given a bitmap returns a grayscale equivalent. + */ + public static Bitmap getHighlitedImageFor(Bitmap image) + { + // create a grayscale image filter + HighlightingImageFilter filter = new HighlightingImageFilter(); + + // get the image's producer + ImageProducer producer = AWTCompatibility.awtImageProducerForBitmap(image); + + // create a filtered source that filters the producer through the grayscale image filter + FilteredImageSource source = new FilteredImageSource(producer, filter); + + // create a bitmap that uses our new filtered producer + return AWTCompatibility.bitmapForAWTImageProducer(source); + } + + + private ImageView _imageView = null; + private StringView _labelView = null; + private Bitmap _altImage = null; + private Bitmap _image = null; + private Bitmap _disabledImage = null; + private boolean _highlighted = false; + private boolean _pressed = false; + private boolean _enabled = true; + private String _label = ""; + private Target _target = null; + private String _command = null; + private boolean _inside = false; + private BorderView _borderView; + private BoxView _vbox; + private MarginLayout _margin; + private Spring _bottomSpring; + private boolean _showLabel = true; + + private boolean _canToggle = false; + private boolean _checked = false; + + private static Border _raisedBorder = null; + private static Border _loweredBorder = null; + private static int _borderPad = 4; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/SeparatorView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/SeparatorView.java new file mode 100644 index 00000000000..44d37f9cc1c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/SeparatorView.java @@ -0,0 +1,52 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.palomar.widget; + +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; + +public class SeparatorView extends ShapeableView +{ + public void drawView(Graphics g) + { + g.setColor(Color.gray); + g.drawLine(0,0,bounds.width,0); + g.setColor(Color.white); + g.drawLine(0,1,bounds.width,1); + } + + public Size preferredSize() + { + return _maxSize; + } + + public Size maxSize() + { + return _maxSize; + } + + public Size minSize() + { + return _minSize; + } + + private Size _maxSize = new Size(9999,2); + private Size _minSize = new Size(2,2); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/StringView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/StringView.java new file mode 100644 index 00000000000..79c587a47a6 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/StringView.java @@ -0,0 +1,115 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.palomar.widget; + +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import netscape.application.*; + +public class StringView extends View implements Shapeable +{ + + public StringView() + { + this(null); + } + + public StringView(String label) + { + _font = Font.defaultFont(); + _metrics = _font.fontMetrics(); + _color = Color.black; + _label = label; + calculateSize(); + } + + public void setColor(Color color) + { + _color = color; + } + + public void setFont(Font font) + { + _font = font; + _metrics = font.fontMetrics(); + calculateSize(); + } + + public void setLabel(String label) + { + _label = label; + + calculateSize(); + } + + public String getLabel() + { + return _label; + } + + public Font getFont() + { + return _font; + } + + public FontMetrics getFontMetrics() + { + return _metrics; + } + + public Color getColor() + { + return _color; + } + + protected void calculateSize() + { + if (_label != null) + { + Size size = _metrics.stringSize(_label); + setMinSize(size.width,size.height); + } else { + setMinSize(0,0); //_metrics.charHeight()); + } + } + + public void drawView(Graphics g) + { + if (_label != null) + { + g.setFont(_font); + g.setColor(_color); + g.drawStringInRect(_label, 0,0,width(),height(),Graphics.CENTERED); + } + } + + public Size preferredSize() + { + return minSize(); + } + + public Size maxSize() + { + return new Size(Integer.MAX_VALUE, Integer.MAX_VALUE); + } + + private Font _font; + private FontMetrics _metrics; + private String _label; + private Color _color; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/BoxSpringLayout.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/BoxSpringLayout.java new file mode 100644 index 00000000000..1b03e6ffa84 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/BoxSpringLayout.java @@ -0,0 +1,559 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout; +import netscape.application.*; +import netscape.util.*; + +public class BoxSpringLayout implements ShapeableLayoutManager +{ + public static final int VERTICAL = 0; + public static final int HORIZONTAL = 1; + public static int INFINITE = Integer.MAX_VALUE; + + /** + * Creates a box given the direction of the box, either + * VERT or HORIZ + */ + public BoxSpringLayout(int direction) + { + _direction = direction; + } + + /** + * sets the size in pixels of the margin around this layout + */ + public void setMargin(int margin) + { + _margin = margin; + } + + /** + * sets space in pixels placed between each child view. + * By default it is 0. + */ + public void setChildPadding(int padding) + { + _childPadding = padding; + } + + + /** + * returns the margin in pixels that appears around this layout. + * default is 0. + */ + public int getMargin() + { + return _margin; + } + + /** + * Adds a spring to the view. + * @param size The initial size of the spring in pixels. + * The min size of the spring whatever the views min size it. + * The max size will be infinite + * the spring contant will be 1. + */ + public void addSpring(Spring spring) + { + _springs.addElement(spring); + } + + /** + * insert a spring to the view. + * @param size The initial size of the spring in pixels. + * The min size of the spring whatever the views min size it. + * The max size will be infinite + * the spring contant will be 1. + */ + public void insertSpring(Spring spring, int index) + { + _springs.insertElementAt(spring,index); + } + + /* + * returns an enumeration of Spring objects + */ + public Enumeration springs() + { + return _springs.elements(); + } + + /** + * Removes the spring, or strut, that is at the specified index. + * @param index the index of the view, spring, or strut in this box. + */ + public Spring removeSpringAt(int index) + { + return (Spring)_springs.removeElementAt(index); + } + + public Spring getSpringAt(int index) + { + return (Spring)_springs.elementAt(index); + } + + public void setSpringAt(int index, Spring spring) + { + _springs.setElementAt(spring, index); + } + + public int count() + { + return _springs.size(); + } + + /** + * Returns the direction this box displays itself. + * VERTICAL or HORIZONTAL + */ + public int getDirection() + { + return _direction; + } + + public void setDirection(int direction) + { + _direction = direction; + } + + public void addSubview(View view) + { + } + + public void removeSubview(View view) + { + } + + /** + * Lays out all of view's children according to the springs that have been added + * to this layout manager. For example spring[0] should be attached to child[0] of view + * spring[1] should be attached to child[1]. + */ + public void layoutView(View mainView, + int deltaWidth, + int deltaHeight) + { + Vector children = mainView.subviews(); + int views = children.size(); + int springs = _springs.size(); + + // get the width and height of the view + int width = mainView.width()-_margin*2; + int height = mainView.height()-_margin*2; + + // if there is padding between cells subtract it + if (_direction == HORIZONTAL) + width -= _childPadding*(views-1); + else + height -= _childPadding*(views-1); + + // apply our springs to the views subviews and + // populate the SpringView with the values so it + // can do the calculations. + for (int i=0; i < views && i < springs;i++) + { + // get the spring + Spring spring = (Spring)_springs.elementAt(i); + + // get the view + View view = (View)children.elementAt(i); + + // get our values for this child + Size preferredSize = getPreferredSizeFor (view,spring); + Size minSize = getMinSizeFor (view,spring); + Size maxSize = getMaxSizeFor (view,spring); + float springConstant = spring.springConstant(); + + // add the spring to the spring vector + + com.netscape.jsdebugging.ifcui.palomar.widget.layout.math.Spring vspring = null; + + if (_direction == HORIZONTAL) + { + vspring = new com.netscape.jsdebugging.ifcui.palomar.widget.layout.math.Spring(preferredSize.width, + (float)springConstant, + minSize.width, + maxSize.width); + } else { + vspring = new com.netscape.jsdebugging.ifcui.palomar.widget.layout.math.Spring(preferredSize.height, + (float)springConstant, + minSize.height, + maxSize.height); + } + + _springVector.addElement(vspring); + + } + + // alright lets stretch the vector to the size of the view + if (_direction == HORIZONTAL) + _springVector.stretch(width); + else + _springVector.stretch(height); + + int offset = _margin; + + // layout all of the subview according to what the spring vector + // tells us + for (int i=0; i < views && i < springs;i++) + { + // get the view + View view = (View)children.elementAt(i); + + com.netscape.jsdebugging.ifcui.palomar.widget.layout.math.Spring vspring = (com.netscape.jsdebugging.ifcui.palomar.widget.layout.math.Spring)_springVector.elementAt(i); + + if (_direction == HORIZONTAL) + { + view.setBounds(offset,_margin, vspring._currentSize,height); + offset += vspring._currentSize+_childPadding; + } else { + view.setBounds(_margin,offset, width,vspring._currentSize); + offset += vspring._currentSize + _childPadding; + } + } + + _springVector.removeAllElements(); + + } + + private Size getMinSizeFor(View view, Spring spring) + { + Size size = view.minSize(); + + // what is its minimum size? + // ask the view, then apply the springs value + if (_direction == HORIZONTAL) + { + if (spring.isMinSizeSet) + size.width = spring.minSize(); + } else { + if (spring.isMinSizeSet) + size.height = spring.minSize(); + } + + return size; + } + + private Size getPreferredSizeFor(View view, Spring spring) + { + Size size = null; + + // if the view is shapeable its easy just ask the + // the shapeable for its prefered size. Otherwise + // its prefered size is it min size. + if (view instanceof Shapeable) + size = ((Shapeable)view).preferredSize(); + else + size = view.minSize(); + + + // apply the spring to the preferred size + if (_direction == HORIZONTAL) + { + if (spring.isPreferredSizeSet) + size.width = spring.preferredSize(); + } else { + if (spring.isPreferredSizeSet) + size.height = spring.preferredSize(); + } + + return size; + } + + private Size getMaxSizeFor(View view, Spring spring) + { + Size size = null; + + // if the view is shapeable its easy just ask the + // the shapeable for its max size. + if (view instanceof Shapeable) + size = ((Shapeable)view).maxSize(); + else + size = new Size(INFINITE, INFINITE); + + // apply the spring to the max size + if (_direction == HORIZONTAL) + { + if (spring.isMaxSizeSet) + size.width = spring.maxSize(); + } else { + if (spring.isMaxSizeSet) + size.height = spring.maxSize(); + } + + return size; + } + + /** + * Returns the desired size of the given view according to this + * layout manager. + */ + public Size preferredSize(View mainView) + { + // should return the desired size of the view by looking at its children, + // and putting them on springs. + + // if the direction is HORIZONTAL then dimention1 is the sum of all of our + // children's widths and dimention2 is the largest height. + + // if the direction is VERTICAL then dimention2 is the sum of all of our + // children's heights and dimention2 is the largest width. + + int dimention1 = 0; + int dimention2 = 0; + + Vector children = mainView.subviews(); + int views = children.size(); + int springs = _springs.size(); + + for (int i=0; i < views && i < springs;i++) + { + // get the spring + Spring spring = (Spring)_springs.elementAt(i); + + // get the view + View view = (View)children.elementAt(i); + + // get our child's size + Size preferredSize = getPreferredSizeFor(view,spring); + + // calculate dimention1 and dimention2 + int dimention = 0; + if (_direction == HORIZONTAL) + { + dimention1 += preferredSize.width; + dimention = preferredSize.height; + } else { + dimention1 += preferredSize.height; + dimention = preferredSize.width; + } + + // dimention2 should equal the biggest child + if (dimention > dimention2) + dimention2 = dimention; + } + + // add in the cell padding + dimention1 += _childPadding*(views-1); + + // add in the margin + dimention1 += _margin; + dimention2 += _margin; + + // depending on the direction set the dimentions right + if (_direction == HORIZONTAL) + return new Size(dimention1,dimention2); + else + return new Size(dimention2,dimention1); + } + + /** + * Returns the minimum size of the given view according to this + * layout manager. + */ + public Size minSize(View mainView) + { + // should return the desired size of the view by looking at its children, + // and putting them on springs. + + // if the direction is HORIZONTAL then dimention1 is the sum of all of our + // children's widths and dimention2 is the largest height. + + // if the direction is VERTICAL then dimention2 is the sum of all of our + // children's heights and dimention2 is the largest width. + + int dimention1 = 0; + int dimention2 = 0; + + Vector children = mainView.subviews(); + int views = children.size(); + int springs = _springs.size(); + + for (int i=0; i < views && i < springs;i++) + { + // get the spring + Spring spring = (Spring)_springs.elementAt(i); + + // get the view + View view = (View)children.elementAt(i); + + Size minSize = getMinSizeFor(view,spring); + + // calculate dimention1 and dimention2 + int dimention = 0; + if (_direction == HORIZONTAL) + { + if (spring.springConstant() == 0.0) { + // if the spring is 0.0 meaning is can't be stretched + // then the min and max sizes become the same as the preferred + // size. We only handle min size here so let do it. + + Size preferredSize = getPreferredSizeFor(view,spring); + dimention1 += preferredSize.width; + } else { + dimention1 += minSize.width; + } + + dimention = minSize.height; + } else { + if (spring.springConstant() == 0.0) { + // if the spring is 0.0 meaning is can't be stretched + // then the min and max sizes become the same as the preferred + // size. We only handle min size here so let do it. + + Size preferredSize = getPreferredSizeFor(view,spring); + dimention1 += preferredSize.height; + } else { + dimention1 += minSize.height; + } + + dimention = minSize.width; + } + + // dimention2 should equal the biggest child + if (dimention > dimention2) + dimention2 = dimention; + } + + // add in the cell padding + dimention1 += _childPadding*(views-1); + + // add in the margin + dimention1 += _margin; + dimention2 += _margin; + + // depending on the direction set the dimentions right + if (_direction == HORIZONTAL) + return new Size(dimention1,dimention2); + else + return new Size(dimention2,dimention1); + } + + /** + * Returns the maximum size of the given view according to this + * layout manager. + */ + public Size maxSize(View mainView) + { + // should return the desired size of the view by looking at its children, + // and putting them on springs. + + // if the direction is HORIZONTAL then dimention1 is the sum of all of our + // children's widths and dimention2 is the largest height. + + // if the direction is VERTICAL then dimention2 is the sum of all of our + // children's heights and dimention2 is the largest width. + + int dimention1 = 0; + int dimention2 = 0; + + Vector children = mainView.subviews(); + int views = children.size(); + int springs = _springs.size(); + + for (int i=0; i < views && i < springs;i++) + { + // get the spring + Spring spring = (Spring)_springs.elementAt(i); + + // get the view + View view = (View)children.elementAt(i); + + // get our child's size + Size maxSize = getMaxSizeFor(view,spring); + + // calculate dimention1 and dimention2 + int dimention = 0; + if (_direction == HORIZONTAL) + { + if (dimention1 != Integer.MAX_VALUE) + { + int size = maxSize.width; + if (spring.springConstant() == 0.0) + { + // if the spring is 0.0 meaning is can't be stretched + // then the min and max sizes become the same as the preferred + // size. We only handle min size here so let do it. + + Size preferredSize = getPreferredSizeFor(view,spring); + size = preferredSize.width; + } + + if (size != Integer.MAX_VALUE) + dimention1 += size; + else + dimention1 = Integer.MAX_VALUE; + } + + dimention = maxSize.height; + } else { + if (dimention1 != Integer.MAX_VALUE) + { + int size = maxSize.height; + if (spring.springConstant() == 0.0) + { + // if the spring is 0.0 meaning is can't be stretched + // then the min and max sizes become the same as the preferred + // size. We only handle min size here so let do it. + + Size preferredSize = getPreferredSizeFor(view,spring); + size = preferredSize.height; + } + + if (size != Integer.MAX_VALUE) + dimention1 += size; + else + dimention1 = Integer.MAX_VALUE; + } + + dimention = maxSize.width; + } + + // dimention2 should equal the biggest child + if (dimention > dimention2) + dimention2 = dimention; + } + + // add in the cell padding + if (dimention1 < Integer.MAX_VALUE) + { + dimention1 += _childPadding*(views-1); + dimention2 += _margin; + } + + // add in the margin + if (dimention2 < Integer.MAX_VALUE) + dimention2 += _margin; + + // depending on the direction set the dimentions right + if (_direction == HORIZONTAL) + return new Size(dimention1,dimention2); + else + return new Size(dimention2,dimention1); + + } + + private Vector _springs = new Vector(); + private int _direction = HORIZONTAL; + private com.netscape.jsdebugging.ifcui.palomar.widget.layout.math.SpringVector _springVector = new com.netscape.jsdebugging.ifcui.palomar.widget.layout.math.SpringVector(); + private int _margin = 0; + private int _childPadding = 0; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/BoxView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/BoxView.java new file mode 100644 index 00000000000..25fb18355c9 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/BoxView.java @@ -0,0 +1,853 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout; +import netscape.application.*; +import netscape.util.*; + +public class BoxView extends ShapeableView +{ + public static final int VERT = 0; + public static final int HORIZ = 1; + + /** + * Creates a box given the direction of the box, either + * VERT or HORIZ + */ + public BoxView(int direction) + { + setLayoutManager(new BoxSpringLayout(direction)); + setAutoResizeSubviews(true); + } + + public void setShowBoxesAndSprings(boolean show) + { + BoxSpringLayout layout = getBoxSpringLayoutManager(); + + // add some margin so we can fit the box in + if (show == true && _showBoxesAndSprings == false) + layout.setMargin(layout.getMargin()+2); + + // remove the margin + if (show == false && _showBoxesAndSprings == true) + layout.setMargin(layout.getMargin()-2); + + resize(); + + _showBoxesAndSprings = show; + + // ask search our children for other boxes + // and set them as well + setShowBoxesAndSprings(this,show); + } + + public boolean getShowBoxesAndSprings() + { + return _showBoxesAndSprings; + } + + private void setShowBoxesAndSprings(View view, boolean show) + { + Vector children = view.subviews(); + int size = children.size(); + for (int i=0;i < size; i++) + { + View child = (View)children.elementAt(i); + if (child instanceof BoxView) + ((BoxView)child).setShowBoxesAndSprings(show); + else if (child instanceof SpringView) + ((SpringView)child).setShowSpring(show); + else + setShowBoxesAndSprings(child,show); + } + } + + + /** + * Adds a view to the box and forces it to be fixed at its preferred size. + * If the view implements the Shapeable interface then its preferred size and + * min size will be retrieved from it. If its just a normal + * view its preferred size will its current width and its max size will be infinite. + * @param view The view to add to the box. + */ + public Spring addFixedView(View view) + { + // create a spring that won't stetch + Spring spring = new Spring(); + spring.setSpringConstant(STRUT_CONSTANT); + addView(view, spring); + return spring; + } + + /** + * Adds a view to the box will a given preferred size and forces it to be flexable. + * If the view implements the Shapeable interface then its + * max size will be retrieved from it and its preferred size will + * be overridden by the given preferred size. If its just a normal + * view its max size will be infinite. + * @param view The view to add to the box. + * @param preferredSize The initial preferred size of the view in pixels. + */ + public Spring addFixedView(View view, int preferredSize) + { + Spring spring = new Spring(); + spring.setPreferredSize(preferredSize); + spring.setSpringConstant(STRUT_CONSTANT); + addView(view, spring); + return spring; + } + + /** + * Adds a view to the box and forces it to be flexable. + * If the view implements the Shapeable interface then its preferred size, + * and max size will be retrieved from it it. If its just a normal + * view its preferred size will be its current width and max size + * will be infinite. + * @param view The view to add to the box. + */ + public Spring addFlexibleView(View view) + { + // create a spring that won't stetch + Spring spring = new Spring(); + spring.setSpringConstant((float)1.0); + addView(view, spring); + return spring; + } + + /** + * Adds a view to the box with a initial preferred size and forces it to be flexable. + * If the view implements the Shapeable interface then its + * max size will be retrieved from it and its preferred size will + * be overridden by the given preferred size. If its just a normal + * view its max size will be infinite. + * @param view The view to add to the box. + */ + public Spring addFlexibleView(View view, int preferredSize) + { + Spring spring = new Spring(); + spring.setPreferredSize(preferredSize); + spring.setSpringConstant((float)1.0); + addView(view, spring); + return spring; + } + + + /** + * Adds a view to the box and forces it to be flexible. + * Its preferred size, min size, and max size will + * be overridden with the sizes given. + * @param view The view to add to the box. + * @param preferredSize The initial size of the view in pixels. + * @param minSize The minimum size of the view in pixels. + * @param maxSize The maximum size of the view in pixels. + */ + public Spring addFlexibleView(View view, int preferredSize, int minSize, int maxSize) + { + Spring spring = new Spring(); + spring.setPreferredSize(preferredSize); + spring.setMinSize(minSize); + spring.setMaxSize(maxSize); + spring.setSpringConstant((float)1.0); + addView(view, spring); + return spring; + } + + + /** + * Adds a view to the box. And uses the given Spring object to determine + * its properties. + * @param view The view to add to the box. + * @param spring The spring to use when laying out this view. + */ + public Spring addView(View view, Spring spring) + { + // if the view is not a shapeable and we haven't set its + // preferred size then set its preferred size to be whatever + // its current size is. + if (view instanceof Shapeable == false && spring.isPreferredSizeSet == false) + { + int min = 0; + int current = 0; + + if (getDirection() == HORIZ) { + min = view.minSize().width; + current = view.width(); + } else { + min = view.minSize().height; + current = view.height(); + } + } + + getBoxSpringLayoutManager().addSpring(spring); + addSubview(view); + resize(); + + // if the view is a SpringView then tell it about the + // spring so it can draw the spring correctly + if (view instanceof SpringView) + ((SpringView)view).setSpring(spring); + + return spring; + } + + /** + * Adds a view to the box. Its preferred size, min size, and max size + * and springConstant will be overridden with the sizes given. + * @param view The view to add to the box. + * @param preferredSize The initial size of the view in pixels. + * @param minSize The minimum size of the view in pixels. + * @param maxSize The maximum size of the view in pixels. + * @param springConstant a number between 1.0 and 0.0 + * springConstant is the constant used to layout the view where 1.0 is + * the most flexable and 0.0 is fixed and won't stretch + */ + public Spring addView(View view, int preferredSize, int minSize, int maxSize, float springConstant) + { + Spring spring = new Spring(); + spring.setPreferredSize(preferredSize); + spring.setMinSize(minSize); + spring.setMaxSize(maxSize); + spring.setSpringConstant(springConstant); + addView(view, spring); + return spring; + } + + /** + * Inserts a view into the box and forces it to be fixed at its preferred size. + * If the view implements the Shapeable interface then its preferred size, + * and max size will be retrieved from it. If its just a normal + * view its preferred size will be its current size and its max size will be infinite. + * @param index the index to insert the view at. + * @param view The view to add to the box. + */ + public Spring insertFixedView(int index, View view) + { + // create a spring that won't stetch + Spring spring = new Spring(); + spring.setSpringConstant(STRUT_CONSTANT); + insertView(index, view, spring); + return spring; + } + + /** + * Inserts a view into the box at the specified location with the given preferred size + * and forces it to be flexable. + * @param index the index to insert the view at. + * @param view The view to add to the box. + * @param preferredSize The initial size of the view in pixels. + */ + public Spring insertFixedView(int index, View view, int preferredSize) + { + Spring spring = new Spring(); + spring.setPreferredSize(preferredSize); + spring.setSpringConstant(STRUT_CONSTANT); + insertView(index, view, spring); + return spring; + } + + /** + * Inserts a view into the box and forces it to be flexable. + * If the view implements the Shapeable interface then its preferred size + * and max size will be retrieved from it. If its just a normal + * view its preferred size will be its current size and its max size + * will be infinite. + * @param index the index to insert the view at. + * @param view The view to add to the box. + */ + public Spring insertFlexibleView(int index, View view) + { + // create a spring that won't stetch + Spring spring = new Spring(); + spring.setSpringConstant((float)1.0); + insertView(index, view, spring); + return spring; + } + + /** + * Inserts a view into the box and forces it to be flexible. Its prefered will be + * overridden by the given preferred size. + * If the view implements the Shapeable interface then its + * max size will be retrieved from it. If its just a normal + * view its max size will be infinite. + * @param index the index to insert the view at. + * @param view The view to add to the box. + * @param preferredSize The initial size of the view in pixels. + */ + public Spring insertFlexibleView(int index, View view, int preferredSize) + { + Spring spring = new Spring(); + spring.setPreferredSize(preferredSize); + spring.setSpringConstant((float)1.0); + insertView(index, view, spring); + return spring; + } + + + /** + * Inserts a view into the box. Its preferred size, min size, and max size will + * be overridden with the sizes given. + * @param index the index to insert the view at. + * @param view The view to add to the box. + * @param preferredSize The initial size of the view in pixels. + * @param minSize The minimum size of the view in pixels. + * @param maxSize The maximum size of the view in pixels. + */ + public Spring insertFlexibleView(int index, View view, int preferredSize, int minSize, int maxSize) + { + Spring spring = new Spring(); + spring.setPreferredSize(preferredSize); + spring.setMinSize(minSize); + spring.setMaxSize(maxSize); + spring.setSpringConstant((float)1.0); + insertView(index, view, spring); + return spring; + } + + /** + * Inserts a view to the box. And uses the given Spring object to determine + * its properties. + * @param index the index to insert the view at + * @param view The view to add to the box. + * @param spring The spring to use when laying out this view. + */ + public Spring insertView(int index, View view, Spring spring) + { + if (index < 0 || index > subviews().size()) + return null; + + Vector children = subviews(); + + if (index == children.size()) + return addView(view,spring); + + // if the view is not a shapeable and we haven't set its + // preferred size then set its preferred size to be whatever + // its current size is. + if (view instanceof Shapeable == false && spring.isPreferredSizeSet == false) + { + int min = 0; + int current = 0; + + if (getDirection() == HORIZ) { + min = view.minSize().width; + current = view.width(); + } else { + min = view.minSize().height; + current = view.height(); + } + } + + getBoxSpringLayoutManager().insertSpring(spring,index); + + // add the view into the view system then move it to + // the correct location. + addSubview(view); + children.insertElementAt(view,index); + children.removeElementAt(children.size()-1); + + // if the view is a SpringView then tell it about the + // spring so it can draw the spring correctly + if (view instanceof SpringView) + ((SpringView)view).setSpring(spring); + + resize(); + + return spring; + } + + /** + * Adds a view to the box. Its preferred size, min size, and max size + * and springConstant will be overridden with the sizes given. + * @param view The view to add to the box. + * @param preferredSize The initial size of the view in pixels. + * @param minSize The minimum size of the view in pixels. + * @param maxSize The maximum size of the view in pixels. + * @param springConstant a number between 1.0 and 0.0 + * springConstant is the constant used to layout the view where 1.0 is + * the most flexable and 0.0 is fixed and won't stretch + */ + public Spring insertView(int index, View view, int preferredSize, int minSize, int maxSize, float springConstant) + { + Spring spring = new Spring(); + spring.setPreferredSize(preferredSize); + spring.setMinSize(minSize); + spring.setMaxSize(maxSize); + spring.setSpringConstant(springConstant); + insertView(index, view, spring); + return spring; + } + + + /** + * Adds a spring to the view. This is essentually the same as + * addView(new View()) except the View added knows how + * to draw a spring when showBoxesAndSprings is set to true. + * @param spring the spring to use + */ + public Spring addSpring(Spring spring) + { + return addView(new SpringView(getDirection(),_showBoxesAndSprings), spring); + } + + /** + * Adds a spring to the view. This is essentually the same as + * addFlexibleView(new View(),preferredSize) except the View added knows how + * to draw a spring when showBoxesAndSprings is set to true. + * If you have several views and want one to just eat up space add one + * of these to it. + * @param preferredSize the initial size of the spring + */ + public Spring addSpring(int preferredSize) + { + return addFlexibleView(new SpringView(getDirection(),_showBoxesAndSprings), preferredSize, 0, Integer.MAX_VALUE); + } + + /** + * Adds a spring to the view. This is essentually the same as + * addFlexibleView(new View(),preferredSize) except the View added knows how + * to draw a spring when showBoxesAndSprings is set to true. + * If you have several views and want one to just eat up space add one + * of these to it. + */ + public Spring addSpring() + { + return addFlexibleView(new SpringView(getDirection(),_showBoxesAndSprings), 0, 0, Integer.MAX_VALUE); + } + + /** + * Adds a spring to the view. This is essentually the same as + * addFlexibleView(new View(),preferredSize) except the View added knows how + * to draw a spring when showBoxesAndSprings is set to true. + * If you have several views and want one to just eat up space add one + * of these to it. + * @param springConstant the spring constant for this spring between 0.0 and 1.0 + */ + public Spring addSpring(float springConstant) + { + return addView(new SpringView(getDirection(),_showBoxesAndSprings), 0, 0, Integer.MAX_VALUE, springConstant); + } + + /** + * Adds a spring to the view. This is essentually the same as + * addFlexibleView(new View(),preferredSize) except the View added knows how + * to draw a spring when showBoxesAndSprings is set to true. + * If you have several views and want one to just eat up space add one + * of these to it. + * @param preferredSize the initial size of the spring + * @param springConstant the spring constant for this spring between 0.0 and 1.0 + */ + public Spring addSpring(int preferredSize, float springConstant) + { + return addView(new SpringView(getDirection(),_showBoxesAndSprings), preferredSize, 0, Integer.MAX_VALUE, springConstant); + } + + + /** + * Adds a spring to the view. This is essentually the same as + * addFlexibleView(new View(),preferredSize,minSize,maxSize) + * except the View added knows how + * to draw a spring when showBoxesAndSprings is set to true. + * If you have several views and want one to just eat up space add one + * of these to it. + * @param preferredSize The initial size of the spring in pixels. + * @param minSize The minimum size of the spring in pixels. + * @param maxSize The maximum size of the spring in pixels. + */ + public Spring addSpring(int preferredSize, int minSize, int maxSize) + { + return addFlexibleView(new SpringView(getDirection(),_showBoxesAndSprings), preferredSize, minSize, maxSize); + } + + /** + * Adds a strut to the view. A Strut is really just a simple case + * of a spring whos springConstant is 0 making it not stretchable. + * Struts also know how to draw a "Strut" when showBoxesAndSprings is set to true. + * Use these to place fixed padding between views. + * @param preferredSize The initial size of the spring in pixels. + */ + public Spring addStrut(int preferredSize) + { + return addFixedView(new SpringView(getDirection(),_showBoxesAndSprings),preferredSize); + } + + /** + * Removes the view, spring, or strut, that is at the specified index. + * @param index the index of the view, spring, or strut in this box. + */ + public Spring removeElementAt(int index) + { + View view = (View)subviews().elementAt(index); + Spring spring = getBoxSpringLayoutManager().removeSpringAt(index); + removeSubview(view); + return spring; + } + + /** + * Removes the view, spring, or strut. + * @param index the index of the view, spring, or strut in this box. + */ + public Spring removeView(View view) + { + int index = indexOfView(view); + if (index == -1) + return null; + + Spring spring = getBoxSpringLayoutManager().removeSpringAt(index); + removeSubview(view); + resize(); + + return spring; + } + + public int indexOfView(View view) + { + return subviews().indexOf(view); + } + + /** + * Sets the view to be displayed at the given index. If the index is that of + * a Spring or Strut the view will replace it but it will keep the spring's or + * strut's properties. + * @param index the index of the view, spring, or strut in this box. + * @param view the view to replace with the old on with + * + * Returns the old view. + * + */ + public View setView(int index, View view) + { + Vector children = subviews(); + + if (index < 0 || index >=children.size()) + return null; + + // get the old view + + View oldView = (View)children.elementAt(index); + + // if its the same as the new one then we are done + if (oldView == view) + return oldView; + + // remove the old one--this method recommended by Kloba, 3/30/97, and it fixes + // the non-redrawing TextView bug in Palomar Connection Builder - sgrennan + if (oldView != null) + oldView.removeFromSuperview(); + + // add the new one + addSubview(view); + + // move the new one to where the old one was + children.insertElementAt(view,index); + children.removeElementAt(children.size()-1); + + if (view instanceof SpringView) + ((SpringView)view).setSpring(getBoxSpringLayoutManager().getSpringAt(index)); + + resize(); + + return oldView; + } + + public void removeAll() + { + Vector children = subviews(); + + while(children.size() > 0) + removeElementAt(0); + + } + + /** + * Replaces the spring used to layout the view at index with + * a new one. + */ + public void setSpringAt(int index, Spring spring) + { + // set the spring one the layout manager + getBoxSpringLayoutManager().setSpringAt(index, spring); + + // if the view is a SpringView lets tell the + // spring view about it so it can display the + // spring correctly + View view = (View)subviews().elementAt(index); + + if (view instanceof SpringView) + ((SpringView)view).setSpring(spring); + + resize(); + + } + + /** + * Returns the View that is displayed at the given index. If it is a + * Spring or Strut it will return the emply view used to display it. + * @param index the index of the view, spring, or strut in this box. + */ + public View getViewAt(int index) + { + return (View)subviews().elementAt(index); + } + + /** + * Returns the element at the given index. This is the spring object that + * controls the shape of the view at the given index. + * @param index the index of the view, spring, or strut in this box. + */ + public Spring getElementAt(int index) + { + return getBoxSpringLayoutManager().getSpringAt(index); + } + + /** + * Returns the direction this box displays itself. + * VERT or HORIZ + */ + public int getDirection() + { + return getBoxSpringLayoutManager().getDirection(); + } + + /** + * Sets the direct this box lays out its views VERT or HORIZ + */ + public void setDirection(int direction) + { + // set the layouts direction + getBoxSpringLayoutManager().setDirection(direction); + + // if we have and SpringViews flip there direction + // so they draw correctly. + Vector children = subviews(); + int size = children.size(); + + for (int i = 0; i < size; i++) + { + View view = (View)children.elementAt(i); + if (view instanceof SpringView) + ((SpringView)view).setDirection(direction); + } + + resize(); + + } + + /** + * Returns all the views in he box + */ + public Enumeration views() + { + return subviews().elements(); + } + + public Enumeration springs() + { + return getBoxSpringLayoutManager().springs(); + } + + /** + * Returns the number of views in the box + */ + public int count() + { + return subviews().size(); + } + + public void drawSubviews(Graphics g) + { + super.drawSubviews(g); + + int arrowHeadSize = 4; + int halfArrowHeadSize = arrowHeadSize/2; + + if (_showBoxesAndSprings) + { + if (getDirection() == HORIZ) + g.setColor(Color.blue); + else + g.setColor(Color.red); + + g.drawRect(1,1,width()-2,height()-2); + } + } + + public Size minSize() + { + if (_minSize == null) + _minSize = super.minSize(); + + return _minSize; + } + + public Size preferredSize() + { + if (_preferredSize == null) + _preferredSize = super.preferredSize(); + + return _preferredSize; + } + + public Size maxSize() + { + if (_maxSize == null) + _maxSize = super.maxSize(); + + return _maxSize; + } + + /** + * Tells the the box to reevaluate its size the next time its + * asked for it or its is layed out + */ + public void resize() + { + _minSize = null; + _maxSize = null; + _preferredSize = null; + } + + /** + * Returns the BoxSpringLayout used by us. + * Is now public so I can set the childpadding, etc... + */ + public BoxSpringLayout getBoxSpringLayoutManager() + { + return (BoxSpringLayout)layoutManager(); + } + + public static float STRUT_CONSTANT = (float)0.0; + private boolean _showBoxesAndSprings = false; + private Size _minSize = null; + private Size _maxSize = null; + private Size _preferredSize = null; +} + +/** + * Helper class to draw springs and struts when showBoxesAndSprings is true + */ +class SpringView extends View +{ + public static final int VERT = 0; + public static final int HORIZ = 1; + + public SpringView(int direction, boolean showSpring) + { + _showSpring = showSpring; + _direction = direction; + } + + public void setShowSpring(boolean show) + { + _showSpring = show; + setDirty(true); + } + + public void setDirection(int direction) + { + _direction = direction; + } + + public int getDirection() + { + return _direction; + } + + public void setSpring(Spring spring) + { + _spring = spring; + } + + public Spring getSpring() + { + return _spring; + } + + public void drawView(Graphics g) + { + // see if we need to show the springs + if (_showSpring == false) + return; + + if (_spring.springConstant() <= BoxView.STRUT_CONSTANT) + drawStrut(g); + else + drawSpring(g); + } + + public void drawStrut(Graphics g) + { + if (_direction == HORIZ) + { + g.setColor(Color.black); + g.drawLine(0, height()/2+1, width(), height()/2+1); + g.setColor(Color.white); + g.drawLine(0, height()/2, width(), height()/2); + } else { + g.setColor(Color.black); + g.drawLine(width()/2+1, 0, width()/2+1, height() ); + g.setColor(Color.white); + g.drawLine(width()/2, 0, width()/2, height()); + } + } + + public void drawSpring(Graphics g) + { + // if we do draw the coils + int distance = 0; + int center = 0; + + if (_direction == HORIZ) + { + distance = width(); + center = height()/2; + } else { + distance = height(); + center = width()/2; + } + + int coilSize = 8; + int coils = distance/coilSize; + + int halfCoilSize = coilSize/2; + int offset = 0; + + for (int i=0; i < coils+1; i++) + { + if (_direction == HORIZ) + { + g.setColor(Color.black); + g.drawLine(offset, center+2, offset+halfCoilSize, center-2); + g.setColor(Color.white); + g.drawLine(offset+halfCoilSize, center-2, offset+coilSize, center+2); + } else { + g.setColor(Color.black); + g.drawLine(center+2, offset, center-2, offset+halfCoilSize); + g.setColor(Color.white); + g.drawLine(center-2, offset+halfCoilSize, center+2, offset+coilSize); + } + + offset += coilSize; + } + } + + private int _direction = HORIZ; + private Spring _spring; + private boolean _showSpring = false; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/MarginLayout.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/MarginLayout.java new file mode 100644 index 00000000000..1784a93001f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/MarginLayout.java @@ -0,0 +1,190 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout; + +import netscape.application.*; +import netscape.util.*; + +/** + * This layout manager is designed to layout a single subview, placing + * left, right, top, and bottom margins around it. It also understands + * Shapeable Views. These are views that implement the Shapeable interface + * allowing them to be querried for preferredSize and maxSize in additon + * to minSize. + */ +public class MarginLayout implements ShapeableLayoutManager +{ + + public MarginLayout() + { + _left = 0; + _right = 0; + _top = 0; + _bottom = 0; + } + + public MarginLayout(int left, int right, int top, int bottom) + { + _left = left; + _right = right; + _top = top; + _bottom = bottom; + } + + public void setLeftMargin(int left) + { + _left = left; + } + + public void setRightMargin(int right) + { + _right = right; + } + + public void setTopMargin(int top) + { + _top = top; + } + + public void setBottomMargin(int bottom) + { + _bottom = bottom; + } + + public int getLeftMargin() + { + return _left; + } + + public int getRightMargin() + { + return _right; + } + + public int getTopMargin() + { + return _top; + } + + public int getBottomMargin() + { + return _bottom; + } + + + + /** + * return the minimum size required to layout the view + */ + private Size sizeFor(View aView, int type) + { + Size size = new Size(); + + Vector views = aView.subviews(); + if (views.size() > 0) + { + View view = (View)views.firstElement(); + + Size vsize = null; + + switch (type) + { + case MIN_SIZE: + vsize = view.minSize(); + break; + + case PREFERRED_SIZE: + if (view instanceof Shapeable) + vsize = ((Shapeable)view).preferredSize(); + else + vsize = view.minSize(); + break; + + case MAX_SIZE: + if (view instanceof Shapeable) + vsize = ((Shapeable)view).maxSize(); + else + return new Size(Integer.MAX_VALUE, Integer.MAX_VALUE); + break; + } + + if (vsize != null) + { + size.width = vsize.width; + size.height = vsize.height; + } + } + + if (size.width != Integer.MAX_VALUE) + size.width += _left+_right; + + if (size.height != Integer.MAX_VALUE) + size.height += _top+_bottom; + + return size; + } + + public Size minSize(View aView) + { + return sizeFor(aView, MIN_SIZE); + } + + public Size maxSize(View aView) + { + return sizeFor(aView, MAX_SIZE); + } + + public Size preferredSize(View aView) + { + return sizeFor(aView, PREFERRED_SIZE); + } + + public void addSubview(View aView) + { + } + + public void removeSubview(View aView) + { + } + + public void layoutView(View aView, + int deltaWidth, + int deltaHeight) + { + Vector views = aView.subviews(); + if (views.size() > 0) + { + View view = (View)views.firstElement(); + + int width = aView.width(); + int height = aView.height(); + view.setBounds(_left,_top,width - _left - _right, height - _top - _bottom); + } + } + + protected int _left = 0; + protected int _right = 0; + protected int _top = 0; + protected int _bottom = 0; + private static final int MIN_SIZE = 0; + private static final int PREFERRED_SIZE = 1; + private static final int MAX_SIZE = 2; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/MarginView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/MarginView.java new file mode 100644 index 00000000000..88a3d218bed --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/MarginView.java @@ -0,0 +1,88 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout; +import netscape.application.*; + +/** + * A convience class that places a margin around its subview. + */ +public class MarginView extends ShapeableView +{ + public MarginView() + { + this(0,0,0,0); + } + + public MarginView(int left, int right, int top, int bottom) + { + setLayoutManager(new MarginLayout(left,right,top,bottom)); + setAutoResizeSubviews(true); + } + + public void setLeftMargin(int size) + { + ((MarginLayout)layoutManager()).setLeftMargin(size); + } + + public void setRightMargin(int size) + { + ((MarginLayout)layoutManager()).setRightMargin(size); + } + + public void setTopMargin(int size) + { + ((MarginLayout)layoutManager()).setTopMargin(size); + } + + public void setBottomMargin(int size) + { + ((MarginLayout)layoutManager()).setBottomMargin(size); + } + + public int getLeftMargin() + { + return ((MarginLayout)layoutManager()).getLeftMargin(); + } + + public int getRightMargin() + { + return ((MarginLayout)layoutManager()).getRightMargin(); + } + + public int getTopMargin() + { + return ((MarginLayout)layoutManager()).getTopMargin(); + } + + public int getBottomMargin() + { + return ((MarginLayout)layoutManager()).getBottomMargin(); + } + + + /* + protected MarginLayout getMarginLayoutManager() + { + return (MarginLayout)layoutManager(); + } + */ +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/Shapeable.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/Shapeable.java new file mode 100644 index 00000000000..7fdfd338e20 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/Shapeable.java @@ -0,0 +1,29 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout; +import netscape.application.*; + +public interface Shapeable +{ + public Size preferredSize(); + public Size minSize(); + public Size maxSize(); +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/ShapeableLayoutManager.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/ShapeableLayoutManager.java new file mode 100644 index 00000000000..f8053dbf902 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/ShapeableLayoutManager.java @@ -0,0 +1,32 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout; + +import netscape.application.*; + +public interface ShapeableLayoutManager extends LayoutManager +{ + public Size preferredSize(View view); + public Size minSize(View view); + public Size maxSize(View view); +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/ShapeableView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/ShapeableView.java new file mode 100644 index 00000000000..1aab2ed01aa --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/ShapeableView.java @@ -0,0 +1,88 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout; + +import netscape.application.*; + +public class ShapeableView extends View implements Shapeable +{ + public Size preferredSize() + { + LayoutManager manager = layoutManager(); + if (manager != null) + { + if (manager instanceof ShapeableLayoutManager) + { + ShapeableLayoutManager smanager = (ShapeableLayoutManager)manager; + return smanager.preferredSize(this); + } + } + + return minSize(); + } + + public Size minSize() + { + LayoutManager manager = layoutManager(); + if (manager != null) + { + if (manager instanceof ShapeableLayoutManager) + { + ShapeableLayoutManager smanager = (ShapeableLayoutManager)manager; + return smanager.minSize(this); + } + } + + return super.minSize(); + } + + + public Size maxSize() + { + LayoutManager manager = layoutManager(); + if (manager != null) + { + if (manager instanceof ShapeableLayoutManager) + { + ShapeableLayoutManager smanager = (ShapeableLayoutManager)manager; + return smanager.maxSize(this); + } + } + + return new Size(Integer.MAX_VALUE, Integer.MAX_VALUE); + } + + /** + * If this view has a shapeable layout manager return it + * otherwise return null. + */ + public ShapeableLayoutManager getShapeableLayoutManager() + { + LayoutManager manager = layoutManager(); + if (manager != null) + { + if (manager instanceof ShapeableLayoutManager) + return (ShapeableLayoutManager)manager; + } + + return null; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/SplitterView.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/SplitterView.java new file mode 100644 index 00000000000..3ce0c57e6e5 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/SplitterView.java @@ -0,0 +1,326 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout; +import netscape.application.*; +import netscape.util.*; + +public class SplitterView extends BoxView +{ + /** + * Creates a splitter given the direction of the splitter, either + * VERT or HORIZ + */ + public SplitterView(int direction) + { + super(direction); + + // leave some spacing for the splitter controls + getBoxSpringLayoutManager().setChildPadding(SPLITTER_SIZE); + } + + public void drawSubviews(Graphics g) + { + super.drawSubviews(g); + + int direction = getDirection(); + + Vector views = subviews(); + int size = views.size(); + if (size < 2) + return; + + // draw the splitter controls + for (int i=0;i < views.size()-1; i++) + { + View child = (View)views.elementAt(i); + Rect bounds = child.bounds(); + + if (direction == HORIZ) { + g.setColor(Color.lightGray); + g.drawLine(bounds.x+bounds.width,bounds.y,bounds.x+bounds.width,bounds.height); + g.setColor(Color.white); + g.drawLine(bounds.x+bounds.width+1,bounds.y,bounds.x+bounds.width+1,bounds.height); + g.setColor(Color.lightGray); + g.drawLine(bounds.x+bounds.width+2,bounds.y,bounds.x+bounds.width+2,bounds.height); + g.setColor(Color.gray); + g.drawLine(bounds.x+bounds.width+3,bounds.y,bounds.x+bounds.width+3,bounds.height); + g.setColor(Color.darkGray); + g.drawLine(bounds.x+bounds.width+4,bounds.y,bounds.x+bounds.width+4,bounds.height); + + } else { + g.setColor(Color.lightGray); + g.drawLine(bounds.x, bounds.y+bounds.height,bounds.width,bounds.y+bounds.height); + g.setColor(Color.white); + g.drawLine(bounds.x, bounds.y+bounds.height+1,bounds.width,bounds.y+bounds.height+1); + g.setColor(Color.lightGray); + g.drawLine(bounds.x, bounds.y+bounds.height+2,bounds.width,bounds.y+bounds.height+2); + g.setColor(Color.gray); + g.drawLine(bounds.x, bounds.y+bounds.height+3,bounds.width,bounds.y+bounds.height+3); + g.setColor(Color.darkGray); + g.drawLine(bounds.x, bounds.y+bounds.height+4,bounds.width,bounds.y+bounds.height+4); + } + } + } + + public int cursorForPoint(int x, + int y) + { + // change the cursor so the user knows he/she can + // change the size + if (getDirection() == HORIZ) + return E_RESIZE_CURSOR; + else + return N_RESIZE_CURSOR; + } + + public void mouseDragged(MouseEvent event) + { + + if (_dragSpringLeft == null) + return; + + int delta = 0; + + // figure out how much to move the splitter + if (getDirection() == HORIZ) + delta = event.x - _dragAnchor.x; + else + delta = event.y - _dragAnchor.y; + + //System.out.println("delta="+delta); + + // change the splitters size if we can + + + // get the sizes of views to resize + int leftMinSize = getMinSizeFor(_dragViewLeft, _dragSpringLeft); + int leftMaxSize = getMaxSizeFor(_dragViewLeft, _dragSpringLeft); + int leftWidth = _dragWidthLeft+delta; + + int rightMinSize = getMinSizeFor(_dragViewRight, _dragSpringRight); + int rightMaxSize = getMaxSizeFor(_dragViewRight, _dragSpringRight); + int rightWidth = _dragWidthRight-delta; + + + // make sure we don't shink things too small or make them too large + if (leftWidth < leftMinSize) { + rightWidth -= (leftMinSize-leftWidth); + leftWidth = leftMinSize; + } else if (leftWidth > leftMaxSize) { + rightWidth -= (leftWidth-leftMaxSize); + leftWidth = leftMaxSize; + } + + if (rightWidth < rightMinSize) { + leftWidth -= (rightMinSize-rightWidth); + rightWidth = rightMinSize; + } else if (rightWidth > rightMaxSize) { + leftWidth -= (rightWidth-rightMaxSize); + rightWidth = rightMaxSize; + } + + //System.out.println("left minsize="+leftMinSize+"left width="+leftWidth); + //System.out.println("Right minsize="+rightMinSize+"right width="+rightWidth); + + _dragSpringLeft.setPreferredSize(leftWidth); + _dragSpringRight.setPreferredSize(rightWidth); + + + // relayout and draw + setDirty(true); + layoutView(0,0); + } + + public boolean mouseDown(MouseEvent event) + { + _dragAnchor = new Point(event.x, event.y); + //System.out.println("anchor set "+_dragAnchor); + + // figure out which splitter was moved + int direction = getDirection(); + + Vector views = subviews(); + int size = views.size(); + if (size < 2) + return true; + + // set the preferred size of every item to what its + // current bounds are. + for (int i=0;i < views.size(); i++) + { + View child = (View)views.elementAt(i); + Rect bounds = child.bounds(); + Spring spring = getElementAt(i); + + if (direction == HORIZ) + { + spring.setPreferredSize(bounds.width); + } else { + spring.setPreferredSize(bounds.height); + } + } + + // find the splitter that the mouse is over + for (int i=0;i < views.size(); i++) + { + View child = (View)views.elementAt(i); + Rect bounds = child.bounds(); + Spring spring = getElementAt(i); + + boolean found = false; + + if (direction == HORIZ) + { + found = (event.x >= bounds.x + bounds.width && event.x < bounds.x + bounds.width + SPLITTER_SIZE); + } else { + found = (event.y >= bounds.y + bounds.height && event.y < bounds.y + bounds.height + SPLITTER_SIZE); + } + + if (found) + { + // record all of the info we need to resize the + // splitter on the drag: + // 1) the views to the left and right of the splitter + // to resize + // 2) the springs used to layout the views to the + // left and right of the splitter + // 3) the initial widths of the views on the left and right of the + // splitter + + _indexDragged = i; + _dragSpringLeft = spring; + _dragWidthLeft = _dragSpringLeft.preferredSize(); + _dragViewLeft = child; + + _dragSpringRight = getElementAt(i+1); + _dragViewRight = (View)views.elementAt(i+1); + + if (direction == HORIZ) + _dragWidthRight = _dragViewRight.width(); + else + _dragWidthRight = _dragViewRight.height(); + + + break; + } + } + + layoutView(0,0); + setDirty(true); + + return true; + } + + public void mouseUp(MouseEvent event) + { + if (_dragAnchor != null && _sizedTarget != null) + _sizedTarget.performCommand(_sizedCommand,new Integer(_indexDragged)); + + _dragAnchor = null; + } + + private int getMinSizeFor(View view, Spring spring) + { + Size size = view.minSize(); + + // what is its minimum size? + // ask the view, then apply the springs value + if (getDirection() == HORIZ) + { + if (spring.isMinSizeSet) + size.width = spring.minSize(); + + return size.width; + + } else { + if (spring.isMinSizeSet) + size.height = spring.minSize(); + + return size.height; + } + } + + private int getMaxSizeFor(View view, Spring spring) + { + Size size = null; + + // if the view is shapeable its easy just ask the + // the shapeable for its max size. + if (view instanceof Shapeable) + size = ((Shapeable)view).maxSize(); + else + size = new Size(Integer.MAX_VALUE, Integer.MAX_VALUE); + + // apply the spring to the max size + if (getDirection() == HORIZ) + { + if (spring.isMaxSizeSet) + size.width = spring.maxSize(); + + return size.width; + + } else { + if (spring.isMaxSizeSet) + size.height = spring.maxSize(); + + return size.height; + } + } + + /** + * Target to be called when a Splitter is moved + * The object passed is a Integer containing the index + * of the splitter that was resized + */ + public void setSizedTarget(Target target) + { + _sizedTarget = target; + } + + public void setSizedCommnad(String command) + { + _sizedCommand = command; + } + + public Target getSizedTarget() + { + return _sizedTarget; + } + + public String getSizedCommand() + { + return _sizedCommand; + } + + private Point _dragAnchor = null; + private final static int SPLITTER_SIZE = 5; + private Spring _dragSpringLeft = null; + private int _dragWidthLeft = 0; + private Spring _dragSpringRight = null; + private int _dragWidthRight = 0; + private View _dragViewLeft = null; + private View _dragViewRight = null; + private Target _sizedTarget; + private String _sizedCommand = "sized"; + private int _indexDragged = 0; + +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/Spring.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/Spring.java new file mode 100644 index 00000000000..42ed20f98d3 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/Spring.java @@ -0,0 +1,82 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Eric D Vaughan + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout; + +public class Spring +{ + /** + * A constant that can be used when setting max sizes of springs that + * represents infinite + */ + public static final int INFINITE = Integer.MAX_VALUE; + + public void setPreferredSize(int preferredSize) + { + _preferredSize = preferredSize; + isPreferredSizeSet = true; + } + + public int preferredSize() + { + return _preferredSize; + } + + public void setMinSize(int minSize) + { + _minSize = minSize; + isMinSizeSet = true; + } + + public int minSize() + { + return _minSize; + } + + public void setMaxSize(int minSize) + { + _maxSize = minSize; + isMaxSizeSet = true; + } + + public int maxSize() + { + return _maxSize; + } + + public void setSpringConstant(float springConstant) + { + _springConstant = springConstant; + } + + public float springConstant() + { + return _springConstant; + } + + protected int _preferredSize = 0; + protected int _maxSize = 0; + protected int _minSize = 0; + protected float _springConstant = 0; + + public boolean isPreferredSizeSet = false; + public boolean isMinSizeSet = false; + public boolean isMaxSizeSet = false; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/math/Spring.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/math/Spring.java new file mode 100644 index 00000000000..00a57478734 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/math/Spring.java @@ -0,0 +1,53 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Don Tilman + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout.math; + +/** + * The length is the natural, unstressed length of the Spring. + * 0 by default. + * + * The springConstant is in distance/force. Thus a Spring with a + * springConstant of 0.0 is a strut; it doesn't move. + * The springConstant is 0.0 by default. + * + * currentLength is set by the SpringVector to the final value. + * + * Needless to say, if specified, minLength should be less than maxLength. + * (I don't bother to check, the results could be fun.) + * Interestingly enough, length doesn't necessarily have to be between + * minLength and maxLength. + **/ + public class Spring { + public int _size = 0; + public float _springConstant = (float) 0.0; + public int _minSize; + public int _maxSize; + public int _currentSize; + boolean _sizeValid = false; + + public Spring(int size, float springConstant, int minSize, int maxSize){ + _size = size; + _springConstant = springConstant; + _minSize = minSize; + _maxSize = maxSize; + } +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/math/SpringVector.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/math/SpringVector.java new file mode 100644 index 00000000000..cb8f06243ff --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/layout/math/SpringVector.java @@ -0,0 +1,93 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// By Don Tilman + +package com.netscape.jsdebugging.ifcui.palomar.widget.layout.math; + +import java.util.*; +import java.lang.Math; + +/** + * A Vector of zero or more springs. + * + * This class extends Vector so you can use all those methods directly + * on it. + * + **/ +public class SpringVector extends Vector { + /** + * Stretch the SpringVector to a new length. The _currentSize of each + * individual Spring will be set to the new value. + * + **/ + public void stretch (int size) { + int nSprings = size(); + // Set sizeRemaining, springConstantsRemaining, validSize's. + int sizeRemaining = size; + float springConstantsRemaining = (float) 0.0; + for (int i=0; i=thisSpring._maxSize) { + //System.out.println("MaxSize hit"); + //System.out.println(thisSpring._maxSize); + thisSpring._currentSize = thisSpring._maxSize; + springConstantsRemaining -= thisSpring._springConstant; + sizeRemaining -= thisSpring._minSize-thisSpring._size; + thisSpring._sizeValid = true; + limit = true; + } + } + } + } + // Okay, now the regular springs. + float stretchFactor = sizeRemaining/springConstantsRemaining; + for (int i=0; i 0) + { + if (oEvent instanceof MouseEvent) + { + MouseEvent oMouseEvent = (MouseEvent)oEvent; + + if (oMouseEvent.type() == MouseEvent.MOUSE_ENTERED) + mouseEntered(); + else if (oMouseEvent.type() == MouseEvent.MOUSE_MOVED) + mouseMoved(oMouseEvent.x, oMouseEvent.y); + else if (oMouseEvent.type() == MouseEvent.MOUSE_DRAGGED) + mouseDragged(oMouseEvent.x, oMouseEvent.y); + else if (oMouseEvent.type() == MouseEvent.MOUSE_EXITED) + mouseExited(); + else { + if (_showingTip == true) + hideTip(); + } + + } else if (oEvent instanceof KeyEvent) { + if (_showingTip == true) + hideTip(); + } + } + +// System.out.println(oEvent); + super.processEvent(oEvent); + } + + + + /** + * Set the font for the tip + */ + public void setTipFont(Font font) + { + _tipView.setFont(font); + } + + public Font getTipFont(Font font) + { + return _tipView.font(); + } + + /** + * How look it take before the tip appears. The default is 1000 ms + */ + public void setTipDelay(int ms) + { + _delay = ms; + if (_timer != null) + _timer.setDelay(_delay); + } + + public void setTipBackgroundColor(Color color) + { + _tipView.setBackgroundColor(color); + } + + public Color getTipBackgroundColor() + { + return _tipView.backgroundColor(); + } + + public void setTipColor(Color color) + { + _tipView.setTextColor(color); + } + + public Color getTipColor() + { + return _tipView.textColor(); + } + + + public int getDelay() + { + return _delay; + } + + /** + * Adds a view that is to have a tip appear when the mouse + * is moved over it. + */ + public void addTip(View oView, String sTip) + { + _tips.put(oView, sTip); + } + + /** + * Removes a view that is to have a tip appear when the mouse + * is moved over it. + */ + public void removeTip(View oView) + { + _tips.remove(oView); + } + + public void printToolTips() + { + System.out.println(_tips.size()+" tips:"); + Enumeration e = _tips.elements(); + while(e.hasMoreElements()) + { + String s = (String)e.nextElement(); + System.out.println(s); + } + } + + private void createToolTip() + { + _tipWindow = new InternalWindow(); + _tipWindow.setLayer(InternalWindow.POPUP_LAYER); + _tipWindow.setType(Window.BLANK_TYPE); + _tipView.setBackgroundColor(new Color(255,255,231)); + _tipView.setBorder(LineBorder.blackLine()); + _tipWindow.contentView().addSubview(_tipView); + } + + /** + * Called when the manager is to be started. This is when the mouse first + * moves into the tool tip managers window. + */ + public void mouseEntered() + { + //System.out.println("Entered"); + startTimer(); + } + + /** + * Called whenever the mouse moves + */ + public void mouseMoved(int x, int y) + { + if (x != _x || y != _y) + { + //System.out.println("Moving: "+ new Point(x,y)); + // if the tip is showing hide it + if (_showingTip == true) + hideTip(); + + _x = x; + _y = y; + + startTimer(); + } + } + + /** + * Called whenever the mouse moves + */ + public void mouseDragged(int x, int y) + { + if (_showingTip == true) + hideTip(); + + stopTimer(); + } + + + /** + * Called when the mouse leaves the ToolTip manager window + */ + public void mouseExited() + { + //System.out.println("Exited"); + + // if the tip is showing then hide it + if (_showingTip == true) + hideTip(); + + // stop the timer if it is ready to go + stopTimer(); + } + + private void startTimer() + { + //System.out.println("Timer started"); + if (_timer == null) { + _timer = new Timer(new ToolTipTarget(this), "show tip", _delay); + _timer.setRepeats(false); + } + _timer.start(); + } + + private void stopTimer() + { + if (_timer != null) + _timer.stop(); + } + + public String getTipForMouse(int x, int y) + { + String tip = null; + + Vector windows = internalWindows(); + int size = windows.size(); + Point p = new Point(); + + for (int i=size-1; i >= 0; i--) + { + InternalWindow nextWindow = (InternalWindow)windows.elementAt(i); + //System.out.println(nextWindow); + convertToView(nextWindow, x,y, p); + if (nextWindow.containsPoint(p.x , p.y)) + { + //System.out.println("inside "+nextWindow); + return getTipFromSubviews(nextWindow, x,y); + } + } + + if (tip == null) + tip = getTipFromSubviews(this,x,y); + + return tip; + } + + /** + * Given a view and a mouse location find the deepest view with a tip + * and return it. + */ + private String getTipFromSubviews(View oTopView, int x, int y) + { + //System.out.println("looking at: " + oTopView); + // is the point inside the View? + if (oTopView.bounds().contains(x,y) == false) + return null; + + x -= oTopView.x(); + y -= oTopView.y(); + + String sTip = null; + + // get the the views subviews. Iterate through them, recursively + // calling ourselves until we find the deepest subview. + Vector oViews = oTopView.subviews(); + + if (oViews != null) + { + int length = oViews.size(); + + for (int i = length - 1; i >= 0; i--) + { + View oChild = (View)oViews.elementAt(i); + + // we already looked through the internal windows + // don't do them again + if (oChild instanceof InternalWindow) + continue; + + //Point p = oTopView.convertToView(oChild,x,y); + sTip = getTipFromSubviews(oChild, x,y); + if (sTip != null) + return sTip; + } + } + + // looks like none of our children have tips. So see if we have + // a tip. If we do return it. + sTip = (String)_tips.get(oTopView); + if (sTip != null) + return sTip; + + return null; + } + + /** + * Shows the tip as a bubble under the mouse + */ + public void showTip() + { + //System.out.println("Showing tip"); + + // stop the timer + _timer.stop(); + + // get the deepest tip + String sTip = getTipForMouse(_x, _y); + + // if we get one then display it + if (sTip != null) { + // Only show the tip if it is not empty. + // Empty tips can be used by a child view to + // prevent its parent's tip from bieng shown when + // the mouse is inside it. + if (sTip.equals("")) + return; + + if (_tipWindow == null) + createToolTip(); + + + + _tipView.setStringValue(sTip); + + Size s = _tipView.minSize(); + _tipView.sizeTo(s.width, s.height); + s =_tipWindow.windowSizeForContentSize(s.width, + s.height); + _tipWindow.sizeTo(s.width,s.height); + + + // make sure it isn't off the right side + if (_x+s.width > rootView().width()) + _x -= (_x+s.width) - rootView().width(); + + // place the tip under the pointer. If there is no space + // place it at the top. + int ydiff = 0; + if (_y+s.height > rootView().height()) + ydiff = -20; + else + ydiff = 20; + + _tipWindow.moveTo(_x, _y + ydiff); + _tipWindow.show(); + _showingTip = true; + } + } + + public void hideTip() + { + _tipWindow.hide(); + _showingTip = false; + } + + private Timer _timer; + private int _delay = 1000; + private Hashtable _tips = new Hashtable(); + private int _x = 0; + private int _y = 0; + private TextField _tipView = new TextField(); + private InternalWindow _tipWindow; + private boolean _showingTip = false; +} + +/** + * Class that receives timer messages and tells the Manager + * to pop up its tip. + */ +class ToolTipTarget implements Target +{ + public ToolTipTarget(ToolTipRootView oManager) + { + _manager = oManager; + } + + /** + * Called when it is time to display the tip + */ + public void performCommand(String command, Object data) + { + //System.out.println("Timer happened!"); + + if (command.equals("show tip")) + _manager.showTip(); + } + + private ToolTipRootView _manager; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/toolbar/Toolbar.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/toolbar/Toolbar.java new file mode 100644 index 00000000000..737970a26b1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/toolbar/Toolbar.java @@ -0,0 +1,323 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.palomar.widget.toolbar; + +import netscape.application.*; +import netscape.util.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.toolTip.*; + +/** A View that implements a toolbar + */ +public class Toolbar extends MarginView +{ + /** + * Create a tool bar. Make sure you call init before using. + */ + + public Toolbar() + { + // tool bar doesn't currently collapse to lets remove + // the collapsers. + // ImageView iv = new ImageView(Bitmap.bitmapNamed("ToolbarCollapser.gif")); + + BoxView innerBox = new BoxView(BoxView.VERT); + // innerBox.addFlexibleView(iv,0); + + _outerBox = new BoxView(BoxView.HORIZ); + _outerBox.addFixedView(innerBox); + _toolBox = new BoxView(BoxView.HORIZ); + _outerBox.addFlexibleView(_toolBox); + addSubview(_outerBox); + } + + /** + * Sets the image to be used as a tile background for this toolbar. + * First, checks to see if the specified file exists in the images directory. + * If not, then does nothing. + */ + public void setBackgroundImage(String name) + { + java.io.File bgImage = new java.io.File("images/" + name); + if ( bgImage.exists() ) { + _backgroundImage = Bitmap.bitmapNamed(name); + setDirty(true); + } + } + + /** + * Sets the image to be used as a tile background for this + * toobar + */ + public void setBackgroundColor(Color color) + { + _backgroundColor = color; + setDirty(true); + } + + public Color getBackgroundColor() + { + return _backgroundColor; + } + + public Image getBackgroundImage() + { + return _backgroundImage; + } + + /** + * Adds a tool to the tool bar. + * @param name The name of the button + * @param note the note that appears when the mouse moves over the button + */ + public PopupButton addButton(String name, String note) + { + return addButton(name, note, null, null); + } + + /** + * Adds a tool to the tool bar will the given target and command + * @param name The name of the tool + * @param note the not that appears when the mouse moves over the tool + * @param target the target to be called when this tool is clicked + * @param command the string command to be called when this tool is clicked + */ + public PopupButton addButton(String name, String note, Target target, String command) + { + return addButton(name, note, target, command, (Bitmap)null, (Bitmap)null); + } + + + /** + * Adds a tool to the tool bar with the given target and the file names + * of the 2 images. + * @param name The name of the button + * @param note the note that appears when the mouse moves over the tool + * @param target the target to be called when this tool is clicked + * @param command the string command to be called when this tool is clicked + * @param imageName the image that appears when the mouse is not over the tool + * @param altImageName the image that appers when the mouse is over the tool + */ + public PopupButton addButton(String name, String note, Target target, String command, String imageName, String altImageName) + { + Bitmap image = Bitmap.bitmapNamed(imageName); + Bitmap altImage = Bitmap.bitmapNamed(altImageName); + return addButton(name, note, target, command, image, altImage); + } + + public PopupButton addButton(String name, String note, Target target, String command, String imageName) + { + Bitmap image = Bitmap.bitmapNamed(imageName); + return addButton(name, note, target, command, image, null); + } + + /** + * Determinrs whether the name of the button appears underneath it + * or not. + */ + public void showLabels(boolean show) + { + if (_showLabels != show) + { + _showLabels = show; + Enumeration e = _toolBox.views(); + while(e.hasMoreElements()) + { + View view = (View)e.nextElement(); + if (view instanceof PopupButton) + { + PopupButton b = (PopupButton)view; + b.showLabel(_showLabels); + } + } + } + } + + /** + * Adds a tool to the tool bar with the target and the 2 images. + * @param name The name of the tool + * @param note the note that appears when the mouse moves over the tool + * @param target the target to be called when this tool is clicked + * @param command the string command to be called when this tool is clicked + * @param image the image that appears when the mouse is not over the tool + * @param altImage the image that appers when the mouse is over the tool + */ + public PopupButton addButton(String name, String note,Target target, String command, Bitmap image, Bitmap altImage) + { + // add a the list of tools. + PopupButton b = new PopupButton(name,target,command,image,altImage); + b.showLabel(_showLabels); + ToolTipRootView main = ToolTipRootView.mainToolTipRootView(); + if (main != null && note != null) + main.addTip(b,note); + + addButton(b); + return b; + } + + + /** Adds a tool to the tool bar. + * + * @param tool the tool to add + */ + public void addButton(PopupButton button) + { + _toolBox.addFixedView(button); + int maxSize = 0; + + Enumeration e = _toolBox.views(); + while(e.hasMoreElements()) + { + View view = (View)e.nextElement(); + if (view instanceof PopupButton) + { + PopupButton b = (PopupButton)view; + Size s = b.minSize(); + if (s.width > maxSize) + maxSize = s.width; + } + } + + int count = 0; + e = _toolBox.springs(); + while(e.hasMoreElements()) + { + Spring spring = (Spring)e.nextElement(); + spring.setPreferredSize(maxSize); + } + } + + public BoxView getToolBox() + { + return _toolBox; + } + + public void relayout() + { + _outerBox.resize(); + _toolBox.resize(); + layoutView(0,0); + } + + public void drawView(Graphics g) + { + //System.out.println("_backgroundColor="+_backgroundColor); + + if (_backgroundColor != null) + { + g.setColor(_backgroundColor); + g.fillRect(0,0,bounds.width,bounds.height); + + } + + if (_backgroundImage != null) + _backgroundImage.drawTiled(g,0,0,bounds.width,bounds.height); + + } + + protected void addTip(View view, String tip) + { + _records.addElement(new ToolbarRecord(view,tip)); + + RootView root = rootView(); + if (root != null && root instanceof ToolTipRootView) + { + ToolTipRootView toolTipRoot = (ToolTipRootView)root; + toolTipRoot.addTip(view, tip); + } + } + + protected void removeTip(View view) + { + // remove the record + int size = _records.size(); + + for (int i = 0; i < size; i++) + { + ToolbarRecord record = (ToolbarRecord)_records.elementAt(i); + if (record.view == view) { + _records.removeElementAt(i); + break; + } + } + + // if the root is a tool tip manager remove from it + RootView root = rootView(); + if (root != null && root instanceof ToolTipRootView) + { + ToolTipRootView toolTipRoot = (ToolTipRootView)root; + toolTipRoot.removeTip(view); + } + } + + protected void ancestorWasAddedToViewHierarchy(View addedView) + { + super.ancestorWasAddedToViewHierarchy(addedView); + RootView root = rootView(); + if (root != null && root instanceof ToolTipRootView) + { + ToolTipRootView toolTipRoot = (ToolTipRootView)root; + int size = _records.size(); + + for (int i = 0; i < size; i++) + { + ToolbarRecord record = (ToolbarRecord)_records.elementAt(i); + toolTipRoot.addTip(record.view, record.tip); + } + } + } + + protected void ancestorWillRemoveFromViewHierarchy(View removedView) + { + super.ancestorWillRemoveFromViewHierarchy(removedView); + RootView root = rootView(); + if (root != null && root instanceof ToolTipRootView) + { + ToolTipRootView toolTipRoot = (ToolTipRootView)root; + int size = _records.size(); + + for (int i = 0; i < size; i++) + { + ToolbarRecord record = (ToolbarRecord)_records.elementAt(i); + toolTipRoot.removeTip(record.view); + } + } + } + + + private Image _backgroundImage = null; + private Color _backgroundColor = Color.lightGray; + private BoxView _toolBox; + private BoxView _outerBox; + private Vector _records = new Vector(); + private boolean _showLabels = true; +} + +class ToolbarRecord +{ + ToolbarRecord(View v, String t) + { + view = v; + tip = t; + } + + View view; + String tip; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/toolbar/ToolbarTray.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/toolbar/ToolbarTray.java new file mode 100644 index 00000000000..8b6e8ec79e2 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/ifcui/palomar/widget/toolbar/ToolbarTray.java @@ -0,0 +1,122 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.ifcui.palomar.widget.toolbar; + +import com.netscape.jsdebugging.ifcui.palomar.widget.layout.*; +import com.netscape.jsdebugging.ifcui.palomar.widget.*; +import netscape.application.*; + +public class ToolbarTray extends ShapeableView +{ + public ToolbarTray() + { + setLayoutManager(new MarginLayout()); + _toolBox = new BoxView(BoxView.VERT); + addSubview(_toolBox); + } + + /** + * Sets the image to be used as a tile background for this toolbar. + * First, checks to see if the specified file exists in the images directory. + * If not, then does nothing. + */ + public void setBackgroundImage(String name) + { + java.io.File bgImage = new java.io.File("images/" + name); + if ( bgImage.exists() ) { + _backgroundImage = Bitmap.bitmapNamed(name); + setDirty(true); + } + } + + public void addToolbar(Toolbar toolbar) + { + // if the tray is empty add the initial separator + if (_toolBox.count() == 0) + _toolBox.addFixedView(new SeparatorView()); + + // add the toolbar + _toolBox.addFixedView(toolbar); + + // add the final separator + _toolBox.addFixedView(new SeparatorView()); + } + + public void removeToolbar(Toolbar toolbar) + { + int index = _toolBox.indexOfView(toolbar); + + if (index != -1) + { + // remove toolbar + _toolBox.removeElementAt(index); + + // remove separator + _toolBox.removeElementAt(index); + + // if all toolbars are gone remove the first separator + if (_toolBox.count() == 1) + _toolBox.removeElementAt(0); + } + + } + + public void drawView(Graphics g) + { + //System.out.println("_backgroundColor="+_backgroundColor); + + if (_backgroundColor != null) + { + g.setColor(_backgroundColor); + g.fillRect(0,0,bounds.width,bounds.height); + + } + + if (_backgroundImage != null) + _backgroundImage.drawTiled(g,0,0,bounds.width,bounds.height); + + } + + /** + * Sets the image to be used as a tile background for this + * toobar + */ + public void setBackgroundColor(Color color) + { + _backgroundColor = color; + setDirty(true); + } + + public Color getBackgroundColor() + { + return _backgroundColor; + } + + public Image getBackgroundImage() + { + return _backgroundImage; + } + + + + private BoxView _toolBox; + private Image _backgroundImage = null; + private Color _backgroundColor = Color.lightGray; + +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/Documentation.html b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/Documentation.html new file mode 100644 index 00000000000..e269646d85a --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/Documentation.html @@ -0,0 +1,207 @@ + + + + + + Documentation + + + +
+

+JSDB

+ +
 
+ +

+Overview

+JSDB is a command line debugger modeled after jdb. +
  +

+Supported Commands

+ +

+Normal State:

+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
load <filename> Load and run a javascript file.
suspendStop before first instruction is executed
stop at <filename> <line>Set a breakpoint. File doesn't have to be loaded yet.
clear at <filename> <line>Clear a breakpoint.
bpList breakpoints.
list <filename> <line>Print source code.
scriptsList loaded scripts.
quit, exitQuit jsdb.
+  +
  +

+Stopped State:

+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
resume, exit Resume execution.
stop at <filename> <line> Set a breakpoint.
clear at <filename> <line>Clear a breakpoint.
bpList breakpoints.
list [<filename> <line>] Print source code. If filename is not specified, prints the current +line in the current stackframe.
upMove up the stack.
downMove down the stack.
whereDump stack.
stepExecute current line.
eval <expr>Evaluate expression in current frame. print() function is supported, +so, for example, eval print(a) will print the value of variable +a.
+  +
  +
  +

+Example

+sample.js: +
______________________________________________________ +
a=1; +
for (i=0; i<10; i++){ +
    a = inc (inc(a)); +
} + +

c = a+2; + +

// Increment function +
function inc (b){ +
    return b+1; +
} +
______________________________________________________ + +

A sample JSDB session could be: + +

>stop at sample.js:6 +
Script not loaded. Breakpoint will be set once the script is loaded +
>load sample.js +
Set breakpoint at sample.js null 6 +
Stopped at 6 +
STOPPED >>list +
c = a+2; +
STOPPED >>eval print (a) +
21 +
STOPPED >>resume +
> +
  +
  +
  +
  +

+Notes

+ +
    +
  • +I didn't test JSDB much, so I'm sure that there are some bugs. If you find +one, or if you have a suggestion, please e-mail +me.
  • +
+  +

+Bugs and "features"

+ +
    +
  • +Important: JSDB crashes when executed with jits. Use -nojit +switch if you are using jre.exe.
  • +
+  +
  +
  +
  + +

Alex Rakhlin +
rakhlin@netscape.com + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBBreakpoint.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBBreakpoint.java new file mode 100644 index 00000000000..a24fb110d79 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBBreakpoint.java @@ -0,0 +1,69 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* JavaScript command line Debugger + * @author Alex Rakhlin + */ + +package com.netscape.jsdebugging.jsdb; + +class JSDBBreakpoint +{ + public JSDBBreakpoint(String url, int line){ + _url = url; + _line = line; + _enabled = true; + _hook = null; + } + + public void update (String url, int line){ + _url = url; + _line = line; + } + + public void setHook (JSDBInstructionHook h){ + _hook = h; + _enabled = true; + } + + public void clearHook (){ + System.out.println ("--- clearing hook --- "+_url+" "+_line); + _enabled = false; + } + + public JSDBInstructionHook getHook () { return _hook; } + public String getURL () { return _url; } + public int getLine() { return _line; } + public boolean isEnabled () { return _enabled; } + + + public boolean equalsTo (JSDBBreakpoint b){ + if (_url.equals (b.getURL()) && _line == b.getLine()) return true; + else return false; + } + + public String toString (){ + return _url + " " + _line; + } + + + private String _url; + private int _line; + private JSDBInstructionHook _hook; + private boolean _enabled; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBBreakpointsList.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBBreakpointsList.java new file mode 100644 index 00000000000..d485ede4bd6 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBBreakpointsList.java @@ -0,0 +1,184 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* JavaScript command line Debugger + * @author Alex Rakhlin + */ + +package com.netscape.jsdebugging.jsdb; + +import java.util.*; +import com.netscape.jsdebugging.api.*; + +class JSDBBreakpointsList +{ + + public JSDBBreakpointsList (JSDBScriptHook hook, DebugController controller){ + _list = new Vector(); + _scriptHook = hook; + _controller = controller; + } + + private void _addBreakpoint (String URL, int line){ + JSDBBreakpoint b = new JSDBBreakpoint (URL, line); + _addBreakpoint (b); + } + + private void _removeBreakpoint (String URL, int line){ + JSDBBreakpoint b = new JSDBBreakpoint (URL, line); + _removeBreakpoint (b); + } + + private void _addBreakpoint (JSDBBreakpoint b){ + _list.addElement (b); + } + + private void _removeBreakpoint (JSDBBreakpoint b){ + int count = _list.size(); + for (int i = 0; i= base && line <= base+extent) { + // if it's a function -- done + if (curr.getFunction()!=null) return curr; + else result = curr; + } + } + } + return result; + } + + public boolean equalScripts (Script s1, Script s2){ + // TODO : use script.equals() ?? + if (s1 == null || s2 == null) return false; + if (!s1.getURL().equals(s2.getURL())) return false; + if (s1.getFunction() == null && s2.getFunction() == null) return true; + if (s1.getFunction() == null || s2.getFunction() == null) return false; + if (s1.getFunction().equals(s2.getFunction())) return true; + return false; + } + + + public Vector getBreakpointsForScript (Script script){ + Vector vec = new Vector(); + int count = _list.size(); + for (int i=0; i>"); + try { + inputLine = in.readLine(); + } + catch (IOException e){ + //eat it... + } + + processLineSuspended (inputLine, state); + } + //--------------------- END ----------------- + } + + public void processLineSuspended (String line, JSThreadState state){ + StringTokenizer st = new StringTokenizer(line); + if (st.countTokens() == 0) return; + if (st.countTokens() == 1){ + String first = new String (st.nextToken()); + if (first.equals ("quit") || first.equals ("exit") || first.equals ("resume")) _resume = true; + else + if (first.equals ("where")) where(state); + else + if (first.equals ("help") || first.equals ("?")) help(); + else + if (first.equals ("step")) step(); + else + if (first.equals ("scripts")) listScripts(); + else + if (first.equals ("up")) upStack(state); + else + if (first.equals ("down")) downStack(state); + else + if (first.equals ("bp")) listBreakpoints(); + else + if (first.equals ("list")){ + try{ + StackFrameInfo[] stack = state.getStack(); + JSPC jspc = (JSPC)stack[_stackpos].getPC(); + printSource (jspc.getScript().getURL(), jspc.getSourceLocation().getLine()); + } + catch (InvalidInfoException e) {} + } + else System.out.println ("Invalid command"); + } + else + if (st.countTokens() >= 2){ + String first =new String (st.nextToken()); + String second = new String (st.nextToken()); + if (first.equals ("eval")) + System.out.println(eval (line.substring(5, line.length()), state)); + else + if (first.equals ("stop") && second.equals ("at")) stopAt (st); + else + if (first.equals ("clear") && second.equals ("at")) clearAt (st); + else + if (first.equals ("list")) list(st, second); + else System.out.println ("Invalid command"); + } + else System.out.println ("Invalid command"); + + } + + public void clearAt (StringTokenizer st){ + try { + String filename = new String (st.nextToken()); + String num = new String (st.nextToken()); + int val = Integer.valueOf (num).intValue (); + _breakpoints.clearBreakpointsAtLoc (filename, val); + } + catch (NoSuchElementException e){ + System.out.println ("Invalid number of parameters"); + } + catch (NumberFormatException e){ + System.out.println ("not a valid line number"); + } + } + + public void stopAt (StringTokenizer st){ + try { + String filename = new String (st.nextToken()); + String num = new String (st.nextToken()); + int val = Integer.valueOf (num).intValue (); + _breakpoints.createBreakpoint (filename, val); + } + catch (NoSuchElementException e){ + System.out.println ("Invalid number of parameters"); + } + catch (NumberFormatException e){ + System.out.println ("not a valid line number"); + } + } + + public void list (StringTokenizer st, String filename){ + try { + String num = new String (st.nextToken()); + int val = Integer.valueOf (num).intValue (); + printSource (filename, val); + } + catch (NoSuchElementException e){ + System.out.println ("Invalid number of parameters"); + } + catch (NumberFormatException e){ + System.out.println ("not a valid line number"); + } + } + + + public void listScripts (){ + JSDBScriptHook hook = (JSDBScriptHook)_controller.getScriptHook(); + Vector scripts = hook.getScripts(); + + int count = scripts.size(); + if (count == 0) { + System.out.println ("No scripts loaded"); + return; + } + + Script s; + for (int i = 0; i < count; i++){ + s = (Script) scripts.elementAt (i); + String file = s.getURL(); + String fun = s.getFunction (); + if (null == fun) fun = "_TOP_LEVEL_"; + System.out.println (file+"#"+fun); + } + } + + public void listBreakpoints(){ + _breakpoints.listBreakpoints(); + } + + public String eval (String str, JSThreadState state){ + ExecResult result; + result = _controller.executeScriptInStackFrame (_frame, str, "USER INPUT", 1); + if(! result.getErrorOccured()) + return result.getResult(); + return "[error] "+result.getErrorMessage(); + } + + public void printSource (String URL, int line){ + _stp.refreshAll(); + SourceTextItem item = _stp.findItem(URL); + if(null == item) { + System.out.println("failed to find item for "+URL); + return; + } + String s = item.getText(); + StringTokenizer tokenizer = new StringTokenizer (s, "\n"); + if (line>tokenizer.countTokens()) System.out.println ("Invalid line"); + else { + String tmp=""; + for (int i=0; i= 0 ; i--) + { + JSPC jspc = (JSPC)stack[i].getPC(); + int line = jspc.getSourceLocation().getLine(); + String file = jspc.getScript().getURL(); + String fun = jspc.getScript().getFunction(); + if( null == fun ) fun = "_TOP_LEVEL_"; + if (i == _stackpos) System.out.print ("*"); + else System.out.print (" "); + System.out.println (file+"#"+fun+"#"+line); + } + } + catch(Exception e) { + // eat it; + } + } + + + public void upStack(JSThreadState state){ + if (_stackpos == 0) System.out.println ("This IS the topmost frame."); + else { + _stackpos --; + try { + _frame = (JSStackFrameInfo)state.getStack()[_stackpos]; + } + catch (InvalidInfoException e){ + } + } + } + + public void downStack(JSThreadState state){ + if (_stackpos == _length_stack-1) System.out.println ("This IS the lowest frame"); + else { + _stackpos ++; + try { + _frame = (JSStackFrameInfo)state.getStack()[_stackpos]; + } + catch (InvalidInfoException e){ + } + } + } + + public boolean shouldStop (JSPC pc){ + if (_old_pc == null) return false; + if (!pc.getScript().equals(_old_pc.getScript())) return true; + if (pc.getSourceLocation().getLine() != _old_pc.getSourceLocation().getLine()) return true; + _old_pc = pc; + return false; + } + + + public void help(){ + System.out.println ("********************************** HELP **********************************"); + System.out.println ("resume, exit Resume execution."); + System.out.println ("stop at Set a breakpoint."); + System.out.println ("clear at Clear a breakpoint."); + System.out.println ("bp List breakpoints."); + System.out.println ("list [ ] Print source code. If filename is not specified"); + System.out.println (" prints the current line in the current stackframe."); + System.out.println ("up Move up the stack."); + System.out.println ("down Move down the stack."); + System.out.println ("where Dump stack."); + System.out.println ("step Execute current line. [stepping into]"); + System.out.println ("eval Evaluate expression in current frame and"); + System.out.println (" print the result."); + System.out.println ("**************************************************************************"); + } + + + public JSDBBreakpointsList getBreakpoints () { return _breakpoints; } + + private static boolean _resume; + private static DebugController _controller; + private static JSDBBreakpointsList _breakpoints; + private static JSStackFrameInfo _frame; + private static int _stackpos, _length_stack; + private static SourceTextProvider _stp; + private static JSPC _old_pc; + private static boolean _stepping; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBScriptHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBScriptHook.java new file mode 100644 index 00000000000..194e49b06b0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/JSDBScriptHook.java @@ -0,0 +1,58 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* JavaScript command line Debugger + * @author Alex Rakhlin + */ + +package com.netscape.jsdebugging.jsdb; + +import com.netscape.jsdebugging.api.*; +import java.util.*; + +class JSDBScriptHook + extends ScriptHook +{ + public JSDBScriptHook(DebugController controller) + { + _scripts = new Vector(); + _controller = controller; + } + + public void justLoadedScript(Script script) + { + //System.out.println("LOADED SCRIPT "+script.getURL()+" "+script.getFunction()); + _scripts.addElement (script); + ((JSDBInterruptHook)_controller.getInterruptHook()).getBreakpoints().setHooksForLoadedScript(script); + } + + public void aboutToUnloadScript(Script script) + { + //System.out.println("UNLOADED SCRIPT "+script.getURL()+" "+script.getFunction()); + _scripts.removeElement (script); + ((JSDBInterruptHook)_controller.getInterruptHook()).getBreakpoints().clearHooksForScript(script); + } + + public Vector getScripts () {return _scripts;} + + private Vector _scripts; + private DebugController _controller; + +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/Main.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/Main.java new file mode 100644 index 00000000000..5eaf784049c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/Main.java @@ -0,0 +1,211 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* JavaScript command line Debugger + * @author Alex Rakhlin + */ + +package com.netscape.jsdebugging.jsdb; + +import java.io.*; +import java.util.*; + +import com.netscape.jsdebugging.engine.*; +import com.netscape.jsdebugging.api.*; + +public class Main { + + public static void main(String args[]) { + new Main(args); + } + + private void showCreation(Object o, String name) { +// System.out.println(name+" "+(o==null?"NOT ":"")+"created"); + } + + public static final String LOCAL_CREATOR_NAME = + "com.netscape.jsdebugging.engine.local.RuntimeCreatorLocal"; + + public static final String RHINO_CREATOR_NAME = + "com.netscape.jsdebugging.engine.rhino.RuntimeCreatorRhino"; + + private void usage() { + System.out.println("jsdb"); + System.out.println(""); + System.out.println("usage java jsdb [local|rhino]"); + System.out.println(""); + } + + private Main(String[] args) { + String creatorName = null; + + if(args.length == 0) { + usage(); + return; + } + if(args[0].toLowerCase().equals("local")) + creatorName = LOCAL_CREATOR_NAME; + else if(args[0].toLowerCase().equals("rhino")) + creatorName = RHINO_CREATOR_NAME; + else { + usage(); + return; + } + + try { + Class clazz = Class.forName(creatorName); + + IRuntimeCreator creator = + (IRuntimeCreator) clazz.newInstance(); + + _runtime = creator.newRuntime(IRuntimeCreator.ENABLE_DEBUGGING, null); + showCreation(_runtime, "runtime"); + + _context = _runtime.newContext(null); + showCreation(_context, "context"); + + _controller = _runtime.getDebugController(); + showCreation(_controller, "controller"); + + _sourceTextProvider = _runtime.getSourceTextProvider(); + showCreation(_sourceTextProvider, "sourceTextProvider"); + + LocalSink sink = new LocalSink(); + _context.setPrintSink(sink); + _context.setErrorSink(sink); + + + _controller.setScriptHook(new JSDBScriptHook(_controller)); + _interruptHook = new JSDBInterruptHook(_controller, _sourceTextProvider); + _controller.setInterruptHook(_interruptHook); + _controller.setErrorReporter(new JSDBErrorReporter()); + } + catch(Throwable t) + { + System.out.println("execption thrown " + t ); + } + + //-------------------- LOOP ----------------- + DataInputStream in = new DataInputStream (System.in); + String inputLine=""; + while (!_quitting){ + System.out.print (">"); + try { + inputLine = in.readLine(); + } + catch (IOException e){ + //eat it... + } + + processLine (inputLine); + } + //--------------------- END ----------------- + } + + /** + * Print a help message. + * + */ + public void help() { + System.out.println ("********************************** HELP **********************************"); + System.out.println ("load Load and run a javascript file."); + System.out.println ("suspend Stop before first instruction is executed"); + System.out.println ("stop at Set a breakpoint. File doesn't have to be loaded"); + System.out.println ("clear at Clear a breakpoint."); + System.out.println ("bp List breakpoints."); + System.out.println ("list Print source code."); + System.out.println ("scripts List loaded scripts."); + System.out.println ("quit, exit Quit jsdb."); + System.out.println ("**************************************************************************"); + } + + // Quit the shell + public void quit() { + _quitting = true; + } + + public void processLine (String line){ + StringTokenizer st = new StringTokenizer(line); + if (st.countTokens() == 0) return; + if (st.countTokens() == 1){ + String first = st.nextToken(); + if (first.equals ("quit") || first.equals ("exit")) quit(); + else + if (first.equals ("help") || first.equals ("?")) help(); + else + if (first.equals ("suspend")) { + System.out.println ("Execution will be stopped at the first instruction"); + _controller.sendInterrupt(); + } + else + if (first.equals ("scripts")) { + _interruptHook.listScripts(); + } + else + if (first.equals ("bp")) { + _interruptHook.listBreakpoints(); + } + else System.out.println ("Invalid command"); + } + else + if (st.countTokens() >= 2){ + String first=st.nextToken(); + String second = st.nextToken(); + if (first.equals ("load")) _context.loadFile(second); + else + if (first.equals ("stop") && second.equals ("at")) _interruptHook.stopAt (st); + else + if (first.equals ("clear") && second.equals ("at")) _interruptHook.clearAt (st); + else + if (first.equals ("list")) _interruptHook.list(st, second); + else System.out.println ("Invalid command"); + } + + } + + public DebugController getController() {return _controller;} + public SourceTextProvider getSourceTextProvider() {return _sourceTextProvider;} + + private IRuntime _runtime; + private IContext _context; + private DebugController _controller; + private SourceTextProvider _sourceTextProvider; + + private boolean _quitting; + private JSDBInterruptHook _interruptHook; +} + +class LocalSink implements IPrintSink, IErrorSink +{ + public void print(String s) { + System.out.print(s); + } + public void error(String msg, String filename, int lineno, + String lineBuf, int offset) + { +// System.out.println(""); +// System.out.println("-------------------------------------"); +// System.out.println(msg); +// System.out.println(filename); +// System.out.println(lineno); +// System.out.println(lineBuf); +// System.out.println(offset); +// System.out.println("-------------------------------------"); +// System.out.println(""); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/sample.js b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/sample.js new file mode 100644 index 00000000000..5ecd9eb5df4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jsdb/sample.js @@ -0,0 +1,11 @@ +a=1; +for (i=0; i<10; i++){ + a = inc (inc(a)); +} + +c = a+2; + +// Increment function +function inc (b){ + return b+1; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/CallChain.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/CallChain.java new file mode 100644 index 00000000000..ae629d21f27 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/CallChain.java @@ -0,0 +1,80 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.jslogger; + +import netscape.jsdebug.*; + +class CallChain +{ + // compare return codes + + public static final int EQUAL = 0; + public static final int CALLER = 1; + public static final int CALLEE = 2; + public static final int DISJOINT = 3; + + public CallChain( JSThreadState threadState ) + { + try + { + StackFrameInfo[] infoarray = threadState.getStack(); + if( null == infoarray || 0 == infoarray.length ) + return; + + int count = infoarray.length; + _chain = new Script[count]; + + for( int i = 0; i < count; i++ ) + _chain[i] = ((JSPC)(infoarray[i].getPC())).getScript(); + } + catch( InvalidInfoException e ) + { + _chain = null; + return; + } + } + + public int compare( CallChain other ) + { + if( this == other ) + return EQUAL; + if( null == _chain || null == other || null == other._chain ) + return DISJOINT; + + int count = _chain.length; + int other_count = other._chain.length; + if( 0 == count || 0 == other_count ) + return DISJOINT; + + int lesser_count = Math.min( count, other_count ); + int i; + for( i = 0; i < lesser_count; i++ ) + { + if( ! _chain[i].equals(other._chain[i]) ) + return DISJOINT; + } + if( count > other_count ) + return CALLER; + if( count < other_count ) + return CALLEE; + return EQUAL; + } + + private Script[] _chain; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/ControlPanel.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/ControlPanel.java new file mode 100644 index 00000000000..379d3fdc550 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/ControlPanel.java @@ -0,0 +1,206 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.jslogger; + +import netscape.application.*; +import netscape.util.*; + +/** +* Main entry point and workhorse for JavaScript Logger +* +* @author John Bandhauer +*/ + +public class ControlPanel + extends View + implements Target, TextFilter +{ + public static ControlPanel create(JSLogger logger) + { + if( ! logger.isApplet() ) + { + ExternalWindow _mainWindow = new ExternalWindow(); + _mainWindow.setBounds(0, 0, 500, 300); + _mainWindow.setTitle("JSLogger"); + _mainWindow.setResizable(false); + logger.setMainRootView(_mainWindow.rootView()); + _mainWindow.show(); + } + logger.mainRootView().setColor(Color.lightGray); +// logger.mainRootView().setColor(Color.white); + return new ControlPanel(logger, logger.mainRootView().localBounds()); + } + private static final int DX = 500; + + private static final int CHECK_DX = 160; + private static final int CHECK_1_X = 2; + private static final int CHECK_2_X = CHECK_1_X+CHECK_DX+2; + private static final int CHECK_INITAL_Y = 2; + private static final int CHECK_DY = 24; + private static final int CHECK_SPACER_DY = 0; + private static final int CHECK_SUBCOL_DX = 10; + + private static final int LABEL_X = CHECK_1_X; + private static final int LABEL_DX = 160; + private static final int EDIT_X = LABEL_X + LABEL_DX + 2; + private static final int EDIT_DX = DX - (LABEL_DX+2+2); + private static final int LABEL_EDIT_DY = 24; + private static final int LABEL_EDIT_SP_DY = 0; + + private int[] check_y = {CHECK_INITAL_Y, CHECK_INITAL_Y}; + private int[] check_x = {CHECK_1_X, CHECK_2_X}; + + private int label_edit_y; + + private ControlPanel(JSLogger logger, Rect rect) + { + super(rect); + _logger = logger; + _logger.mainRootView().addSubview(this); + + _checkbox(0,0,"Logging On", JSLogger.LOGGING_ON); + _checkbox(0,1,"Log Date", JSLogger.LOG_DATE); + _checkbox(0,1,"Log Thread Name", JSLogger.LOG_THREADNAME); + _checkbox(0,1,"Log to File", JSLogger.LOG_TO_FILE); + _checkbox(0,1,"Log to Console", JSLogger.LOG_TO_CONSOLE); + _checkbox(1,0,"Log Execution", JSLogger.TRACE_EXECUTION); + _checkbox(1,1,"Log Function Calls", JSLogger.TRACE_FUNCTION_CALLS); + _checkbox(1,2,"Log Stack Trace", JSLogger.TRACE_DUMP_CALLSTACKS); + _checkbox(1,1,"Log Each Line", JSLogger.TRACE_EACH_LINE); + _checkbox(1,0,"Log Script Loading", JSLogger.TRACE_SCRIPT_LOADING); + + label_edit_y = Math.max(check_y[0],check_y[1]) + 2; + + _edit("Eval Expression", JSLogger.EVAL_EXPRESSION); + _edit("Only Scripts From", JSLogger.LOG_ONLY_SCRIPTS_FROM); + _edit("Ignore Scripts From", JSLogger.IGNORE_SCRIPTS_FROM); + _edit("Only Functions Named", JSLogger.LOG_ONLY_IN_FUNCTION); + _edit("Ignore Functions Named", JSLogger.IGNORE_IN_FUNCTION); + _edit("Ignore Script Loading From", JSLogger.IGNORE_SCRIPT_LOADING_FROM); + } + + private void _checkbox(int col, int subCol, String title, int cmdID) + { + Button button = + Button.createCheckButton(check_x[col] + CHECK_SUBCOL_DX * subCol, + check_y[col], + CHECK_DX - CHECK_SUBCOL_DX * subCol, + CHECK_DY); + button.setTitle(title); + button.setTarget(this); + button.setCommand(_makeBoolCmd(cmdID)); + button.setState(_logger.getBoolOption(cmdID)); + addSubview(button); + + check_y[col] += CHECK_DY + CHECK_SPACER_DY; + } + + private void _edit(String title, int cmdID) + { + TextField label = new TextField(LABEL_X, label_edit_y, + LABEL_DX, LABEL_EDIT_DY ); + label.setStringValue(title); + label.setEditable(false); + label.setSelectable(false); + label.setJustification(Graphics.RIGHT_JUSTIFIED); + label.setBackgroundColor(Color.lightGray); + label.setBorder(null); + addSubview(label); + + TextField edit = new TextField(EDIT_X, label_edit_y, + EDIT_DX, LABEL_EDIT_DY ); + edit.setCommand(_makeStringCmd(cmdID)); + edit.setStringValue(_logger.getStringOption(cmdID)); + edit.setFilter(this); // to catch return key + addSubview(edit); + + label_edit_y += LABEL_EDIT_DY + LABEL_EDIT_SP_DY; + } + + // implement TextFilter interface + public boolean acceptsEvent(Object o, KeyEvent ke , Vector vec) + { + if( ke.isReturnKey() ) + { + try + { + TextField t = (TextField)o; + Application.application().performCommandLater(this, t.command(), t); + return false; + } + catch(Throwable t) + { + System.out.println(t); + // eat it + } + } + return true; + } + + private String _tfs(Object data) + { + TextField t = (TextField)data; + String s = t.stringValue(); + if( null == s || 0 == s.trim().length() ) + return null; + return s; + } + + public void performCommand(String cmd, Object data) + { + if( _isBoolCmd(cmd) ) + _logger.setBoolOption(_getBoolCmdNumber(cmd),((Button)data).state()); + if( _isStringCmd(cmd) ) + _logger.setStringOption(_getStringCmdNumber(cmd),_tfs(data)); + } + + private String _makeBoolCmd(int num) {return BOOL_CMD_PREFIX+num;} + private String _makeStringCmd(int num) {return STRING_CMD_PREFIX+num;} + private boolean _isBoolCmd(String cmd) {return cmd.startsWith(BOOL_CMD_PREFIX);} + private boolean _isStringCmd(String cmd){return cmd.startsWith(STRING_CMD_PREFIX);} + private int _getBoolCmdNumber(String cmd) + { + try + { + return Integer.parseInt(cmd.substring(BOOL_CMD_PREFIX.length())); + } + catch(Exception e) + { + // eat it... + } + return 0; + } + private int _getStringCmdNumber(String cmd) + { + try + { + return Integer.parseInt(cmd.substring(STRING_CMD_PREFIX.length())); + } + catch(Exception e) + { + // eat it... + } + return 0; + } + + private static final String BOOL_CMD_PREFIX = "BOOL_"; + private static final String STRING_CMD_PREFIX = "STRING_"; + + private JSLogger _logger; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/JSLogger.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/JSLogger.java new file mode 100644 index 00000000000..3630f922338 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/JSLogger.java @@ -0,0 +1,183 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.jslogger; + +import netscape.application.*; +import netscape.util.*; +import netscape.jsdebug.*; +import netscape.security.PrivilegeManager; +import com.netscape.jsdebugging.ifcui.Env; +import com.netscape.jsdebugging.ifcui.Log; + +/** +* Main entry point and workhorse for JavaScript Logger +* +* @author John Bandhauer +*/ + +public class JSLogger + extends Application +{ + private static final String _logfilename = "log.txt"; + private static final boolean _interactive = true; + + // boolean options + public static final int LOGGING_ON = 0; + public static final int LOG_DATE = 1; + public static final int LOG_THREADNAME = 2; + public static final int LOG_TO_FILE = 3; + public static final int LOG_TO_CONSOLE = 4; + public static final int TRACE_SCRIPT_LOADING = 5; + public static final int TRACE_EXECUTION = 6; + public static final int TRACE_EACH_LINE = 7; + public static final int TRACE_FUNCTION_CALLS = 8; + public static final int TRACE_DUMP_CALLSTACKS = 9; + public static final int BOOLEAN_LIMIT = 10; + + // String options + public static final int EVAL_EXPRESSION = 0; + public static final int LOG_ONLY_SCRIPTS_FROM = 1; + public static final int IGNORE_SCRIPTS_FROM = 2; + public static final int LOG_ONLY_IN_FUNCTION = 3; + public static final int IGNORE_IN_FUNCTION = 4; + public static final int IGNORE_SCRIPT_LOADING_FROM = 5; + public static final int STRING_LIMIT = 6; + + /** + * Entry point for running as an Application + */ + public static void main(String[] args) + { + System.out.println("Launching JSLogger..."); + new Thread(new JSLogger()).start(); + } + + /** + * override Application.init() + */ + public void init() + { + Env.Init(); +// Log.setEnabled(true); +// Log.setFilename(_logfilename, true); + System.out.println("JSLogger output to : "+Log.getFilename()); + + // defaults can be changed here... + setBoolOption(LOGGING_ON , true); + setBoolOption(LOG_DATE , true); + setBoolOption(LOG_THREADNAME , false); + setBoolOption(LOG_TO_FILE , false); + setBoolOption(LOG_TO_CONSOLE , true); + setBoolOption(TRACE_SCRIPT_LOADING , true); + setBoolOption(TRACE_EXECUTION , true); + setBoolOption(TRACE_EACH_LINE , true); + setBoolOption(TRACE_FUNCTION_CALLS , true); + setBoolOption(TRACE_DUMP_CALLSTACKS , false); + + setStringOption(EVAL_EXPRESSION , null); + setStringOption(LOG_ONLY_SCRIPTS_FROM , null); + setStringOption(IGNORE_SCRIPTS_FROM , null); + setStringOption(LOG_ONLY_IN_FUNCTION , null); + setStringOption(IGNORE_IN_FUNCTION , null); + setStringOption(IGNORE_SCRIPT_LOADING_FROM , null); + + Log.setShowThreadName(getBoolOption(LOG_THREADNAME)); + Log.setLogToFile(getBoolOption(LOG_TO_FILE)); + Log.setLogToConsole(getBoolOption(LOG_TO_CONSOLE)); + + Log.setShowDate(true); + Log.log(null, "========== session start ==========" ); + Log.setShowDate(getBoolOption(LOG_DATE)); + + try + { + PrivilegeManager.enablePrivilege("Debugger"); + _controller = DebugController.getDebugController(); + if( null == _controller || 0 == _controller.getNativeContext() ) + { + Log.log(null, "FAILED to Init DebugController"); + return; + } + _controller.setScriptHook(new MyScriptHook(this)); + _controller.setInterruptHook(new MyInterruptHook(this)); + _controller.setErrorReporter( new MyErrorReporter(this)); + _controller.sendInterrupt(); + + if( _interactive ) + { + _controlPanel = ControlPanel.create(this); + } + } + catch(Throwable t) + { + Log.log(null, "execption thrown " + t ); + } + } + + private void _update() + { + Log.setShowThreadName(getBoolOption(LOG_THREADNAME)); + Log.setLogToFile(getBoolOption(LOG_TO_FILE)); + Log.setLogToConsole(getBoolOption(LOG_TO_CONSOLE)); + Log.setShowDate(getBoolOption(LOG_DATE)); + + if( null != _controller ) + { + try + { + PrivilegeManager.enablePrivilege("Debugger"); + _controller.sendInterrupt(); + } + catch(Throwable t) + { + Log.log(null, "execption thrown " + t ); + } + } + } + + public void setBoolOption(int option, boolean b) + { + _boolOptions[option] = b; + _update(); + } + + public boolean getBoolOption(int option) + { + return _boolOptions[option]; + } + + public void setStringOption(int option, String s) + { + _stringOptions[option] = s; + _update(); + } + + public String getStringOption(int option) + { + return _stringOptions[option]; + } + + public DebugController getController() {return _controller;} + + private DebugController _controller; + private ControlPanel _controlPanel; + private boolean[] _boolOptions = new boolean[BOOLEAN_LIMIT]; + private String[] _stringOptions = new String[STRING_LIMIT]; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/JSLoggerAsIFCApplet.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/JSLoggerAsIFCApplet.java new file mode 100644 index 00000000000..894c77afd7c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/JSLoggerAsIFCApplet.java @@ -0,0 +1,56 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// NetscapeApplet.java + +package com.netscape.jsdebugging.jslogger; + +import netscape.application.*; +import netscape.util.*; + +public class JSLoggerAsIFCApplet extends FoundationApplet { + /** This method must be implemented by the applet developer because + * there is no way in the standard Java API for system classes (such as, + * netscape.application) to look up an applet's class by name. The + * static method Class.forName() simply looks up one level in the + * stack and gets the ClassLoader associated with the method block of the + * caller. + *

+ * When the netscape.application classes are installed as + * system classes, the ClassLoader is null. Thus, when code in + * netscape.application calls Class.forName() it can only find + * other system classes. + *

+ * The solution is an API that allows code to + * find the ClassLoader for an applet by URL, and a public API on + * ClassLoader to ask it to load classes by name. Until those + * enhancements can be made and distributed to all the world's Java + * systems, applets must subclass FoundationApplet and + * implement the following one-line method: + *

+      *     public abstract Class classForName(String className)
+      *         throws ClassNotFoundException {
+      *         return Class.forName(className);
+      *     }
+      * 
+ */ + public Class classForName(String className) + throws ClassNotFoundException { + return Class.forName(className); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyErrorReporter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyErrorReporter.java new file mode 100644 index 00000000000..beeec2758ce --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyErrorReporter.java @@ -0,0 +1,54 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.jslogger; + +import netscape.jsdebug.*; +import netscape.security.PrivilegeManager; +import com.netscape.jsdebugging.ifcui.Log; + +class MyErrorReporter + implements JSErrorReporter +{ + public MyErrorReporter(JSLogger logger) + { + _logger = logger; + } + + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + if( _logger.getBoolOption(JSLogger.LOGGING_ON) ) + { + Log.log(null, "!!!!!!!!!!!!!! BEGIN ERROR_REPORT !!!!!!!!!!!!!!"); + Log.log(null, "!!! msg: " + msg); + Log.log(null, "!!! file: "+ filename); + Log.log(null, "!!! lineno: "+ lineno); + Log.log(null, "!!! linebuf: "+ linebuf); + Log.log(null, "!!! tokenOffset: "+ tokenOffset); + Log.log(null, "!!!!!!!!!!!!!! END ERROR_REPORT !!!!!!!!!!!!!!"); + } + + return JSErrorReporter.PASS_ALONG; + } + private JSLogger _logger; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyInterruptHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyInterruptHook.java new file mode 100644 index 00000000000..2c3fc92803c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyInterruptHook.java @@ -0,0 +1,230 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.jslogger; + +import netscape.jsdebug.*; +import netscape.security.PrivilegeManager; +import com.netscape.jsdebugging.ifcui.Log; + +class MyInterruptHook + extends InterruptHook + implements JSErrorReporter +{ + public MyInterruptHook(JSLogger logger) + { + _logger = logger; + } + + public void aboutToExecute(ThreadStateBase debug, PC pc) + { + try + { + if( ! _enabled(JSLogger.LOGGING_ON) ) + return; + PrivilegeManager.enablePrivilege("Debugger"); + + if( ! _enabled(JSLogger.TRACE_EXECUTION) ) + return; + + JSThreadState state = (JSThreadState) debug; + JSPC jspc = (JSPC) pc; + // bootstap on the first pass... + if( null == _lastJSPC ) + _lastJSPC = jspc; + + String fun = jspc.getScript().getFunction(); + if( null == fun ) + fun = _noFun; + + String file = jspc.getScript().getURL(); + + + if( _enabled(JSLogger.TRACE_FUNCTION_CALLS) ) + { + boolean ignoreChain = false; + CallChain newChain = new CallChain(state); + + // bootstap on the first pass... + if( null == _lastChain ) + { + _lastChain = newChain; + _lastFunction = fun; + _lastJSPC = jspc; + } + + switch(_lastChain.compare(newChain)) + { + default: + case CallChain.EQUAL: + ignoreChain = true; + break; + case CallChain.CALLER: + // returned + Log.log(null, _pad(state)+"call to "+_lastFunction+ + " returned to "+fun+" at line: "+ + jspc.getSourceLocation().getLine()); + break; + case CallChain.CALLEE: + // calling deeper + Log.log(null, _pad(state)+_lastFunction+" is calling "+ + fun+ " from line: "+ + _lastJSPC.getSourceLocation().getLine()); + _lastChain = newChain; + break; + case CallChain.DISJOINT: + Log.log(null, _pad(state)+"control jumped to "+fun); + _lastChain = newChain; + break; + } + if( ! ignoreChain ) + { + if( _enabled(JSLogger.TRACE_DUMP_CALLSTACKS) ) + _dumpStack(state); + _lastFunction = fun; + _lastChain = newChain; + } + } + + if( _enabled(JSLogger.TRACE_EACH_LINE) && + (null == _string(JSLogger.IGNORE_SCRIPTS_FROM) || + ! _string(JSLogger.IGNORE_SCRIPTS_FROM).equals(file)) && + (null == _string(JSLogger.LOG_ONLY_SCRIPTS_FROM) || + _string(JSLogger.LOG_ONLY_SCRIPTS_FROM).equals(file)) && + (null == _string(JSLogger.IGNORE_IN_FUNCTION) || + ! _string(JSLogger.IGNORE_IN_FUNCTION).equals(fun)) && + (null == _string(JSLogger.LOG_ONLY_IN_FUNCTION) || + _string(JSLogger.LOG_ONLY_IN_FUNCTION).equals(fun)) ) + { + if( _lastJSPC.getScript() != jspc.getScript() || + _lastJSPC.getSourceLocation().getLine() != + jspc.getSourceLocation().getLine() ) + { + // show info about this line + String str = _pad(state)+"->"+file+"#"+fun+"#"+ + jspc.getSourceLocation().getLine(); + + // evaluate the expression here if indicated + String expression = _string(JSLogger.EVAL_EXPRESSION); + if( null != expression ) + { + DebugController dc = _logger.getController(); + + JSStackFrameInfo frame = + (JSStackFrameInfo) state.getCurrentFrame(); + + _evalErrorMsg = null; + JSErrorReporter oldER = dc.setErrorReporter(this); + String result = + dc.executeScriptInStackFrame(frame, + expression, + "eval", 1); + dc.setErrorReporter(oldER); + if( null != _evalErrorMsg ) + result = _evalErrorMsg; + + str += " +++ EVAL OF: "+expression+" YIELDS: "+result; + } + Log.log(null, str); + } + + } + _lastJSPC = jspc; + _logger.getController().sendInterrupt(); + } + catch(Throwable t) + { + // eat it... + Log.log(null, "execption thrown " + t ); + } + } + + // implements JSErrorReporter + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ) + { + _evalErrorMsg = "!!ERROR!! "+msg; + return JSErrorReporter.RETURN; + } + + private final String _string(int option) + { + return _logger.getStringOption(option); + } + + private final boolean _enabled(int option) + { + return _logger.getBoolOption(option); + } + + private final String _pad(JSThreadState state) + { + try + { + StringBuffer b = new StringBuffer(); + int len = state.getStack().length; + for(int i = 0; i < len; i++) + b.append(" "); + return b.toString(); + } + catch(Exception e) + { + // eat it; + } + return null; + } + + private void _dumpStack(JSThreadState state) + { + String pad = _pad(state); + Log.log(null, pad+"++++BEGIN STACKDUMP:"); + + try + { + StackFrameInfo[] stack = state.getStack(); + for(int i = stack.length-1; i >= 0 ; i--) + { + JSPC jspc = (JSPC)stack[i].getPC(); + int line = jspc.getSourceLocation().getLine(); + String file = jspc.getScript().getURL(); + String fun = jspc.getScript().getFunction(); + if( null == fun ) + fun = _noFun; + // Log.log(null, pad+"line: "+line+" fun: "+fun+" file: "+file ); + Log.log(null, pad+file+"#"+fun+"#"+line); + } + } + catch(Exception e) + { + // eat it; + } + + Log.log(null, pad+"----END STACKDUMP"); + } + + private JSLogger _logger; + private CallChain _lastChain = null; + private String _lastFunction = null; + private JSPC _lastJSPC = null; + private String _evalErrorMsg; + private static final String _noFun = "_TOP_LEVEL_"; +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyScriptHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyScriptHook.java new file mode 100644 index 00000000000..460360a4113 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/MyScriptHook.java @@ -0,0 +1,91 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.jsdebugging.jslogger; + +import netscape.jsdebug.*; +import netscape.security.PrivilegeManager; +import com.netscape.jsdebugging.ifcui.Log; + +class MyScriptHook + extends ScriptHook +{ + public MyScriptHook(JSLogger logger) + { + _logger = logger; + } + + public void justLoadedScript(Script script) + { + try + { + if( _shouldLog(script) ) + Log.log(null, "++LOADED SCRIPT: " + _describe(script) ); + } + catch(Exception e) + { + // eat it; + } + } + + public void aboutToUnloadScript(Script script) + { + try + { + if( _shouldLog(script) ) + Log.log(null, "--UNLOADED SCRIPT: " + _describe(script) ); + } + catch(Exception e) + { + // eat it; + } + } + + private boolean _shouldLog(Script script) + { + if( ! _enabled(JSLogger.LOGGING_ON) || + ! _enabled(JSLogger.TRACE_SCRIPT_LOADING) ) + return false; + + String ignoreFrom = _string(JSLogger.IGNORE_SCRIPT_LOADING_FROM); + + return ignoreFrom == null || ! ignoreFrom.equals(script.getURL()); + } + + private String _describe(Script script) + { + String s = script.getURL(); + if( null != script.getFunction() ) + s += "#" + script.getFunction() +"()"; + return s; + } + + private final String _string(int option) + { + return _logger.getStringOption(option); + } + + private final boolean _enabled(int option) + { + return _logger.getBoolOption(option); + } + + private JSLogger _logger; +} + + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/README b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/README new file mode 100644 index 00000000000..3224e892e18 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/jslogger/README @@ -0,0 +1,5 @@ +/* jband - 09/14/98 - */ + +jslogger is a simple IFC applet that uses the netscape.jsdebug API (as shipped +in Navigator 4.x - and presumably to be in mozilla) to log JavaScript activity +with runtime control over the level of detail desired. \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugController.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugController.java new file mode 100644 index 00000000000..6233d67cef8 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugController.java @@ -0,0 +1,71 @@ + +package com.netscape.jsdebugging.remote.corba; + +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +public interface IDebugController extends org.omg.CORBA.Object +{ + public int getMajorVersion(); + public int getMinorVersion(); + + public IJSErrorReporter setErrorReporter(IJSErrorReporter er); + public IJSErrorReporter getErrorReporter(); + + public IScriptHook setScriptHook(IScriptHook h); + public IScriptHook getScriptHook(); + + public IJSPC getClosestPC(IScript script, int line); + + public IJSSourceLocation getSourceLocation(IJSPC pc); + + public IJSExecutionHook setInterruptHook(IJSExecutionHook hook); + public IJSExecutionHook getInterruptHook(); + + public IJSExecutionHook setDebugBreakHook(IJSExecutionHook hook); + public IJSExecutionHook getDebugBreakHook(); + + public IJSExecutionHook setInstructionHook(IJSExecutionHook hook, IJSPC pc); + public IJSExecutionHook getInstructionHook(IJSPC pc); + + public void setThreadContinueState(int threadID, int state); + public void setThreadReturnValue(int threadID, String value); + + public void sendInterrupt(); + + public void sendInterruptStepInto(int threadID); + public void sendInterruptStepOver(int threadID); + public void sendInterruptStepOut(int threadID); + + public void reinstateStepper(int threadID); + + + public IExecResult executeScriptInStackFrame(int threadID, + IJSStackFrameInfo frame, + String text, + String filename, + int lineno); + + public boolean isRunningHook(int threadID); + public boolean isWaitingForResume(int threadID); + public void leaveThreadSuspended(int threadID); + public void resumeThread(int threadID); + + public void iterateScripts(IScriptHook h); +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugControllerHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugControllerHelper.java new file mode 100644 index 00000000000..a8efa9f3952 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugControllerHelper.java @@ -0,0 +1,60 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IDebugControllerHelper { + public static com.netscape.jsdebugging.remote.corba.IDebugController narrow(org.omg.CORBA.Object object) { + return narrow(object, false); + } + private static com.netscape.jsdebugging.remote.corba.IDebugController narrow(org.omg.CORBA.Object object, boolean is_a) { + if(object == null) { + return null; + } + if(object instanceof com.netscape.jsdebugging.remote.corba.IDebugController) { + return (com.netscape.jsdebugging.remote.corba.IDebugController) object; + } + if(is_a || object._is_a(id())) { + com.netscape.jsdebugging.remote.corba.IDebugController result = new com.netscape.jsdebugging.remote.corba._st_IDebugController(); + ((org.omg.CORBA.portable.ObjectImpl) result)._set_delegate + (((org.omg.CORBA.portable.ObjectImpl) object)._get_delegate()); + return result; + } + return null; + } + public static com.netscape.jsdebugging.remote.corba.IDebugController bind(org.omg.CORBA.ORB orb) { + return bind(orb, null, null, null); + } + public static com.netscape.jsdebugging.remote.corba.IDebugController bind(org.omg.CORBA.ORB orb, java.lang.String name) { + return bind(orb, name, null, null); + } + public static com.netscape.jsdebugging.remote.corba.IDebugController bind(org.omg.CORBA.ORB orb, java.lang.String name, java.lang.String host, org.omg.CORBA.BindOptions options) { + return narrow(orb.bind(id(), name, host, options), true); + } + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IDebugController read(org.omg.CORBA.portable.InputStream _input) { + return com.netscape.jsdebugging.remote.corba.IDebugControllerHelper.narrow(_input.read_Object(), true); + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IDebugController value) { + _output.write_Object(value); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IDebugController value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IDebugController extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + _type = _orb().create_interface_tc(id(), "IDebugController"); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IDebugController:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugControllerHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugControllerHolder.java new file mode 100644 index 00000000000..22540785db2 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IDebugControllerHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IDebugControllerHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IDebugController value; + public IDebugControllerHolder() { + } + public IDebugControllerHolder(com.netscape.jsdebugging.remote.corba.IDebugController value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IDebugControllerHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IDebugControllerHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IDebugControllerHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResult.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResult.java new file mode 100644 index 00000000000..39e9feb719d --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResult.java @@ -0,0 +1,34 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IExecResult { + public java.lang.String result; + public boolean errorOccured; + public java.lang.String errorMessage; + public java.lang.String errorFilename; + public int errorLineNumber; + public java.lang.String errorLineBuffer; + public int errorTokenOffset; + public IExecResult() { + } + public IExecResult( + java.lang.String result, + boolean errorOccured, + java.lang.String errorMessage, + java.lang.String errorFilename, + int errorLineNumber, + java.lang.String errorLineBuffer, + int errorTokenOffset + ) { + this.result = result; + this.errorOccured = errorOccured; + this.errorMessage = errorMessage; + this.errorFilename = errorFilename; + this.errorLineNumber = errorLineNumber; + this.errorLineBuffer = errorLineBuffer; + this.errorTokenOffset = errorTokenOffset; + } + public java.lang.String toString() { + org.omg.CORBA.Any any = org.omg.CORBA.ORB.init().create_any(); + com.netscape.jsdebugging.remote.corba.IExecResultHelper.insert(any, this); + return any.toString(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResultHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResultHelper.java new file mode 100644 index 00000000000..989564b1132 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResultHelper.java @@ -0,0 +1,55 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IExecResultHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IExecResult read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.IExecResult result = new com.netscape.jsdebugging.remote.corba.IExecResult(); + result.result = _input.read_string(); + result.errorOccured = _input.read_boolean(); + result.errorMessage = _input.read_string(); + result.errorFilename = _input.read_string(); + result.errorLineNumber = _input.read_long(); + result.errorLineBuffer = _input.read_string(); + result.errorTokenOffset = _input.read_long(); + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IExecResult value) { + _output.write_string(value.result); + _output.write_boolean(value.errorOccured); + _output.write_string(value.errorMessage); + _output.write_string(value.errorFilename); + _output.write_long(value.errorLineNumber); + _output.write_string(value.errorLineBuffer); + _output.write_long(value.errorTokenOffset); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IExecResult value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IExecResult extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[7]; + members[0] = new org.omg.CORBA.StructMember("result", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), null); + members[1] = new org.omg.CORBA.StructMember("errorOccured", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_boolean), null); + members[2] = new org.omg.CORBA.StructMember("errorMessage", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), null); + members[3] = new org.omg.CORBA.StructMember("errorFilename", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), null); + members[4] = new org.omg.CORBA.StructMember("errorLineNumber", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + members[5] = new org.omg.CORBA.StructMember("errorLineBuffer", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), null); + members[6] = new org.omg.CORBA.StructMember("errorTokenOffset", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + _type = _orb().create_struct_tc(id(), "IExecResult", members); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IExecResult:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResultHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResultHolder.java new file mode 100644 index 00000000000..15af52567a0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IExecResultHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IExecResultHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IExecResult value; + public IExecResultHolder() { + } + public IExecResultHolder(com.netscape.jsdebugging.remote.corba.IExecResult value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IExecResultHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IExecResultHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IExecResultHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporter.java new file mode 100644 index 00000000000..7679f8ac5bd --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporter.java @@ -0,0 +1,35 @@ + +package com.netscape.jsdebugging.remote.corba; + +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +public interface IJSErrorReporter extends org.omg.CORBA.Object +{ + /* keep these in sync with the numbers in jsdebug.h */ + public static final int PASS_ALONG = 0; + public static final int RETURN = 1; + public static final int DEBUG = 2; + + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ); +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporterHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporterHelper.java new file mode 100644 index 00000000000..5407c991af1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporterHelper.java @@ -0,0 +1,60 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IJSErrorReporterHelper { + public static com.netscape.jsdebugging.remote.corba.IJSErrorReporter narrow(org.omg.CORBA.Object object) { + return narrow(object, false); + } + private static com.netscape.jsdebugging.remote.corba.IJSErrorReporter narrow(org.omg.CORBA.Object object, boolean is_a) { + if(object == null) { + return null; + } + if(object instanceof com.netscape.jsdebugging.remote.corba.IJSErrorReporter) { + return (com.netscape.jsdebugging.remote.corba.IJSErrorReporter) object; + } + if(is_a || object._is_a(id())) { + com.netscape.jsdebugging.remote.corba.IJSErrorReporter result = new com.netscape.jsdebugging.remote.corba._st_IJSErrorReporter(); + ((org.omg.CORBA.portable.ObjectImpl) result)._set_delegate + (((org.omg.CORBA.portable.ObjectImpl) object)._get_delegate()); + return result; + } + return null; + } + public static com.netscape.jsdebugging.remote.corba.IJSErrorReporter bind(org.omg.CORBA.ORB orb) { + return bind(orb, null, null, null); + } + public static com.netscape.jsdebugging.remote.corba.IJSErrorReporter bind(org.omg.CORBA.ORB orb, java.lang.String name) { + return bind(orb, name, null, null); + } + public static com.netscape.jsdebugging.remote.corba.IJSErrorReporter bind(org.omg.CORBA.ORB orb, java.lang.String name, java.lang.String host, org.omg.CORBA.BindOptions options) { + return narrow(orb.bind(id(), name, host, options), true); + } + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IJSErrorReporter read(org.omg.CORBA.portable.InputStream _input) { + return com.netscape.jsdebugging.remote.corba.IJSErrorReporterHelper.narrow(_input.read_Object(), true); + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IJSErrorReporter value) { + _output.write_Object(value); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IJSErrorReporter value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IJSErrorReporter extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + _type = _orb().create_interface_tc(id(), "IJSErrorReporter"); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IJSErrorReporter:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporterHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporterHolder.java new file mode 100644 index 00000000000..d8de88a68c9 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSErrorReporterHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IJSErrorReporterHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IJSErrorReporter value; + public IJSErrorReporterHolder() { + } + public IJSErrorReporterHolder(com.netscape.jsdebugging.remote.corba.IJSErrorReporter value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IJSErrorReporterHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IJSErrorReporterHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IJSErrorReporterHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHook.java new file mode 100644 index 00000000000..fb208ace662 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHook.java @@ -0,0 +1,7 @@ +package com.netscape.jsdebugging.remote.corba; +public interface IJSExecutionHook extends org.omg.CORBA.Object { + public void aboutToExecute( + com.netscape.jsdebugging.remote.corba.IJSThreadState arg0, + com.netscape.jsdebugging.remote.corba.IJSPC arg1 + ); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHookHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHookHelper.java new file mode 100644 index 00000000000..eb97adba9ca --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHookHelper.java @@ -0,0 +1,60 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IJSExecutionHookHelper { + public static com.netscape.jsdebugging.remote.corba.IJSExecutionHook narrow(org.omg.CORBA.Object object) { + return narrow(object, false); + } + private static com.netscape.jsdebugging.remote.corba.IJSExecutionHook narrow(org.omg.CORBA.Object object, boolean is_a) { + if(object == null) { + return null; + } + if(object instanceof com.netscape.jsdebugging.remote.corba.IJSExecutionHook) { + return (com.netscape.jsdebugging.remote.corba.IJSExecutionHook) object; + } + if(is_a || object._is_a(id())) { + com.netscape.jsdebugging.remote.corba.IJSExecutionHook result = new com.netscape.jsdebugging.remote.corba._st_IJSExecutionHook(); + ((org.omg.CORBA.portable.ObjectImpl) result)._set_delegate + (((org.omg.CORBA.portable.ObjectImpl) object)._get_delegate()); + return result; + } + return null; + } + public static com.netscape.jsdebugging.remote.corba.IJSExecutionHook bind(org.omg.CORBA.ORB orb) { + return bind(orb, null, null, null); + } + public static com.netscape.jsdebugging.remote.corba.IJSExecutionHook bind(org.omg.CORBA.ORB orb, java.lang.String name) { + return bind(orb, name, null, null); + } + public static com.netscape.jsdebugging.remote.corba.IJSExecutionHook bind(org.omg.CORBA.ORB orb, java.lang.String name, java.lang.String host, org.omg.CORBA.BindOptions options) { + return narrow(orb.bind(id(), name, host, options), true); + } + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IJSExecutionHook read(org.omg.CORBA.portable.InputStream _input) { + return com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.narrow(_input.read_Object(), true); + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IJSExecutionHook value) { + _output.write_Object(value); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IJSExecutionHook value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IJSExecutionHook extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + _type = _orb().create_interface_tc(id(), "IJSExecutionHook"); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IJSExecutionHook:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHookHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHookHolder.java new file mode 100644 index 00000000000..141e79681ff --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSExecutionHookHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IJSExecutionHookHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IJSExecutionHook value; + public IJSExecutionHookHolder() { + } + public IJSExecutionHookHolder(com.netscape.jsdebugging.remote.corba.IJSExecutionHook value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IJSExecutionHookHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IJSExecutionHookHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IJSExecutionHookHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPC.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPC.java new file mode 100644 index 00000000000..998e12d8f5d --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPC.java @@ -0,0 +1,19 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IJSPC { + public com.netscape.jsdebugging.remote.corba.IScript script; + public int offset; + public IJSPC() { + } + public IJSPC( + com.netscape.jsdebugging.remote.corba.IScript script, + int offset + ) { + this.script = script; + this.offset = offset; + } + public java.lang.String toString() { + org.omg.CORBA.Any any = org.omg.CORBA.ORB.init().create_any(); + com.netscape.jsdebugging.remote.corba.IJSPCHelper.insert(any, this); + return any.toString(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPCHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPCHelper.java new file mode 100644 index 00000000000..18a421886b6 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPCHelper.java @@ -0,0 +1,40 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IJSPCHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IJSPC read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.IJSPC result = new com.netscape.jsdebugging.remote.corba.IJSPC(); + result.script = com.netscape.jsdebugging.remote.corba.IScriptHelper.read(_input); + result.offset = _input.read_long(); + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IJSPC value) { + com.netscape.jsdebugging.remote.corba.IScriptHelper.write(_output, value.script); + _output.write_long(value.offset); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IJSPC value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IJSPC extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[2]; + members[0] = new org.omg.CORBA.StructMember("script", com.netscape.jsdebugging.remote.corba.IScriptHelper.type(), null); + members[1] = new org.omg.CORBA.StructMember("offset", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + _type = _orb().create_struct_tc(id(), "IJSPC", members); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IJSPC:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPCHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPCHolder.java new file mode 100644 index 00000000000..9de9dcfae30 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSPCHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IJSPCHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IJSPC value; + public IJSPCHolder() { + } + public IJSPCHolder(com.netscape.jsdebugging.remote.corba.IJSPC value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IJSPCHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IJSPCHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IJSPCHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocation.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocation.java new file mode 100644 index 00000000000..0b9562619e1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocation.java @@ -0,0 +1,19 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IJSSourceLocation { + public int line; + public com.netscape.jsdebugging.remote.corba.IJSPC pc; + public IJSSourceLocation() { + } + public IJSSourceLocation( + int line, + com.netscape.jsdebugging.remote.corba.IJSPC pc + ) { + this.line = line; + this.pc = pc; + } + public java.lang.String toString() { + org.omg.CORBA.Any any = org.omg.CORBA.ORB.init().create_any(); + com.netscape.jsdebugging.remote.corba.IJSSourceLocationHelper.insert(any, this); + return any.toString(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocationHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocationHelper.java new file mode 100644 index 00000000000..df546a7784b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocationHelper.java @@ -0,0 +1,40 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IJSSourceLocationHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IJSSourceLocation read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.IJSSourceLocation result = new com.netscape.jsdebugging.remote.corba.IJSSourceLocation(); + result.line = _input.read_long(); + result.pc = com.netscape.jsdebugging.remote.corba.IJSPCHelper.read(_input); + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IJSSourceLocation value) { + _output.write_long(value.line); + com.netscape.jsdebugging.remote.corba.IJSPCHelper.write(_output, value.pc); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IJSSourceLocation value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IJSSourceLocation extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[2]; + members[0] = new org.omg.CORBA.StructMember("line", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + members[1] = new org.omg.CORBA.StructMember("pc", com.netscape.jsdebugging.remote.corba.IJSPCHelper.type(), null); + _type = _orb().create_struct_tc(id(), "IJSSourceLocation", members); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IJSSourceLocation:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocationHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocationHolder.java new file mode 100644 index 00000000000..abfcdda8bfb --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSSourceLocationHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IJSSourceLocationHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IJSSourceLocation value; + public IJSSourceLocationHolder() { + } + public IJSSourceLocationHolder(com.netscape.jsdebugging.remote.corba.IJSSourceLocation value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IJSSourceLocationHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IJSSourceLocationHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IJSSourceLocationHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfo.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfo.java new file mode 100644 index 00000000000..248516f2bd2 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfo.java @@ -0,0 +1,19 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IJSStackFrameInfo { + public com.netscape.jsdebugging.remote.corba.IJSPC pc; + public int jsdframe; + public IJSStackFrameInfo() { + } + public IJSStackFrameInfo( + com.netscape.jsdebugging.remote.corba.IJSPC pc, + int jsdframe + ) { + this.pc = pc; + this.jsdframe = jsdframe; + } + public java.lang.String toString() { + org.omg.CORBA.Any any = org.omg.CORBA.ORB.init().create_any(); + com.netscape.jsdebugging.remote.corba.IJSStackFrameInfoHelper.insert(any, this); + return any.toString(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfoHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfoHelper.java new file mode 100644 index 00000000000..278afbc0b97 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfoHelper.java @@ -0,0 +1,40 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IJSStackFrameInfoHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo result = new com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo(); + result.pc = com.netscape.jsdebugging.remote.corba.IJSPCHelper.read(_input); + result.jsdframe = _input.read_long(); + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo value) { + com.netscape.jsdebugging.remote.corba.IJSPCHelper.write(_output, value.pc); + _output.write_long(value.jsdframe); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[2]; + members[0] = new org.omg.CORBA.StructMember("pc", com.netscape.jsdebugging.remote.corba.IJSPCHelper.type(), null); + members[1] = new org.omg.CORBA.StructMember("jsdframe", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + _type = _orb().create_struct_tc(id(), "IJSStackFrameInfo", members); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IJSStackFrameInfo:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfoHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfoHolder.java new file mode 100644 index 00000000000..6c3aa23f599 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSStackFrameInfoHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IJSStackFrameInfoHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo value; + public IJSStackFrameInfoHolder() { + } + public IJSStackFrameInfoHolder(com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IJSStackFrameInfoHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IJSStackFrameInfoHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IJSStackFrameInfoHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadState.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadState.java new file mode 100644 index 00000000000..51f2c10ed07 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadState.java @@ -0,0 +1,68 @@ + +package com.netscape.jsdebugging.remote.corba; + +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +public final class IJSThreadState +{ + /** + * partial list of thread states from sun.debug.ThreadInfo. + * XXX some of these don't apply. + */ + public final static int THR_STATUS_UNKNOWN = 0x01; + public final static int THR_STATUS_ZOMBIE = 0x02; + public final static int THR_STATUS_RUNNING = 0x03; + public final static int THR_STATUS_SLEEPING = 0x04; + public final static int THR_STATUS_MONWAIT = 0x05; + public final static int THR_STATUS_CONDWAIT = 0x06; + public final static int THR_STATUS_SUSPENDED = 0x07; + public final static int THR_STATUS_BREAK = 0x08; + + + public final static int DEBUG_STATE_DEAD = 0x01; + + /** + * if the continueState is RUN, the thread will + * proceed to the next program counter value when it resumes. + */ + public final static int DEBUG_STATE_RUN = 0x02; + + /** + * if the continueState is RETURN, the thread will + * return from the current method with the value in getReturnValue() + * when it resumes. + */ + public final static int DEBUG_STATE_RETURN = 0x03; + + /** + * if the continueState is THROW, the thread will + * throw an exception (accessible with getException()) when it + * resumes. + */ + public final static int DEBUG_STATE_THROW = 0x04; + + + public IJSStackFrameInfo[] stack; + public int continueState; + public String returnValue; + public int status; + public int jsdthreadstate; + public int id; // used for referencing this object +} + diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadStateHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadStateHelper.java new file mode 100644 index 00000000000..0fcb7eaf9f4 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadStateHelper.java @@ -0,0 +1,52 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IJSThreadStateHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IJSThreadState read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.IJSThreadState result = new com.netscape.jsdebugging.remote.corba.IJSThreadState(); + result.stack = com.netscape.jsdebugging.remote.corba.sequence_of_IJSStackFrameInfoHelper.read(_input); + result.continueState = _input.read_long(); + result.returnValue = _input.read_string(); + result.status = _input.read_long(); + result.jsdthreadstate = _input.read_long(); + result.id = _input.read_long(); + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IJSThreadState value) { + com.netscape.jsdebugging.remote.corba.sequence_of_IJSStackFrameInfoHelper.write(_output, value.stack); + _output.write_long(value.continueState); + _output.write_string(value.returnValue); + _output.write_long(value.status); + _output.write_long(value.jsdthreadstate); + _output.write_long(value.id); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IJSThreadState value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IJSThreadState extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[6]; + members[0] = new org.omg.CORBA.StructMember("stack", _orb().create_sequence_tc(0, com.netscape.jsdebugging.remote.corba.IJSStackFrameInfoHelper.type()), null); + members[1] = new org.omg.CORBA.StructMember("continueState", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + members[2] = new org.omg.CORBA.StructMember("returnValue", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), null); + members[3] = new org.omg.CORBA.StructMember("status", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + members[4] = new org.omg.CORBA.StructMember("jsdthreadstate", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + members[5] = new org.omg.CORBA.StructMember("id", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + _type = _orb().create_struct_tc(id(), "IJSThreadState", members); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IJSThreadState:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadStateHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadStateHolder.java new file mode 100644 index 00000000000..afcd1fb6676 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IJSThreadStateHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IJSThreadStateHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IJSThreadState value; + public IJSThreadStateHolder() { + } + public IJSThreadStateHolder(com.netscape.jsdebugging.remote.corba.IJSThreadState value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IJSThreadStateHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IJSThreadStateHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IJSThreadStateHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScript.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScript.java new file mode 100644 index 00000000000..04cb40d76f1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScript.java @@ -0,0 +1,31 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IScript { + public java.lang.String url; + public java.lang.String funname; + public int base; + public int extent; + public int jsdscript; + public com.netscape.jsdebugging.remote.corba.IScriptSection[] sections; + public IScript() { + } + public IScript( + java.lang.String url, + java.lang.String funname, + int base, + int extent, + int jsdscript, + com.netscape.jsdebugging.remote.corba.IScriptSection[] sections + ) { + this.url = url; + this.funname = funname; + this.base = base; + this.extent = extent; + this.jsdscript = jsdscript; + this.sections = sections; + } + public java.lang.String toString() { + org.omg.CORBA.Any any = org.omg.CORBA.ORB.init().create_any(); + com.netscape.jsdebugging.remote.corba.IScriptHelper.insert(any, this); + return any.toString(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHelper.java new file mode 100644 index 00000000000..a0111ebbb5a --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHelper.java @@ -0,0 +1,52 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IScriptHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IScript read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.IScript result = new com.netscape.jsdebugging.remote.corba.IScript(); + result.url = _input.read_string(); + result.funname = _input.read_string(); + result.base = _input.read_long(); + result.extent = _input.read_long(); + result.jsdscript = _input.read_long(); + result.sections = com.netscape.jsdebugging.remote.corba.sequence_of_IScriptSectionHelper.read(_input); + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IScript value) { + _output.write_string(value.url); + _output.write_string(value.funname); + _output.write_long(value.base); + _output.write_long(value.extent); + _output.write_long(value.jsdscript); + com.netscape.jsdebugging.remote.corba.sequence_of_IScriptSectionHelper.write(_output, value.sections); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IScript value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IScript extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[6]; + members[0] = new org.omg.CORBA.StructMember("url", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), null); + members[1] = new org.omg.CORBA.StructMember("funname", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), null); + members[2] = new org.omg.CORBA.StructMember("base", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + members[3] = new org.omg.CORBA.StructMember("extent", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + members[4] = new org.omg.CORBA.StructMember("jsdscript", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + members[5] = new org.omg.CORBA.StructMember("sections", _orb().create_sequence_tc(0, com.netscape.jsdebugging.remote.corba.IScriptSectionHelper.type()), null); + _type = _orb().create_struct_tc(id(), "IScript", members); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IScript:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHolder.java new file mode 100644 index 00000000000..f3079b229fd --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IScriptHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IScript value; + public IScriptHolder() { + } + public IScriptHolder(com.netscape.jsdebugging.remote.corba.IScript value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IScriptHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IScriptHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IScriptHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHook.java new file mode 100644 index 00000000000..1ec391a7ec8 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHook.java @@ -0,0 +1,9 @@ +package com.netscape.jsdebugging.remote.corba; +public interface IScriptHook extends org.omg.CORBA.Object { + public void justLoadedScript( + com.netscape.jsdebugging.remote.corba.IScript arg0 + ); + public void aboutToUnloadScript( + com.netscape.jsdebugging.remote.corba.IScript arg0 + ); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHookHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHookHelper.java new file mode 100644 index 00000000000..788e6b5a29e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHookHelper.java @@ -0,0 +1,60 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IScriptHookHelper { + public static com.netscape.jsdebugging.remote.corba.IScriptHook narrow(org.omg.CORBA.Object object) { + return narrow(object, false); + } + private static com.netscape.jsdebugging.remote.corba.IScriptHook narrow(org.omg.CORBA.Object object, boolean is_a) { + if(object == null) { + return null; + } + if(object instanceof com.netscape.jsdebugging.remote.corba.IScriptHook) { + return (com.netscape.jsdebugging.remote.corba.IScriptHook) object; + } + if(is_a || object._is_a(id())) { + com.netscape.jsdebugging.remote.corba.IScriptHook result = new com.netscape.jsdebugging.remote.corba._st_IScriptHook(); + ((org.omg.CORBA.portable.ObjectImpl) result)._set_delegate + (((org.omg.CORBA.portable.ObjectImpl) object)._get_delegate()); + return result; + } + return null; + } + public static com.netscape.jsdebugging.remote.corba.IScriptHook bind(org.omg.CORBA.ORB orb) { + return bind(orb, null, null, null); + } + public static com.netscape.jsdebugging.remote.corba.IScriptHook bind(org.omg.CORBA.ORB orb, java.lang.String name) { + return bind(orb, name, null, null); + } + public static com.netscape.jsdebugging.remote.corba.IScriptHook bind(org.omg.CORBA.ORB orb, java.lang.String name, java.lang.String host, org.omg.CORBA.BindOptions options) { + return narrow(orb.bind(id(), name, host, options), true); + } + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IScriptHook read(org.omg.CORBA.portable.InputStream _input) { + return com.netscape.jsdebugging.remote.corba.IScriptHookHelper.narrow(_input.read_Object(), true); + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IScriptHook value) { + _output.write_Object(value); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IScriptHook value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IScriptHook extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + _type = _orb().create_interface_tc(id(), "IScriptHook"); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IScriptHook:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHookHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHookHolder.java new file mode 100644 index 00000000000..024cfa5b198 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptHookHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IScriptHookHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IScriptHook value; + public IScriptHookHolder() { + } + public IScriptHookHolder(com.netscape.jsdebugging.remote.corba.IScriptHook value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IScriptHookHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IScriptHookHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IScriptHookHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSection.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSection.java new file mode 100644 index 00000000000..126cf5fe2f0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSection.java @@ -0,0 +1,19 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IScriptSection { + public int base; + public int extent; + public IScriptSection() { + } + public IScriptSection( + int base, + int extent + ) { + this.base = base; + this.extent = extent; + } + public java.lang.String toString() { + org.omg.CORBA.Any any = org.omg.CORBA.ORB.init().create_any(); + com.netscape.jsdebugging.remote.corba.IScriptSectionHelper.insert(any, this); + return any.toString(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSectionHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSectionHelper.java new file mode 100644 index 00000000000..d2032f088f2 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSectionHelper.java @@ -0,0 +1,40 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class IScriptSectionHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IScriptSection read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.IScriptSection result = new com.netscape.jsdebugging.remote.corba.IScriptSection(); + result.base = _input.read_long(); + result.extent = _input.read_long(); + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IScriptSection value) { + _output.write_long(value.base); + _output.write_long(value.extent); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IScriptSection value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IScriptSection extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[2]; + members[0] = new org.omg.CORBA.StructMember("base", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + members[1] = new org.omg.CORBA.StructMember("extent", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + _type = _orb().create_struct_tc(id(), "IScriptSection", members); + } + return _type; + } + public static java.lang.String id() { + return "IDL:IScriptSection:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSectionHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSectionHolder.java new file mode 100644 index 00000000000..564ce3cf92f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/IScriptSectionHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class IScriptSectionHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IScriptSection value; + public IScriptSectionHolder() { + } + public IScriptSectionHolder(com.netscape.jsdebugging.remote.corba.IScriptSection value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = IScriptSectionHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + IScriptSectionHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return IScriptSectionHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProvider.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProvider.java new file mode 100644 index 00000000000..28c7ce877af --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProvider.java @@ -0,0 +1,40 @@ + +package com.netscape.jsdebugging.remote.corba; + +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +public interface ISourceTextProvider extends org.omg.CORBA.Object +{ + /* these coorespond to jsdebug.h values - change in both places if anywhere */ + public static final int INITED = 0; + public static final int FULL = 1; + public static final int PARTIAL = 2; + public static final int ABORTED = 3; + public static final int FAILED = 4; + public static final int CLEARED = 5; + + public String[] getAllPages(); + public void refreshAllPages(); + public boolean hasPage(String url); + public boolean loadPage(String url); + public void refreshPage(String url); + public String getPageText(String url); + public int getPageStatus(String url); + public int getPageAlterCount(String url); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderHelper.java new file mode 100644 index 00000000000..cdb7c528d8c --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderHelper.java @@ -0,0 +1,60 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class ISourceTextProviderHelper { + public static com.netscape.jsdebugging.remote.corba.ISourceTextProvider narrow(org.omg.CORBA.Object object) { + return narrow(object, false); + } + private static com.netscape.jsdebugging.remote.corba.ISourceTextProvider narrow(org.omg.CORBA.Object object, boolean is_a) { + if(object == null) { + return null; + } + if(object instanceof com.netscape.jsdebugging.remote.corba.ISourceTextProvider) { + return (com.netscape.jsdebugging.remote.corba.ISourceTextProvider) object; + } + if(is_a || object._is_a(id())) { + com.netscape.jsdebugging.remote.corba.ISourceTextProvider result = new com.netscape.jsdebugging.remote.corba._st_ISourceTextProvider(); + ((org.omg.CORBA.portable.ObjectImpl) result)._set_delegate + (((org.omg.CORBA.portable.ObjectImpl) object)._get_delegate()); + return result; + } + return null; + } + public static com.netscape.jsdebugging.remote.corba.ISourceTextProvider bind(org.omg.CORBA.ORB orb) { + return bind(orb, null, null, null); + } + public static com.netscape.jsdebugging.remote.corba.ISourceTextProvider bind(org.omg.CORBA.ORB orb, java.lang.String name) { + return bind(orb, name, null, null); + } + public static com.netscape.jsdebugging.remote.corba.ISourceTextProvider bind(org.omg.CORBA.ORB orb, java.lang.String name, java.lang.String host, org.omg.CORBA.BindOptions options) { + return narrow(orb.bind(id(), name, host, options), true); + } + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.ISourceTextProvider read(org.omg.CORBA.portable.InputStream _input) { + return com.netscape.jsdebugging.remote.corba.ISourceTextProviderHelper.narrow(_input.read_Object(), true); + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.ISourceTextProvider value) { + _output.write_Object(value); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.ISourceTextProvider value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.ISourceTextProvider extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + _type = _orb().create_interface_tc(id(), "ISourceTextProvider"); + } + return _type; + } + public static java.lang.String id() { + return "IDL:ISourceTextProvider:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderHolder.java new file mode 100644 index 00000000000..7700aa9ab92 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class ISourceTextProviderHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.ISourceTextProvider value; + public ISourceTextProviderHolder() { + } + public ISourceTextProviderHolder(com.netscape.jsdebugging.remote.corba.ISourceTextProvider value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = ISourceTextProviderHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + ISourceTextProviderHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return ISourceTextProviderHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderPackage/sequence_of_stringHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderPackage/sequence_of_stringHelper.java new file mode 100644 index 00000000000..4aa417e9cd7 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderPackage/sequence_of_stringHelper.java @@ -0,0 +1,45 @@ + package com.netscape.jsdebugging.remote.corba.ISourceTextProviderPackage; + abstract public class sequence_of_stringHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static java.lang.String[] read(org.omg.CORBA.portable.InputStream _input) { + java.lang.String[] result; + { + int _length4 = _input.read_long(); + result = new java.lang.String[_length4]; + for(int _i4 = 0; _i4 < _length4; _i4++) { + result[_i4] = _input.read_string(); + } + } + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, java.lang.String[] value) { + _output.write_long(value.length); + for(int _i3 = 0; _i3 < value.length; _i3++) { + _output.write_string(value[_i3]); + } + } + public static void insert(org.omg.CORBA.Any any, java.lang.String[] value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static java.lang.String[] extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.TypeCode original_type = _orb().create_sequence_tc(0, _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string)); + _type = _orb().create_alias_tc(id(), "sequence_of_string", original_type); + } + return _type; + } + public static java.lang.String id() { + return "IDL:ISourceTextProvider/sequence_of_string:1.0"; + } + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderPackage/sequence_of_stringHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderPackage/sequence_of_stringHolder.java new file mode 100644 index 00000000000..a86ccf1951e --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ISourceTextProviderPackage/sequence_of_stringHolder.java @@ -0,0 +1,18 @@ + package com.netscape.jsdebugging.remote.corba.ISourceTextProviderPackage; + final public class sequence_of_stringHolder implements org.omg.CORBA.portable.Streamable { + public java.lang.String[] value; + public sequence_of_stringHolder() { + } + public sequence_of_stringHolder(java.lang.String[] value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = sequence_of_stringHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + sequence_of_stringHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return sequence_of_stringHelper.type(); + } + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringReciever.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringReciever.java new file mode 100644 index 00000000000..6f3b1834f4f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringReciever.java @@ -0,0 +1,9 @@ +package com.netscape.jsdebugging.remote.corba; +public interface StringReciever extends org.omg.CORBA.Object { + public void recieveString( + java.lang.String arg0 + ); + public void bounce( + int arg0 + ); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringRecieverHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringRecieverHelper.java new file mode 100644 index 00000000000..02c5be775c0 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringRecieverHelper.java @@ -0,0 +1,60 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class StringRecieverHelper { + public static com.netscape.jsdebugging.remote.corba.StringReciever narrow(org.omg.CORBA.Object object) { + return narrow(object, false); + } + private static com.netscape.jsdebugging.remote.corba.StringReciever narrow(org.omg.CORBA.Object object, boolean is_a) { + if(object == null) { + return null; + } + if(object instanceof com.netscape.jsdebugging.remote.corba.StringReciever) { + return (com.netscape.jsdebugging.remote.corba.StringReciever) object; + } + if(is_a || object._is_a(id())) { + com.netscape.jsdebugging.remote.corba.StringReciever result = new com.netscape.jsdebugging.remote.corba._st_StringReciever(); + ((org.omg.CORBA.portable.ObjectImpl) result)._set_delegate + (((org.omg.CORBA.portable.ObjectImpl) object)._get_delegate()); + return result; + } + return null; + } + public static com.netscape.jsdebugging.remote.corba.StringReciever bind(org.omg.CORBA.ORB orb) { + return bind(orb, null, null, null); + } + public static com.netscape.jsdebugging.remote.corba.StringReciever bind(org.omg.CORBA.ORB orb, java.lang.String name) { + return bind(orb, name, null, null); + } + public static com.netscape.jsdebugging.remote.corba.StringReciever bind(org.omg.CORBA.ORB orb, java.lang.String name, java.lang.String host, org.omg.CORBA.BindOptions options) { + return narrow(orb.bind(id(), name, host, options), true); + } + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.StringReciever read(org.omg.CORBA.portable.InputStream _input) { + return com.netscape.jsdebugging.remote.corba.StringRecieverHelper.narrow(_input.read_Object(), true); + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.StringReciever value) { + _output.write_Object(value); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.StringReciever value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.StringReciever extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + _type = _orb().create_interface_tc(id(), "StringReciever"); + } + return _type; + } + public static java.lang.String id() { + return "IDL:StringReciever:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringRecieverHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringRecieverHolder.java new file mode 100644 index 00000000000..888c104fde8 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/StringRecieverHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class StringRecieverHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.StringReciever value; + public StringRecieverHolder() { + } + public StringRecieverHolder(com.netscape.jsdebugging.remote.corba.StringReciever value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = StringRecieverHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + StringRecieverHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return StringRecieverHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterface.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterface.java new file mode 100644 index 00000000000..21b2795371a --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterface.java @@ -0,0 +1,12 @@ +package com.netscape.jsdebugging.remote.corba; +public interface TestInterface extends org.omg.CORBA.Object { + public java.lang.String getFirstAppInList(); + public void getAppNames( + com.netscape.jsdebugging.remote.corba.StringReciever arg0 + ); + public com.netscape.jsdebugging.remote.corba.Thing[] getThings(); + public void callBounce( + com.netscape.jsdebugging.remote.corba.StringReciever arg0, + int arg1 + ); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfaceHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfaceHelper.java new file mode 100644 index 00000000000..7df32e8d91f --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfaceHelper.java @@ -0,0 +1,60 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class TestInterfaceHelper { + public static com.netscape.jsdebugging.remote.corba.TestInterface narrow(org.omg.CORBA.Object object) { + return narrow(object, false); + } + private static com.netscape.jsdebugging.remote.corba.TestInterface narrow(org.omg.CORBA.Object object, boolean is_a) { + if(object == null) { + return null; + } + if(object instanceof com.netscape.jsdebugging.remote.corba.TestInterface) { + return (com.netscape.jsdebugging.remote.corba.TestInterface) object; + } + if(is_a || object._is_a(id())) { + com.netscape.jsdebugging.remote.corba.TestInterface result = new com.netscape.jsdebugging.remote.corba._st_TestInterface(); + ((org.omg.CORBA.portable.ObjectImpl) result)._set_delegate + (((org.omg.CORBA.portable.ObjectImpl) object)._get_delegate()); + return result; + } + return null; + } + public static com.netscape.jsdebugging.remote.corba.TestInterface bind(org.omg.CORBA.ORB orb) { + return bind(orb, null, null, null); + } + public static com.netscape.jsdebugging.remote.corba.TestInterface bind(org.omg.CORBA.ORB orb, java.lang.String name) { + return bind(orb, name, null, null); + } + public static com.netscape.jsdebugging.remote.corba.TestInterface bind(org.omg.CORBA.ORB orb, java.lang.String name, java.lang.String host, org.omg.CORBA.BindOptions options) { + return narrow(orb.bind(id(), name, host, options), true); + } + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.TestInterface read(org.omg.CORBA.portable.InputStream _input) { + return com.netscape.jsdebugging.remote.corba.TestInterfaceHelper.narrow(_input.read_Object(), true); + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.TestInterface value) { + _output.write_Object(value); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.TestInterface value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.TestInterface extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + _type = _orb().create_interface_tc(id(), "TestInterface"); + } + return _type; + } + public static java.lang.String id() { + return "IDL:TestInterface:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfaceHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfaceHolder.java new file mode 100644 index 00000000000..317defc3a93 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfaceHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class TestInterfaceHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.TestInterface value; + public TestInterfaceHolder() { + } + public TestInterfaceHolder(com.netscape.jsdebugging.remote.corba.TestInterface value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = TestInterfaceHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + TestInterfaceHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return TestInterfaceHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfacePackage/sequence_of_ThingHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfacePackage/sequence_of_ThingHelper.java new file mode 100644 index 00000000000..5dfbc332e00 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfacePackage/sequence_of_ThingHelper.java @@ -0,0 +1,45 @@ + package com.netscape.jsdebugging.remote.corba.TestInterfacePackage; + abstract public class sequence_of_ThingHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.Thing[] read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.Thing[] result; + { + int _length4 = _input.read_long(); + result = new com.netscape.jsdebugging.remote.corba.Thing[_length4]; + for(int _i4 = 0; _i4 < _length4; _i4++) { + result[_i4] = com.netscape.jsdebugging.remote.corba.ThingHelper.read(_input); + } + } + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.Thing[] value) { + _output.write_long(value.length); + for(int _i3 = 0; _i3 < value.length; _i3++) { + com.netscape.jsdebugging.remote.corba.ThingHelper.write(_output, value[_i3]); + } + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.Thing[] value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.Thing[] extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.TypeCode original_type = _orb().create_sequence_tc(0, com.netscape.jsdebugging.remote.corba.ThingHelper.type()); + _type = _orb().create_alias_tc(id(), "sequence_of_Thing", original_type); + } + return _type; + } + public static java.lang.String id() { + return "IDL:TestInterface/sequence_of_Thing:1.0"; + } + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfacePackage/sequence_of_ThingHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfacePackage/sequence_of_ThingHolder.java new file mode 100644 index 00000000000..8579aff6b25 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/TestInterfacePackage/sequence_of_ThingHolder.java @@ -0,0 +1,18 @@ + package com.netscape.jsdebugging.remote.corba.TestInterfacePackage; + final public class sequence_of_ThingHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.Thing[] value; + public sequence_of_ThingHolder() { + } + public sequence_of_ThingHolder(com.netscape.jsdebugging.remote.corba.Thing[] value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = sequence_of_ThingHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + sequence_of_ThingHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return sequence_of_ThingHelper.type(); + } + } diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/Thing.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/Thing.java new file mode 100644 index 00000000000..2462794bef6 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/Thing.java @@ -0,0 +1,19 @@ +package com.netscape.jsdebugging.remote.corba; +final public class Thing { + public java.lang.String s; + public int i; + public Thing() { + } + public Thing( + java.lang.String s, + int i + ) { + this.s = s; + this.i = i; + } + public java.lang.String toString() { + org.omg.CORBA.Any any = org.omg.CORBA.ORB.init().create_any(); + com.netscape.jsdebugging.remote.corba.ThingHelper.insert(any, this); + return any.toString(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ThingHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ThingHelper.java new file mode 100644 index 00000000000..beefce42f52 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ThingHelper.java @@ -0,0 +1,40 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class ThingHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.Thing read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.Thing result = new com.netscape.jsdebugging.remote.corba.Thing(); + result.s = _input.read_string(); + result.i = _input.read_long(); + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.Thing value) { + _output.write_string(value.s); + _output.write_long(value.i); + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.Thing value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.Thing extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.StructMember[] members = new org.omg.CORBA.StructMember[2]; + members[0] = new org.omg.CORBA.StructMember("s", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_string), null); + members[1] = new org.omg.CORBA.StructMember("i", _orb().get_primitive_tc(org.omg.CORBA.TCKind.tk_long), null); + _type = _orb().create_struct_tc(id(), "Thing", members); + } + return _type; + } + public static java.lang.String id() { + return "IDL:Thing:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ThingHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ThingHolder.java new file mode 100644 index 00000000000..19a6c2c6ddf --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/ThingHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class ThingHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.Thing value; + public ThingHolder() { + } + public ThingHolder(com.netscape.jsdebugging.remote.corba.Thing value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = ThingHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + ThingHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return ThingHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IDebugController.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IDebugController.java new file mode 100644 index 00000000000..7afc779e828 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IDebugController.java @@ -0,0 +1,241 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class _sk_IDebugController extends org.omg.CORBA.portable.Skeleton implements com.netscape.jsdebugging.remote.corba.IDebugController { + protected _sk_IDebugController(java.lang.String name) { + super(name); + } + protected _sk_IDebugController() { + super(); + } + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:IDebugController:1.0" + }; + public org.omg.CORBA.portable.MethodPointer[] _methods() { + org.omg.CORBA.portable.MethodPointer[] methods = { + new org.omg.CORBA.portable.MethodPointer("getMajorVersion", 0, 0), + new org.omg.CORBA.portable.MethodPointer("getMinorVersion", 0, 1), + new org.omg.CORBA.portable.MethodPointer("setErrorReporter", 0, 2), + new org.omg.CORBA.portable.MethodPointer("getErrorReporter", 0, 3), + new org.omg.CORBA.portable.MethodPointer("setScriptHook", 0, 4), + new org.omg.CORBA.portable.MethodPointer("getScriptHook", 0, 5), + new org.omg.CORBA.portable.MethodPointer("getClosestPC", 0, 6), + new org.omg.CORBA.portable.MethodPointer("getSourceLocation", 0, 7), + new org.omg.CORBA.portable.MethodPointer("setInterruptHook", 0, 8), + new org.omg.CORBA.portable.MethodPointer("getInterruptHook", 0, 9), + new org.omg.CORBA.portable.MethodPointer("setDebugBreakHook", 0, 10), + new org.omg.CORBA.portable.MethodPointer("getDebugBreakHook", 0, 11), + new org.omg.CORBA.portable.MethodPointer("setInstructionHook", 0, 12), + new org.omg.CORBA.portable.MethodPointer("getInstructionHook", 0, 13), + new org.omg.CORBA.portable.MethodPointer("setThreadContinueState", 0, 14), + new org.omg.CORBA.portable.MethodPointer("setThreadReturnValue", 0, 15), + new org.omg.CORBA.portable.MethodPointer("sendInterrupt", 0, 16), + new org.omg.CORBA.portable.MethodPointer("sendInterruptStepInto", 0, 17), + new org.omg.CORBA.portable.MethodPointer("sendInterruptStepOver", 0, 18), + new org.omg.CORBA.portable.MethodPointer("sendInterruptStepOut", 0, 19), + new org.omg.CORBA.portable.MethodPointer("reinstateStepper", 0, 20), + new org.omg.CORBA.portable.MethodPointer("executeScriptInStackFrame", 0, 21), + new org.omg.CORBA.portable.MethodPointer("isRunningHook", 0, 22), + new org.omg.CORBA.portable.MethodPointer("isWaitingForResume", 0, 23), + new org.omg.CORBA.portable.MethodPointer("leaveThreadSuspended", 0, 24), + new org.omg.CORBA.portable.MethodPointer("resumeThread", 0, 25), + new org.omg.CORBA.portable.MethodPointer("iterateScripts", 0, 26), + }; + return methods; + } + public boolean _execute(org.omg.CORBA.portable.MethodPointer method, org.omg.CORBA.portable.InputStream input, org.omg.CORBA.portable.OutputStream output) { + switch(method.interface_id) { + case 0: { + return com.netscape.jsdebugging.remote.corba._sk_IDebugController._execute(this, method.method_id, input, output); + } + } + throw new org.omg.CORBA.MARSHAL(); + } + public static boolean _execute(com.netscape.jsdebugging.remote.corba.IDebugController _self, int _method_id, org.omg.CORBA.portable.InputStream _input, org.omg.CORBA.portable.OutputStream _output) { + switch(_method_id) { + case 0: { + int _result = _self.getMajorVersion(); + _output.write_long(_result); + return false; + } + case 1: { + int _result = _self.getMinorVersion(); + _output.write_long(_result); + return false; + } + case 2: { + com.netscape.jsdebugging.remote.corba.IJSErrorReporter arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IJSErrorReporterHelper.read(_input); + com.netscape.jsdebugging.remote.corba.IJSErrorReporter _result = _self.setErrorReporter(arg0); + com.netscape.jsdebugging.remote.corba.IJSErrorReporterHelper.write(_output, _result); + return false; + } + case 3: { + com.netscape.jsdebugging.remote.corba.IJSErrorReporter _result = _self.getErrorReporter(); + com.netscape.jsdebugging.remote.corba.IJSErrorReporterHelper.write(_output, _result); + return false; + } + case 4: { + com.netscape.jsdebugging.remote.corba.IScriptHook arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IScriptHookHelper.read(_input); + com.netscape.jsdebugging.remote.corba.IScriptHook _result = _self.setScriptHook(arg0); + com.netscape.jsdebugging.remote.corba.IScriptHookHelper.write(_output, _result); + return false; + } + case 5: { + com.netscape.jsdebugging.remote.corba.IScriptHook _result = _self.getScriptHook(); + com.netscape.jsdebugging.remote.corba.IScriptHookHelper.write(_output, _result); + return false; + } + case 6: { + com.netscape.jsdebugging.remote.corba.IScript arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IScriptHelper.read(_input); + int arg1; + arg1 = _input.read_long(); + com.netscape.jsdebugging.remote.corba.IJSPC _result = _self.getClosestPC(arg0,arg1); + com.netscape.jsdebugging.remote.corba.IJSPCHelper.write(_output, _result); + return false; + } + case 7: { + com.netscape.jsdebugging.remote.corba.IJSPC arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IJSPCHelper.read(_input); + com.netscape.jsdebugging.remote.corba.IJSSourceLocation _result = _self.getSourceLocation(arg0); + com.netscape.jsdebugging.remote.corba.IJSSourceLocationHelper.write(_output, _result); + return false; + } + case 8: { + com.netscape.jsdebugging.remote.corba.IJSExecutionHook arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.read(_input); + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result = _self.setInterruptHook(arg0); + com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.write(_output, _result); + return false; + } + case 9: { + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result = _self.getInterruptHook(); + com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.write(_output, _result); + return false; + } + case 10: { + com.netscape.jsdebugging.remote.corba.IJSExecutionHook arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.read(_input); + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result = _self.setDebugBreakHook(arg0); + com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.write(_output, _result); + return false; + } + case 11: { + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result = _self.getDebugBreakHook(); + com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.write(_output, _result); + return false; + } + case 12: { + com.netscape.jsdebugging.remote.corba.IJSExecutionHook arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.read(_input); + com.netscape.jsdebugging.remote.corba.IJSPC arg1; + arg1 = com.netscape.jsdebugging.remote.corba.IJSPCHelper.read(_input); + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result = _self.setInstructionHook(arg0,arg1); + com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.write(_output, _result); + return false; + } + case 13: { + com.netscape.jsdebugging.remote.corba.IJSPC arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IJSPCHelper.read(_input); + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result = _self.getInstructionHook(arg0); + com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.write(_output, _result); + return false; + } + case 14: { + int arg0; + arg0 = _input.read_long(); + int arg1; + arg1 = _input.read_long(); + _self.setThreadContinueState(arg0,arg1); + return false; + } + case 15: { + int arg0; + arg0 = _input.read_long(); + java.lang.String arg1; + arg1 = _input.read_string(); + _self.setThreadReturnValue(arg0,arg1); + return false; + } + case 16: { + _self.sendInterrupt(); + return false; + } + case 17: { + int arg0; + arg0 = _input.read_long(); + _self.sendInterruptStepInto(arg0); + return false; + } + case 18: { + int arg0; + arg0 = _input.read_long(); + _self.sendInterruptStepOver(arg0); + return false; + } + case 19: { + int arg0; + arg0 = _input.read_long(); + _self.sendInterruptStepOut(arg0); + return false; + } + case 20: { + int arg0; + arg0 = _input.read_long(); + _self.reinstateStepper(arg0); + return false; + } + case 21: { + int arg0; + arg0 = _input.read_long(); + com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo arg1; + arg1 = com.netscape.jsdebugging.remote.corba.IJSStackFrameInfoHelper.read(_input); + java.lang.String arg2; + arg2 = _input.read_string(); + java.lang.String arg3; + arg3 = _input.read_string(); + int arg4; + arg4 = _input.read_long(); + com.netscape.jsdebugging.remote.corba.IExecResult _result = _self.executeScriptInStackFrame(arg0,arg1,arg2,arg3,arg4); + com.netscape.jsdebugging.remote.corba.IExecResultHelper.write(_output, _result); + return false; + } + case 22: { + int arg0; + arg0 = _input.read_long(); + boolean _result = _self.isRunningHook(arg0); + _output.write_boolean(_result); + return false; + } + case 23: { + int arg0; + arg0 = _input.read_long(); + boolean _result = _self.isWaitingForResume(arg0); + _output.write_boolean(_result); + return false; + } + case 24: { + int arg0; + arg0 = _input.read_long(); + _self.leaveThreadSuspended(arg0); + return false; + } + case 25: { + int arg0; + arg0 = _input.read_long(); + _self.resumeThread(arg0); + return false; + } + case 26: { + com.netscape.jsdebugging.remote.corba.IScriptHook arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IScriptHookHelper.read(_input); + _self.iterateScripts(arg0); + return false; + } + } + throw new org.omg.CORBA.MARSHAL(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IJSErrorReporter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IJSErrorReporter.java new file mode 100644 index 00000000000..ea98cb77ec5 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IJSErrorReporter.java @@ -0,0 +1,49 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class _sk_IJSErrorReporter extends org.omg.CORBA.portable.Skeleton implements com.netscape.jsdebugging.remote.corba.IJSErrorReporter { + protected _sk_IJSErrorReporter(java.lang.String name) { + super(name); + } + protected _sk_IJSErrorReporter() { + super(); + } + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:IJSErrorReporter:1.0" + }; + public org.omg.CORBA.portable.MethodPointer[] _methods() { + org.omg.CORBA.portable.MethodPointer[] methods = { + new org.omg.CORBA.portable.MethodPointer("reportError", 0, 0), + }; + return methods; + } + public boolean _execute(org.omg.CORBA.portable.MethodPointer method, org.omg.CORBA.portable.InputStream input, org.omg.CORBA.portable.OutputStream output) { + switch(method.interface_id) { + case 0: { + return com.netscape.jsdebugging.remote.corba._sk_IJSErrorReporter._execute(this, method.method_id, input, output); + } + } + throw new org.omg.CORBA.MARSHAL(); + } + public static boolean _execute(com.netscape.jsdebugging.remote.corba.IJSErrorReporter _self, int _method_id, org.omg.CORBA.portable.InputStream _input, org.omg.CORBA.portable.OutputStream _output) { + switch(_method_id) { + case 0: { + java.lang.String arg0; + arg0 = _input.read_string(); + java.lang.String arg1; + arg1 = _input.read_string(); + int arg2; + arg2 = _input.read_long(); + java.lang.String arg3; + arg3 = _input.read_string(); + int arg4; + arg4 = _input.read_long(); + int _result = _self.reportError(arg0,arg1,arg2,arg3,arg4); + _output.write_long(_result); + return false; + } + } + throw new org.omg.CORBA.MARSHAL(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IJSExecutionHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IJSExecutionHook.java new file mode 100644 index 00000000000..4e279832cda --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IJSExecutionHook.java @@ -0,0 +1,42 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class _sk_IJSExecutionHook extends org.omg.CORBA.portable.Skeleton implements com.netscape.jsdebugging.remote.corba.IJSExecutionHook { + protected _sk_IJSExecutionHook(java.lang.String name) { + super(name); + } + protected _sk_IJSExecutionHook() { + super(); + } + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:IJSExecutionHook:1.0" + }; + public org.omg.CORBA.portable.MethodPointer[] _methods() { + org.omg.CORBA.portable.MethodPointer[] methods = { + new org.omg.CORBA.portable.MethodPointer("aboutToExecute", 0, 0), + }; + return methods; + } + public boolean _execute(org.omg.CORBA.portable.MethodPointer method, org.omg.CORBA.portable.InputStream input, org.omg.CORBA.portable.OutputStream output) { + switch(method.interface_id) { + case 0: { + return com.netscape.jsdebugging.remote.corba._sk_IJSExecutionHook._execute(this, method.method_id, input, output); + } + } + throw new org.omg.CORBA.MARSHAL(); + } + public static boolean _execute(com.netscape.jsdebugging.remote.corba.IJSExecutionHook _self, int _method_id, org.omg.CORBA.portable.InputStream _input, org.omg.CORBA.portable.OutputStream _output) { + switch(_method_id) { + case 0: { + com.netscape.jsdebugging.remote.corba.IJSThreadState arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IJSThreadStateHelper.read(_input); + com.netscape.jsdebugging.remote.corba.IJSPC arg1; + arg1 = com.netscape.jsdebugging.remote.corba.IJSPCHelper.read(_input); + _self.aboutToExecute(arg0,arg1); + return false; + } + } + throw new org.omg.CORBA.MARSHAL(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IScriptHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IScriptHook.java new file mode 100644 index 00000000000..0a482ed799d --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_IScriptHook.java @@ -0,0 +1,47 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class _sk_IScriptHook extends org.omg.CORBA.portable.Skeleton implements com.netscape.jsdebugging.remote.corba.IScriptHook { + protected _sk_IScriptHook(java.lang.String name) { + super(name); + } + protected _sk_IScriptHook() { + super(); + } + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:IScriptHook:1.0" + }; + public org.omg.CORBA.portable.MethodPointer[] _methods() { + org.omg.CORBA.portable.MethodPointer[] methods = { + new org.omg.CORBA.portable.MethodPointer("justLoadedScript", 0, 0), + new org.omg.CORBA.portable.MethodPointer("aboutToUnloadScript", 0, 1), + }; + return methods; + } + public boolean _execute(org.omg.CORBA.portable.MethodPointer method, org.omg.CORBA.portable.InputStream input, org.omg.CORBA.portable.OutputStream output) { + switch(method.interface_id) { + case 0: { + return com.netscape.jsdebugging.remote.corba._sk_IScriptHook._execute(this, method.method_id, input, output); + } + } + throw new org.omg.CORBA.MARSHAL(); + } + public static boolean _execute(com.netscape.jsdebugging.remote.corba.IScriptHook _self, int _method_id, org.omg.CORBA.portable.InputStream _input, org.omg.CORBA.portable.OutputStream _output) { + switch(_method_id) { + case 0: { + com.netscape.jsdebugging.remote.corba.IScript arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IScriptHelper.read(_input); + _self.justLoadedScript(arg0); + return false; + } + case 1: { + com.netscape.jsdebugging.remote.corba.IScript arg0; + arg0 = com.netscape.jsdebugging.remote.corba.IScriptHelper.read(_input); + _self.aboutToUnloadScript(arg0); + return false; + } + } + throw new org.omg.CORBA.MARSHAL(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_ISourceTextProvider.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_ISourceTextProvider.java new file mode 100644 index 00000000000..7e9ebc916c8 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_ISourceTextProvider.java @@ -0,0 +1,91 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class _sk_ISourceTextProvider extends org.omg.CORBA.portable.Skeleton implements com.netscape.jsdebugging.remote.corba.ISourceTextProvider { + protected _sk_ISourceTextProvider(java.lang.String name) { + super(name); + } + protected _sk_ISourceTextProvider() { + super(); + } + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:ISourceTextProvider:1.0" + }; + public org.omg.CORBA.portable.MethodPointer[] _methods() { + org.omg.CORBA.portable.MethodPointer[] methods = { + new org.omg.CORBA.portable.MethodPointer("getAllPages", 0, 0), + new org.omg.CORBA.portable.MethodPointer("refreshAllPages", 0, 1), + new org.omg.CORBA.portable.MethodPointer("hasPage", 0, 2), + new org.omg.CORBA.portable.MethodPointer("loadPage", 0, 3), + new org.omg.CORBA.portable.MethodPointer("refreshPage", 0, 4), + new org.omg.CORBA.portable.MethodPointer("getPageText", 0, 5), + new org.omg.CORBA.portable.MethodPointer("getPageStatus", 0, 6), + new org.omg.CORBA.portable.MethodPointer("getPageAlterCount", 0, 7), + }; + return methods; + } + public boolean _execute(org.omg.CORBA.portable.MethodPointer method, org.omg.CORBA.portable.InputStream input, org.omg.CORBA.portable.OutputStream output) { + switch(method.interface_id) { + case 0: { + return com.netscape.jsdebugging.remote.corba._sk_ISourceTextProvider._execute(this, method.method_id, input, output); + } + } + throw new org.omg.CORBA.MARSHAL(); + } + public static boolean _execute(com.netscape.jsdebugging.remote.corba.ISourceTextProvider _self, int _method_id, org.omg.CORBA.portable.InputStream _input, org.omg.CORBA.portable.OutputStream _output) { + switch(_method_id) { + case 0: { + java.lang.String[] _result = _self.getAllPages(); + com.netscape.jsdebugging.remote.corba.ISourceTextProviderPackage.sequence_of_stringHelper.write(_output, _result); + return false; + } + case 1: { + _self.refreshAllPages(); + return false; + } + case 2: { + java.lang.String arg0; + arg0 = _input.read_string(); + boolean _result = _self.hasPage(arg0); + _output.write_boolean(_result); + return false; + } + case 3: { + java.lang.String arg0; + arg0 = _input.read_string(); + boolean _result = _self.loadPage(arg0); + _output.write_boolean(_result); + return false; + } + case 4: { + java.lang.String arg0; + arg0 = _input.read_string(); + _self.refreshPage(arg0); + return false; + } + case 5: { + java.lang.String arg0; + arg0 = _input.read_string(); + java.lang.String _result = _self.getPageText(arg0); + _output.write_string(_result); + return false; + } + case 6: { + java.lang.String arg0; + arg0 = _input.read_string(); + int _result = _self.getPageStatus(arg0); + _output.write_long(_result); + return false; + } + case 7: { + java.lang.String arg0; + arg0 = _input.read_string(); + int _result = _self.getPageAlterCount(arg0); + _output.write_long(_result); + return false; + } + } + throw new org.omg.CORBA.MARSHAL(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_StringReciever.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_StringReciever.java new file mode 100644 index 00000000000..14aa435e2e9 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_StringReciever.java @@ -0,0 +1,47 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class _sk_StringReciever extends org.omg.CORBA.portable.Skeleton implements com.netscape.jsdebugging.remote.corba.StringReciever { + protected _sk_StringReciever(java.lang.String name) { + super(name); + } + protected _sk_StringReciever() { + super(); + } + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:StringReciever:1.0" + }; + public org.omg.CORBA.portable.MethodPointer[] _methods() { + org.omg.CORBA.portable.MethodPointer[] methods = { + new org.omg.CORBA.portable.MethodPointer("recieveString", 0, 0), + new org.omg.CORBA.portable.MethodPointer("bounce", 0, 1), + }; + return methods; + } + public boolean _execute(org.omg.CORBA.portable.MethodPointer method, org.omg.CORBA.portable.InputStream input, org.omg.CORBA.portable.OutputStream output) { + switch(method.interface_id) { + case 0: { + return com.netscape.jsdebugging.remote.corba._sk_StringReciever._execute(this, method.method_id, input, output); + } + } + throw new org.omg.CORBA.MARSHAL(); + } + public static boolean _execute(com.netscape.jsdebugging.remote.corba.StringReciever _self, int _method_id, org.omg.CORBA.portable.InputStream _input, org.omg.CORBA.portable.OutputStream _output) { + switch(_method_id) { + case 0: { + java.lang.String arg0; + arg0 = _input.read_string(); + _self.recieveString(arg0); + return false; + } + case 1: { + int arg0; + arg0 = _input.read_long(); + _self.bounce(arg0); + return false; + } + } + throw new org.omg.CORBA.MARSHAL(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_TestInterface.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_TestInterface.java new file mode 100644 index 00000000000..f94030c3abf --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_sk_TestInterface.java @@ -0,0 +1,61 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class _sk_TestInterface extends org.omg.CORBA.portable.Skeleton implements com.netscape.jsdebugging.remote.corba.TestInterface { + protected _sk_TestInterface(java.lang.String name) { + super(name); + } + protected _sk_TestInterface() { + super(); + } + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:TestInterface:1.0" + }; + public org.omg.CORBA.portable.MethodPointer[] _methods() { + org.omg.CORBA.portable.MethodPointer[] methods = { + new org.omg.CORBA.portable.MethodPointer("getFirstAppInList", 0, 0), + new org.omg.CORBA.portable.MethodPointer("getAppNames", 0, 1), + new org.omg.CORBA.portable.MethodPointer("getThings", 0, 2), + new org.omg.CORBA.portable.MethodPointer("callBounce", 0, 3), + }; + return methods; + } + public boolean _execute(org.omg.CORBA.portable.MethodPointer method, org.omg.CORBA.portable.InputStream input, org.omg.CORBA.portable.OutputStream output) { + switch(method.interface_id) { + case 0: { + return com.netscape.jsdebugging.remote.corba._sk_TestInterface._execute(this, method.method_id, input, output); + } + } + throw new org.omg.CORBA.MARSHAL(); + } + public static boolean _execute(com.netscape.jsdebugging.remote.corba.TestInterface _self, int _method_id, org.omg.CORBA.portable.InputStream _input, org.omg.CORBA.portable.OutputStream _output) { + switch(_method_id) { + case 0: { + java.lang.String _result = _self.getFirstAppInList(); + _output.write_string(_result); + return false; + } + case 1: { + com.netscape.jsdebugging.remote.corba.StringReciever arg0; + arg0 = com.netscape.jsdebugging.remote.corba.StringRecieverHelper.read(_input); + _self.getAppNames(arg0); + return false; + } + case 2: { + com.netscape.jsdebugging.remote.corba.Thing[] _result = _self.getThings(); + com.netscape.jsdebugging.remote.corba.TestInterfacePackage.sequence_of_ThingHelper.write(_output, _result); + return false; + } + case 3: { + com.netscape.jsdebugging.remote.corba.StringReciever arg0; + arg0 = com.netscape.jsdebugging.remote.corba.StringRecieverHelper.read(_input); + int arg1; + arg1 = _input.read_long(); + _self.callBounce(arg0,arg1); + return false; + } + } + throw new org.omg.CORBA.MARSHAL(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IDebugController.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IDebugController.java new file mode 100644 index 00000000000..93f11463a65 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IDebugController.java @@ -0,0 +1,427 @@ +package com.netscape.jsdebugging.remote.corba; +public class _st_IDebugController extends org.omg.CORBA.portable.ObjectImpl implements com.netscape.jsdebugging.remote.corba.IDebugController { + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:IDebugController:1.0" + }; + public int getMajorVersion() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getMajorVersion", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + int _result; + _result = _input.read_long(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getMajorVersion(); + } + } + public int getMinorVersion() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getMinorVersion", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + int _result; + _result = _input.read_long(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getMinorVersion(); + } + } + public com.netscape.jsdebugging.remote.corba.IJSErrorReporter setErrorReporter( + com.netscape.jsdebugging.remote.corba.IJSErrorReporter arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("setErrorReporter", true); + com.netscape.jsdebugging.remote.corba.IJSErrorReporterHelper.write(_output, arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IJSErrorReporter _result; + _result = com.netscape.jsdebugging.remote.corba.IJSErrorReporterHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return setErrorReporter( + arg0 + ); + } + } + public com.netscape.jsdebugging.remote.corba.IJSErrorReporter getErrorReporter() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getErrorReporter", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IJSErrorReporter _result; + _result = com.netscape.jsdebugging.remote.corba.IJSErrorReporterHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getErrorReporter(); + } + } + public com.netscape.jsdebugging.remote.corba.IScriptHook setScriptHook( + com.netscape.jsdebugging.remote.corba.IScriptHook arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("setScriptHook", true); + com.netscape.jsdebugging.remote.corba.IScriptHookHelper.write(_output, arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IScriptHook _result; + _result = com.netscape.jsdebugging.remote.corba.IScriptHookHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return setScriptHook( + arg0 + ); + } + } + public com.netscape.jsdebugging.remote.corba.IScriptHook getScriptHook() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getScriptHook", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IScriptHook _result; + _result = com.netscape.jsdebugging.remote.corba.IScriptHookHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getScriptHook(); + } + } + public com.netscape.jsdebugging.remote.corba.IJSPC getClosestPC( + com.netscape.jsdebugging.remote.corba.IScript arg0, + int arg1 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getClosestPC", true); + com.netscape.jsdebugging.remote.corba.IScriptHelper.write(_output, arg0); + _output.write_long(arg1); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IJSPC _result; + _result = com.netscape.jsdebugging.remote.corba.IJSPCHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getClosestPC( + arg0, + arg1 + ); + } + } + public com.netscape.jsdebugging.remote.corba.IJSSourceLocation getSourceLocation( + com.netscape.jsdebugging.remote.corba.IJSPC arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getSourceLocation", true); + com.netscape.jsdebugging.remote.corba.IJSPCHelper.write(_output, arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IJSSourceLocation _result; + _result = com.netscape.jsdebugging.remote.corba.IJSSourceLocationHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getSourceLocation( + arg0 + ); + } + } + public com.netscape.jsdebugging.remote.corba.IJSExecutionHook setInterruptHook( + com.netscape.jsdebugging.remote.corba.IJSExecutionHook arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("setInterruptHook", true); + com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.write(_output, arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result; + _result = com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return setInterruptHook( + arg0 + ); + } + } + public com.netscape.jsdebugging.remote.corba.IJSExecutionHook getInterruptHook() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getInterruptHook", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result; + _result = com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getInterruptHook(); + } + } + public com.netscape.jsdebugging.remote.corba.IJSExecutionHook setDebugBreakHook( + com.netscape.jsdebugging.remote.corba.IJSExecutionHook arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("setDebugBreakHook", true); + com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.write(_output, arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result; + _result = com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return setDebugBreakHook( + arg0 + ); + } + } + public com.netscape.jsdebugging.remote.corba.IJSExecutionHook getDebugBreakHook() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getDebugBreakHook", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result; + _result = com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getDebugBreakHook(); + } + } + public com.netscape.jsdebugging.remote.corba.IJSExecutionHook setInstructionHook( + com.netscape.jsdebugging.remote.corba.IJSExecutionHook arg0, + com.netscape.jsdebugging.remote.corba.IJSPC arg1 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("setInstructionHook", true); + com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.write(_output, arg0); + com.netscape.jsdebugging.remote.corba.IJSPCHelper.write(_output, arg1); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result; + _result = com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return setInstructionHook( + arg0, + arg1 + ); + } + } + public com.netscape.jsdebugging.remote.corba.IJSExecutionHook getInstructionHook( + com.netscape.jsdebugging.remote.corba.IJSPC arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getInstructionHook", true); + com.netscape.jsdebugging.remote.corba.IJSPCHelper.write(_output, arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IJSExecutionHook _result; + _result = com.netscape.jsdebugging.remote.corba.IJSExecutionHookHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getInstructionHook( + arg0 + ); + } + } + public void setThreadContinueState( + int arg0, + int arg1 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("setThreadContinueState", true); + _output.write_long(arg0); + _output.write_long(arg1); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + setThreadContinueState( + arg0, + arg1 + ); + } + } + public void setThreadReturnValue( + int arg0, + java.lang.String arg1 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("setThreadReturnValue", true); + _output.write_long(arg0); + _output.write_string(arg1); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + setThreadReturnValue( + arg0, + arg1 + ); + } + } + public void sendInterrupt() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("sendInterrupt", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + sendInterrupt(); + } + } + public void sendInterruptStepInto( + int arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("sendInterruptStepInto", true); + _output.write_long(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + sendInterruptStepInto( + arg0 + ); + } + } + public void sendInterruptStepOver( + int arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("sendInterruptStepOver", true); + _output.write_long(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + sendInterruptStepOver( + arg0 + ); + } + } + public void sendInterruptStepOut( + int arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("sendInterruptStepOut", true); + _output.write_long(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + sendInterruptStepOut( + arg0 + ); + } + } + public void reinstateStepper( + int arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("reinstateStepper", true); + _output.write_long(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + reinstateStepper( + arg0 + ); + } + } + public com.netscape.jsdebugging.remote.corba.IExecResult executeScriptInStackFrame( + int arg0, + com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo arg1, + java.lang.String arg2, + java.lang.String arg3, + int arg4 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("executeScriptInStackFrame", true); + _output.write_long(arg0); + com.netscape.jsdebugging.remote.corba.IJSStackFrameInfoHelper.write(_output, arg1); + _output.write_string(arg2); + _output.write_string(arg3); + _output.write_long(arg4); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.IExecResult _result; + _result = com.netscape.jsdebugging.remote.corba.IExecResultHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return executeScriptInStackFrame( + arg0, + arg1, + arg2, + arg3, + arg4 + ); + } + } + public boolean isRunningHook( + int arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("isRunningHook", true); + _output.write_long(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + boolean _result; + _result = _input.read_boolean(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return isRunningHook( + arg0 + ); + } + } + public boolean isWaitingForResume( + int arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("isWaitingForResume", true); + _output.write_long(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + boolean _result; + _result = _input.read_boolean(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return isWaitingForResume( + arg0 + ); + } + } + public void leaveThreadSuspended( + int arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("leaveThreadSuspended", true); + _output.write_long(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + leaveThreadSuspended( + arg0 + ); + } + } + public void resumeThread( + int arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("resumeThread", true); + _output.write_long(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + resumeThread( + arg0 + ); + } + } + public void iterateScripts( + com.netscape.jsdebugging.remote.corba.IScriptHook arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("iterateScripts", true); + com.netscape.jsdebugging.remote.corba.IScriptHookHelper.write(_output, arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + iterateScripts( + arg0 + ); + } + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IJSErrorReporter.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IJSErrorReporter.java new file mode 100644 index 00000000000..746beb1cd78 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IJSErrorReporter.java @@ -0,0 +1,38 @@ +package com.netscape.jsdebugging.remote.corba; +public class _st_IJSErrorReporter extends org.omg.CORBA.portable.ObjectImpl implements com.netscape.jsdebugging.remote.corba.IJSErrorReporter { + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:IJSErrorReporter:1.0" + }; + public int reportError( + java.lang.String arg0, + java.lang.String arg1, + int arg2, + java.lang.String arg3, + int arg4 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("reportError", true); + _output.write_string(arg0); + _output.write_string(arg1); + _output.write_long(arg2); + _output.write_string(arg3); + _output.write_long(arg4); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + int _result; + _result = _input.read_long(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return reportError( + arg0, + arg1, + arg2, + arg3, + arg4 + ); + } + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IJSExecutionHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IJSExecutionHook.java new file mode 100644 index 00000000000..c608f3b788b --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IJSExecutionHook.java @@ -0,0 +1,26 @@ +package com.netscape.jsdebugging.remote.corba; +public class _st_IJSExecutionHook extends org.omg.CORBA.portable.ObjectImpl implements com.netscape.jsdebugging.remote.corba.IJSExecutionHook { + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:IJSExecutionHook:1.0" + }; + public void aboutToExecute( + com.netscape.jsdebugging.remote.corba.IJSThreadState arg0, + com.netscape.jsdebugging.remote.corba.IJSPC arg1 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("aboutToExecute", true); + com.netscape.jsdebugging.remote.corba.IJSThreadStateHelper.write(_output, arg0); + com.netscape.jsdebugging.remote.corba.IJSPCHelper.write(_output, arg1); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + aboutToExecute( + arg0, + arg1 + ); + } + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IScriptHook.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IScriptHook.java new file mode 100644 index 00000000000..5f98238058d --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_IScriptHook.java @@ -0,0 +1,37 @@ +package com.netscape.jsdebugging.remote.corba; +public class _st_IScriptHook extends org.omg.CORBA.portable.ObjectImpl implements com.netscape.jsdebugging.remote.corba.IScriptHook { + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:IScriptHook:1.0" + }; + public void justLoadedScript( + com.netscape.jsdebugging.remote.corba.IScript arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("justLoadedScript", true); + com.netscape.jsdebugging.remote.corba.IScriptHelper.write(_output, arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + justLoadedScript( + arg0 + ); + } + } + public void aboutToUnloadScript( + com.netscape.jsdebugging.remote.corba.IScript arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("aboutToUnloadScript", true); + com.netscape.jsdebugging.remote.corba.IScriptHelper.write(_output, arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + aboutToUnloadScript( + arg0 + ); + } + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_ISourceTextProvider.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_ISourceTextProvider.java new file mode 100644 index 00000000000..2cf64968eea --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_ISourceTextProvider.java @@ -0,0 +1,129 @@ +package com.netscape.jsdebugging.remote.corba; +public class _st_ISourceTextProvider extends org.omg.CORBA.portable.ObjectImpl implements com.netscape.jsdebugging.remote.corba.ISourceTextProvider { + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:ISourceTextProvider:1.0" + }; + public java.lang.String[] getAllPages() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getAllPages", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + java.lang.String[] _result; + _result = com.netscape.jsdebugging.remote.corba.ISourceTextProviderPackage.sequence_of_stringHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getAllPages(); + } + } + public void refreshAllPages() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("refreshAllPages", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + refreshAllPages(); + } + } + public boolean hasPage( + java.lang.String arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("hasPage", true); + _output.write_string(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + boolean _result; + _result = _input.read_boolean(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return hasPage( + arg0 + ); + } + } + public boolean loadPage( + java.lang.String arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("loadPage", true); + _output.write_string(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + boolean _result; + _result = _input.read_boolean(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return loadPage( + arg0 + ); + } + } + public void refreshPage( + java.lang.String arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("refreshPage", true); + _output.write_string(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + refreshPage( + arg0 + ); + } + } + public java.lang.String getPageText( + java.lang.String arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getPageText", true); + _output.write_string(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + java.lang.String _result; + _result = _input.read_string(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getPageText( + arg0 + ); + } + } + public int getPageStatus( + java.lang.String arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getPageStatus", true); + _output.write_string(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + int _result; + _result = _input.read_long(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getPageStatus( + arg0 + ); + } + } + public int getPageAlterCount( + java.lang.String arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getPageAlterCount", true); + _output.write_string(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + int _result; + _result = _input.read_long(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getPageAlterCount( + arg0 + ); + } + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_StringReciever.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_StringReciever.java new file mode 100644 index 00000000000..1419b74b3e1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_StringReciever.java @@ -0,0 +1,37 @@ +package com.netscape.jsdebugging.remote.corba; +public class _st_StringReciever extends org.omg.CORBA.portable.ObjectImpl implements com.netscape.jsdebugging.remote.corba.StringReciever { + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:StringReciever:1.0" + }; + public void recieveString( + java.lang.String arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("recieveString", true); + _output.write_string(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + recieveString( + arg0 + ); + } + } + public void bounce( + int arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("bounce", true); + _output.write_long(arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + bounce( + arg0 + ); + } + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_TestInterface.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_TestInterface.java new file mode 100644 index 00000000000..d0bf35323db --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/_st_TestInterface.java @@ -0,0 +1,64 @@ +package com.netscape.jsdebugging.remote.corba; +public class _st_TestInterface extends org.omg.CORBA.portable.ObjectImpl implements com.netscape.jsdebugging.remote.corba.TestInterface { + public java.lang.String[] _ids() { + return __ids; + } + private static java.lang.String[] __ids = { + "IDL:TestInterface:1.0" + }; + public java.lang.String getFirstAppInList() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getFirstAppInList", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + java.lang.String _result; + _result = _input.read_string(); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getFirstAppInList(); + } + } + public void getAppNames( + com.netscape.jsdebugging.remote.corba.StringReciever arg0 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getAppNames", true); + com.netscape.jsdebugging.remote.corba.StringRecieverHelper.write(_output, arg0); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + getAppNames( + arg0 + ); + } + } + public com.netscape.jsdebugging.remote.corba.Thing[] getThings() { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("getThings", true); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + com.netscape.jsdebugging.remote.corba.Thing[] _result; + _result = com.netscape.jsdebugging.remote.corba.TestInterfacePackage.sequence_of_ThingHelper.read(_input); + return _result; + } + catch(org.omg.CORBA.TRANSIENT _exception) { + return getThings(); + } + } + public void callBounce( + com.netscape.jsdebugging.remote.corba.StringReciever arg0, + int arg1 + ) { + try { + org.omg.CORBA.portable.OutputStream _output = this._request("callBounce", true); + com.netscape.jsdebugging.remote.corba.StringRecieverHelper.write(_output, arg0); + _output.write_long(arg1); + org.omg.CORBA.portable.InputStream _input = this._invoke(_output, null); + } + catch(org.omg.CORBA.TRANSIENT _exception) { + callBounce( + arg0, + arg1 + ); + } + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IJSStackFrameInfoHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IJSStackFrameInfoHelper.java new file mode 100644 index 00000000000..826f5e36211 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IJSStackFrameInfoHelper.java @@ -0,0 +1,45 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class sequence_of_IJSStackFrameInfoHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo[] read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo[] result; + { + int _length3 = _input.read_long(); + result = new com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo[_length3]; + for(int _i3 = 0; _i3 < _length3; _i3++) { + result[_i3] = com.netscape.jsdebugging.remote.corba.IJSStackFrameInfoHelper.read(_input); + } + } + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo[] value) { + _output.write_long(value.length); + for(int _i2 = 0; _i2 < value.length; _i2++) { + com.netscape.jsdebugging.remote.corba.IJSStackFrameInfoHelper.write(_output, value[_i2]); + } + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo[] value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo[] extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.TypeCode original_type = _orb().create_sequence_tc(0, com.netscape.jsdebugging.remote.corba.IJSStackFrameInfoHelper.type()); + _type = _orb().create_alias_tc(id(), "sequence_of_IJSStackFrameInfo", original_type); + } + return _type; + } + public static java.lang.String id() { + return "IDL:sequence_of_IJSStackFrameInfo:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IJSStackFrameInfoHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IJSStackFrameInfoHolder.java new file mode 100644 index 00000000000..b26defc2bf1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IJSStackFrameInfoHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class sequence_of_IJSStackFrameInfoHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo[] value; + public sequence_of_IJSStackFrameInfoHolder() { + } + public sequence_of_IJSStackFrameInfoHolder(com.netscape.jsdebugging.remote.corba.IJSStackFrameInfo[] value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = sequence_of_IJSStackFrameInfoHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + sequence_of_IJSStackFrameInfoHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return sequence_of_IJSStackFrameInfoHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IScriptSectionHelper.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IScriptSectionHelper.java new file mode 100644 index 00000000000..f013f560d81 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IScriptSectionHelper.java @@ -0,0 +1,45 @@ +package com.netscape.jsdebugging.remote.corba; +abstract public class sequence_of_IScriptSectionHelper { + private static org.omg.CORBA.ORB _orb() { + return org.omg.CORBA.ORB.init(); + } + public static com.netscape.jsdebugging.remote.corba.IScriptSection[] read(org.omg.CORBA.portable.InputStream _input) { + com.netscape.jsdebugging.remote.corba.IScriptSection[] result; + { + int _length3 = _input.read_long(); + result = new com.netscape.jsdebugging.remote.corba.IScriptSection[_length3]; + for(int _i3 = 0; _i3 < _length3; _i3++) { + result[_i3] = com.netscape.jsdebugging.remote.corba.IScriptSectionHelper.read(_input); + } + } + return result; + } + public static void write(org.omg.CORBA.portable.OutputStream _output, com.netscape.jsdebugging.remote.corba.IScriptSection[] value) { + _output.write_long(value.length); + for(int _i2 = 0; _i2 < value.length; _i2++) { + com.netscape.jsdebugging.remote.corba.IScriptSectionHelper.write(_output, value[_i2]); + } + } + public static void insert(org.omg.CORBA.Any any, com.netscape.jsdebugging.remote.corba.IScriptSection[] value) { + org.omg.CORBA.portable.OutputStream output = any.create_output_stream(); + write(output, value); + any.read_value(output.create_input_stream(), type()); + } + public static com.netscape.jsdebugging.remote.corba.IScriptSection[] extract(org.omg.CORBA.Any any) { + if(!any.type().equal(type())) { + throw new org.omg.CORBA.BAD_TYPECODE(); + } + return read(any.create_input_stream()); + } + private static org.omg.CORBA.TypeCode _type; + public static org.omg.CORBA.TypeCode type() { + if(_type == null) { + org.omg.CORBA.TypeCode original_type = _orb().create_sequence_tc(0, com.netscape.jsdebugging.remote.corba.IScriptSectionHelper.type()); + _type = _orb().create_alias_tc(id(), "sequence_of_IScriptSection", original_type); + } + return _type; + } + public static java.lang.String id() { + return "IDL:sequence_of_IScriptSection:1.0"; + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IScriptSectionHolder.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IScriptSectionHolder.java new file mode 100644 index 00000000000..582ee6026ac --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/remote/corba/sequence_of_IScriptSectionHolder.java @@ -0,0 +1,18 @@ +package com.netscape.jsdebugging.remote.corba; +final public class sequence_of_IScriptSectionHolder implements org.omg.CORBA.portable.Streamable { + public com.netscape.jsdebugging.remote.corba.IScriptSection[] value; + public sequence_of_IScriptSectionHolder() { + } + public sequence_of_IScriptSectionHolder(com.netscape.jsdebugging.remote.corba.IScriptSection[] value) { + this.value = value; + } + public void _read(org.omg.CORBA.portable.InputStream input) { + value = sequence_of_IScriptSectionHelper.read(input); + } + public void _write(org.omg.CORBA.portable.OutputStream output) { + sequence_of_IScriptSectionHelper.write(output, value); + } + public org.omg.CORBA.TypeCode _type() { + return sequence_of_IScriptSectionHelper.type(); + } +} diff --git a/mozilla/js/jsdj/classes/com/netscape/jsdebugging/tools/depend/Main.java b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/tools/depend/Main.java new file mode 100644 index 00000000000..b968afd6740 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/jsdebugging/tools/depend/Main.java @@ -0,0 +1,704 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* + * This program can read a set of classfiles and display the dependcies of + * those classfiles on other classfiles. It can optionally take lists of + * independent classfiles to ignore. It will return a value -1 on error or + * the count of unexpected dependencies (zero if none). + * + * This is based on code hacked out of netscape.tools.DumpClass + * + * jband - 09/06/98 + */ + +package com.netscape.jsdebugging.tools.depend; + +import java.util.Hashtable; +import java.util.Enumeration; +import java.util.Vector; + +import java.io.File; +import java.io.InputStream; +import java.io.FileInputStream; +import java.io.DataInputStream; +import java.io.IOException; +import java.io.FilenameFilter; +import java.io.PrintStream; + +class Main { + public static void main(String[] argv) { + new Main().go(argv); + } + + Main() { + _classinfos = new Hashtable(); + _inputClasses = new Vector(); + _ignoreStrings= new Vector(); + } + + void usage() { + + System.out.println("usage: Main [-a] [-i string] name [more_names...]"); + System.out.println(" -a means \'all\'"); + System.out.println(" -i means \'ignore\'"); + System.out.println("example:"); + System.out.println(" Main -i java/io -i java/lang *.class foo/*"); + } + + void go(String[] argv) { + int retval = 0; + if (argv.length < 1) { + usage(); + System.exit(-1); + return; + } + try { + parseCommandline(argv); + + for(int i = 0; i < _inputClasses.size(); i++) { +// System.out.println(_inputClasses.elementAt(i)); + readClass((String)_inputClasses.elementAt(i)); + } + + Enumeration e = getAllClassInfos(); + Vector dep = new Vector(); + + int i; + int size; + + +next_el: while(e.hasMoreElements()) { + ClassInfo info = (ClassInfo) e.nextElement(); + String name = info._name; + + if(!_all) { + // remove input classnames + size = _inputClasses.size(); + for(i = 0; i < size; i++) { + String cur = (String) _inputClasses.elementAt(i); + if(name.equals(cur)) + continue next_el; + } + // remove explicit ignore classnames + size = _ignoreStrings.size(); + for(i = 0; i < size; i++) { + String cur = (String) _ignoreStrings.elementAt(i); + if(name.startsWith(cur)) + continue next_el; + } + } + + // slow insertion sort... + size = dep.size(); + for(i = 0; i < size; i++) { + ClassInfo cur = (ClassInfo) dep.elementAt(i); + if( 0 > name.compareTo(cur._name)) { + dep.insertElementAt(info,i); + break; + } + } + if(i == size) + dep.addElement(info); + retval++ ; + } + + size = dep.size(); + for(i = 0; i < size; i++) { + ClassInfo cur = (ClassInfo) dep.elementAt(i); + System.out.println(cur._name); + } + + } catch (Throwable t) { + System.err.println("### Problem in depend: "); + t.printStackTrace(); + System.exit(-1); + } + System.exit(retval); + } + + String backToSlash(String name) { + if(-1 == name.indexOf('\\')) + return name; + return name.replace('\\', '/'); + } + + void parseCommandline(String[] argv) throws Exception { + for(int i = 0; i < argv.length; i++) { + String arg = argv[i]; + if("-a".equals(arg)) + _all = true; + else if("-i".equals(arg)) { + if(++i == argv.length) + throw new Exception("-i flag not followed by class or package"); + _ignoreStrings.addElement(backToSlash(argv[i])); + } + else + addInputClass(backToSlash(arg)); + } + } + + void addInputClass(String str) { + String tmp = new String(str).toLowerCase(); + if(tmp.endsWith(".class")) + str = str.substring(0, str.length()-6); + + if(str.endsWith("*")) + addWildCardsToInputClassesList(str.substring(0, str.length()-1)); + else + _inputClasses.addElement(str); + } + + void addWildCardsToInputClassesList(String str) { + String pkg = new String(str); + if(0 == str.length()) + str = "."; + + String[] files = new File(str).list(new ClassnameFileFilter()); + int len; + if(null != files && 0 != (len = files.length)) + for(int i = 0; i < len; i++) { + String str1 = files[i]; + str1 = str1.substring(0, str1.length()-6); + _inputClasses.addElement(pkg+str1); + } + } + + void readClass(String filename) throws Exception { + int i; + int len; + ClassReader cr = new ClassReader(filename+".class"); + cr.read(); + ClassInfo info = getClassInfo(cr.getName()); + + info._super = getClassInfo(cr.getSuperName()); + + String[] interfaceNames = cr.getInterfaces(); + if(null != interfaceNames && 0 != (len = interfaceNames.length)) { + info._interfaces = new ClassInfo[len]; + for(i = 0; i < len; i++) + info._interfaces[i] = getClassInfo(interfaceNames[i]); + } + + String[] usesNames = cr.getUses(); + if(null != usesNames && 0 != (len = usesNames.length)) { + info._uses = new ClassInfo[len]; + for(i = 0; i < len; i++) + info._uses[i] = getClassInfo(usesNames[i]); + } + + info._read = true; + } + + ClassInfo getClassInfo(String name) { + ClassInfo info; + info = (ClassInfo) _classinfos.get(name); + if(null == info) { + info = new ClassInfo(name); + _classinfos.put(name, info); + } + return info; + } + + Enumeration getAllClassInfos() { + return _classinfos.elements(); + } + + Hashtable _classinfos; + Vector _inputClasses; + Vector _ignoreStrings; + boolean _all; +} + +class ClassInfo { + ClassInfo(String name) {_name = name;} + String _name; + ClassInfo _super; + ClassInfo[] _interfaces; + ClassInfo[] _uses; + boolean _read; +} + +class ClassReader { + static final int MAGIC = 0xCAFEBABE; + static final int MAJOR_VERSION = 45; + static final int MINOR_VERSION = 3; + + // access_flags + static final int ACC_PUBLIC = 0x0001; + static final int ACC_PRIVATE = 0x0002; + static final int ACC_PROTECTED = 0x0004; + static final int ACC_STATIC = 0x0008; + static final int ACC_FINAL = 0x0010; + static final int ACC_SYNCHRONIZED = 0x0020; + static final int ACC_THREADSAFE = 0x0040; + static final int ACC_TRANSIENT = 0x0080; + static final int ACC_NATIVE = 0x0100; + static final int ACC_INTERFACE = 0x0200; + static final int ACC_ABSTRACT = 0x0400; + + // constant types + static final int CONSTANT_Class = 7; + static final int CONSTANT_Fieldref = 9; + static final int CONSTANT_Methodref = 10; + static final int CONSTANT_String = 8; + static final int CONSTANT_Integer = 3; + static final int CONSTANT_Float = 4; + static final int CONSTANT_Long = 5; + static final int CONSTANT_Double = 6; + static final int CONSTANT_InterfaceMethodref= 11; + static final int CONSTANT_NameAndType = 12; + static final int CONSTANT_Asciz = 1; + + + ClassReader(String filename) { + _filename = filename; + _usesTable = new Hashtable(); + _classNames = new Vector(); + } + + void read() throws Exception { + LoggingInputStream s = new LoggingInputStream(new FileInputStream(_filename)); + + int magic = s.readInt("magic number"); + if (magic != MAGIC) + throw new Exception("The file " + _filename + " isn't a Java .class file."); + + int minorVersion = s.readShort("minorVersion"); + int majorVersion = s.readShort("majorVersion"); + if (majorVersion != MAJOR_VERSION || minorVersion != MINOR_VERSION) + throw new Exception("The file " + _filename + + " has the wrong version (" + + majorVersion + "." + minorVersion + + " rather than " + + MAJOR_VERSION + "." + MINOR_VERSION + ")"); + + short constant_pool_count = s.readShort("constant_pool_count"); + cpool = new Object[constant_pool_count]; + + // suck in the constant pool for future use + for (int i = 1; i < constant_pool_count; i++) { // constant_pool[0] always unused + byte type = s.readByte("constant pool [" + i + "] item type"); + switch (type) { + case CONSTANT_Class: { + short name_index = s.readShort("Class name_index"); + cpool[i] = new ClassStruct(name_index); + _classNames.addElement(new Integer(name_index)); + break; + } + case CONSTANT_Fieldref: { + short class_index = s.readShort("Fieldref class_index"); + short name_and_type_index = s.readShort("Fieldref name_and_type_index"); + cpool[i] = new FieldrefStruct(class_index, name_and_type_index); + break; + } + case CONSTANT_Methodref: { + short class_index = s.readShort("Methodref class_index"); + short name_and_type_index = s.readShort("Methodref name_and_type_index"); + cpool[i] = new MethodrefStruct(class_index, name_and_type_index); + break; + } + case CONSTANT_InterfaceMethodref: { + short class_index = s.readShort("InterfaceMethodref class_index"); + short name_and_type_index = s.readShort("InterfaceMethodref name_and_type_index"); + cpool[i] = new InterfaceMethodrefStruct(class_index, name_and_type_index); + break; + } + case CONSTANT_String: { + short string_index = s.readShort("String string_index"); + cpool[i] = new StringStruct(string_index); + break; + } + case CONSTANT_Integer: { + int value = s.readInt("Integer value"); + cpool[i] = new Integer(value); + break; + } + case CONSTANT_Float: { + float value = s.readFloat("Float value"); + cpool[i] = new Float(value); + break; + } + case CONSTANT_Long: { + long value = s.readLong("Long value"); + i++; /* Argh!!!!! */ + cpool[i] = new Long(value); + break; + } + case CONSTANT_Double: { + double value = s.readDouble("Double value"); + i++; /* Argh!!!!! */ + cpool[i] = new Double(value); + break; + } + case CONSTANT_NameAndType: { + short name_index = s.readShort("NameAndType name_index"); + short signature_index = s.readShort("NameAndType signature_index"); + cpool[i] = new NameAndTypeStruct(name_index, signature_index); + break; + } + case CONSTANT_Asciz: { + cpool[i] = s.readUTF("Asciz value"); + break; + } + default: + throw new Exception("Unrecognized constant pool type: " + type); + } + } + + short access_flags = s.readShort("access_flags"); + + short this_class = s.readShort("this_class"); + ClassStruct myClass = (ClassStruct)cpool[this_class]; + if (myClass != null) + _name = getName(myClass.name_index); + + short super_class = s.readShort("super_class"); + ClassStruct mySuper = (ClassStruct)cpool[super_class]; + if (mySuper != null) + _supername = getName(mySuper.name_index); + + + short interfaces_count = s.readShort("interfaces_count"); + if (interfaces_count != 0) { + _interfaces = new String[interfaces_count]; + for (int i = 0; i < interfaces_count; i++) { + short index = s.readShort("Interface index"); + _interfaces[i] = getName(((ClassStruct)cpool[index]).name_index); + } + } + + short fields_count = s.readShort("fields_count"); + for (int i = 0; i < fields_count; i++) { + readField(s); + } + + + short methods_count = s.readShort("methods_count"); + for (int i = 0; i < methods_count; i++) { + readMethod(s); + } + + short attributes_count = s.readShort("attributes_count"); + for (int i = 0; i < attributes_count; i++) { + readAttribute(s); + } + + finishUses(); + } + + + void readField(LoggingInputStream s) throws Exception { + short access_flags = s.readShort("Field access_flags"); + short name_index = s.readShort("Field name_index"); + short signature_index = s.readShort("Field signature_index"); + short attributes_count = s.readShort("Field attributes_count"); + + addSig(getName(signature_index)); + for (int i = 0; i < attributes_count; i++) { + readAttribute(s); + } + } + + + void readMethod(LoggingInputStream s) throws Exception { + short access_flags = s.readShort("Method access_flags"); + short name_index = s.readShort("Method name_index"); + short signature_index = s.readShort("Method signature_index"); + short attributes_count = s.readShort("Method attributes_count"); + + addSig(getName(signature_index)); + for (int i = 0; i < attributes_count; i++) { + readAttribute(s); + } + } + + void readAttribute(LoggingInputStream s) throws Exception { + short attribute_name_index = s.readShort("Attribute attribute_name_index"); + int attribute_length = s.readInt("Attribute attribute_length"); + String name = (String)cpool[attribute_name_index]; + + if ("SourceFile".equals(name)) { + short sourcefile_index = s.readShort("Attribute SourceFile sourcefile_index"); + } + else if ("ConstantValue".equals(name)) { + short constantvalue_index = s.readShort("Attribute ConstantValue constantvalue_index"); + } + else if ("Code".equals(name)) { + short max_stack = s.readShort("Attribute Code max_stack"); + short max_locals = s.readShort("Attribute Code max_locals"); + int code_length = s.readInt("Attribute Code code_length"); + + byte[] code = new byte[code_length]; + s.read(code, "Attribute Code bytecodes"); + short exception_table_length = s.readShort("Attribute Code exception_table_length"); + + if (exception_table_length != 0) { + for (int i = 0; i < exception_table_length; i++) { + short start_pc = s.readShort("Attribute Code ExceptionTable start_pc"); + short end_pc = s.readShort("Attribute Code ExceptionTable end_pc"); + short handler_pc = s.readShort("Attribute Code ExceptionTable handler_pc"); + short catch_type = s.readShort("Attribute Code ExceptionTable catch_type"); + } + } + + short attributes_count = s.readShort("Attribute Code attributes_count"); + for (int i = 0; i < attributes_count; i++) { + readAttribute(s); + } + } + else if ("LineNumberTable".equals(name)) { + short line_number_table_length = s.readShort("Attribute LineNumberTable line_number_table_length"); + + if (line_number_table_length != 0) { + for (int i = 0; i < line_number_table_length; i++) { + short start_pc = s.readShort("Attribute LineNumberTable start_pc"); + short line_number = s.readShort("Attribute LineNumberTable line_number"); + } + } + } + else if ("LocalVariableTable".equals(name)) { + short local_variable_table_length = s.readShort("Attribute LocalVariableNumberTable local_variable_table_length"); + if (local_variable_table_length != 0) { + for (int i = 0; i < local_variable_table_length; i++) { + short start_pc = s.readShort("Attribute LocalVariableNumberTable start_pc"); + short length = s.readShort("Attribute LocalVariableNumberTable length"); + short name_index = s.readShort("Attribute LocalVariableNumberTable name_index"); + short signature_index = s.readShort("Attribute LocalVariableNumberTable signature_index"); + short slot = s.readShort("Attribute LocalVariableNumberTable slot"); + + addSig(getName(signature_index)); + } + } + } + else { + s.skipBytes(attribute_length, "Unrecognized attribute"); + } + } + + + String getName(int index) { + Object obj = cpool[index]; + if (obj == null) + return null; + else + return obj.toString(); + } + + + Object[] cpool; + + Hashtable _usesTable; + Vector _classNames; + + void addSig(String sig) { +// System.out.println("sig: "+sig); + int start, end, len, cur; + if(null == sig || 0 == (len = sig.length())) + return; + for(cur = 0; cur < len; cur++) { + if(sig.charAt(cur) == 'L') { + start = ++cur; + while(sig.charAt(++cur) != ';') + ; + addUses(sig.substring(start,cur)); +// System.out.println("sig_added: "+sig.substring(start,cur)+ " from "+sig); + } + } + } + + void addUses(String name) { + if(null == name || 0 == name.length()) + return; + if(name.charAt(0) =='[') { + addSig(name); + return; + } + _usesTable.put(name,name); +// System.out.println("add_uses_added: "+name); + } + + void finishUses() { + int len; + int i; + + // gather in all the names from the const pool CONSTANT_Class types + len = _classNames.size(); + for(i = 0; i < len; i++) + addUses(getName(((Integer)_classNames.elementAt(i)).intValue())); + + len = _usesTable.size(); + if(0 != len) { + i = 0; + _uses = new String[len]; + Enumeration e = _usesTable.keys(); + while(e.hasMoreElements()) + _uses[i++] = (String) e.nextElement(); + } + _usesTable = null; + } + + /*********************************/ + + String getName() {return _name;} + String getSuperName() {return _supername;} + String[] getInterfaces() {return _interfaces;} + String[] getUses() {return _uses;} + + + String _filename; + String _name; + String _supername; + String[] _interfaces; + String[] _uses; +} + + +class ConstantPoolStruct { +} + +class ClassStruct extends ConstantPoolStruct { + public short name_index; + ClassStruct(short name_index) { + this.name_index = name_index; + } +} + +class FieldrefStruct extends ConstantPoolStruct { + public short class_index; + public short name_and_type_index; + FieldrefStruct(short class_index, short name_and_type_index) { + this.class_index = class_index; + this.name_and_type_index = name_and_type_index; + } +} + +class MethodrefStruct extends ConstantPoolStruct { + public short class_index; + public short name_and_type_index; + MethodrefStruct(short class_index, short name_and_type_index) { + this.class_index = class_index; + this.name_and_type_index = name_and_type_index; + } +} + +class InterfaceMethodrefStruct extends ConstantPoolStruct { + public short class_index; + public short name_and_type_index; + InterfaceMethodrefStruct(short class_index, short name_and_type_index) { + this.class_index = class_index; + this.name_and_type_index = name_and_type_index; + } +} + +class StringStruct extends ConstantPoolStruct { + public short string_index; + StringStruct(short string_index) { + this.string_index = string_index; + } +} + +class NameAndTypeStruct extends ConstantPoolStruct { + public short name_index; + public short signature_index; + NameAndTypeStruct(short name_index, short signature_index) { + this.name_index = name_index; + this.signature_index = signature_index; + } +} + +class LoggingInputStream { + public boolean trace = false; +// public boolean trace = true; + DataInputStream s; + PrintStream traceStream = System.out; +// PrintStream traceStream = System.err; + + LoggingInputStream(InputStream s) { + super(); + this.s = new DataInputStream(s); + } + + public int readInt(String reason) throws IOException { + if (trace) traceStream.print("# reading int for " + reason); + int result = s.readInt(); + if (trace) traceStream.println(" => " + result); + return result; + } + + public short readShort(String reason) throws IOException { + if (trace) traceStream.print("# reading short for " + reason); + short result = s.readShort(); + if (trace) traceStream.println(" => " + result); + return result; + } + + public byte readByte(String reason) throws IOException { + if (trace) traceStream.print("# reading byte for " + reason); + byte result = s.readByte(); + if (trace) traceStream.println(" => " + result); + return result; + } + + public float readFloat(String reason) throws IOException { + if (trace) traceStream.print("# reading float for " + reason); + float result = s.readFloat(); + if (trace) traceStream.println(" => " + result); + return result; + } + + public long readLong(String reason) throws IOException { + if (trace) traceStream.print("# reading long for " + reason); + long result = s.readLong(); + if (trace) traceStream.println(" => " + result); + return result; + } + + public double readDouble(String reason) throws IOException { + if (trace) traceStream.print("# reading double for " + reason); + double result = s.readDouble(); + if (trace) traceStream.println(" => " + result); + return result; + } + + public int read(byte[] b, String reason) throws IOException { + if (trace) traceStream.print("# reading byte[" + b.length + "] for " + reason); + int result = s.read(b); + if (trace) traceStream.println(" => " + result); + return result; + } + + public void skipBytes(int amount, String reason) throws IOException { + if (trace) traceStream.println("# skipping " + amount + " bytes for " + reason); + s.skipBytes(amount); + } + + public String readUTF(String reason) throws IOException { + if (trace) traceStream.print("# reading utf for " + reason); + String result = DataInputStream.readUTF(s); + if (trace) traceStream.println(" => " + result); + return result; + } +} + + +class ClassnameFileFilter implements FilenameFilter { + public boolean accept(File dir, String name) { + return name.endsWith(".class"); + } +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/nativejsengine/IErrorSink.java b/mozilla/js/jsdj/classes/com/netscape/nativejsengine/IErrorSink.java new file mode 100644 index 00000000000..42bf8739852 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/nativejsengine/IErrorSink.java @@ -0,0 +1,25 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.nativejsengine; + +public interface IErrorSink +{ + public void error(String msg, String filename, int lineno, + String lineBuf, int offset); +} diff --git a/mozilla/js/jsdj/classes/com/netscape/nativejsengine/IPrintSink.java b/mozilla/js/jsdj/classes/com/netscape/nativejsengine/IPrintSink.java new file mode 100644 index 00000000000..3584d475016 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/nativejsengine/IPrintSink.java @@ -0,0 +1,24 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.nativejsengine; + +public interface IPrintSink +{ + public void print(String s); +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/nativejsengine/JSContext.java b/mozilla/js/jsdj/classes/com/netscape/nativejsengine/JSContext.java new file mode 100644 index 00000000000..d195e6f2130 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/nativejsengine/JSContext.java @@ -0,0 +1,92 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.nativejsengine; + +public class JSContext +{ + private JSContext() { + // empty + } + public static JSContext newContext(JSRuntime runtime) { + JSContext context = new JSContext(); + context._runtime = runtime; + if(! context._init()) + return null; + return context; + } + + public boolean isValid() { + return _nativeContext != 0 && _runtime != null; + } + + // finalization not guaranteed to happen in right order - trust programmer + public void destroy() { + _exit(); + _nativeContext = 0; + _runtime = null; + } + + public void eval(String s, String filename, int lineno) { + if(isValid()) + _eval(s, filename, lineno); + } + + public void load(String filename) { + if(isValid()) + _load(filename); + } + + public IErrorSink getErrorSink() {return _errorSink;} + public IErrorSink setErrorSink(IErrorSink sink) { + IErrorSink result = _errorSink; + _errorSink = sink; + return result; + } + + public IPrintSink getPrintSink() {return _printSink;} + public IPrintSink setPrintSink(IPrintSink sink) { + IPrintSink result = _printSink; + _printSink = sink; + return result; + } + + /*******************************************************************/ + + private void _print(String s) { + if(null != _printSink) + _printSink.print(s); + } + + private void _reportError(String msg, String filename, int lineno, + String lineBuf, int offset) + { + if(null != _errorSink) + _errorSink.error(msg, filename, lineno, lineBuf, offset); + } + + private synchronized native boolean _init(); + private synchronized native void _exit(); + private synchronized native void _eval(String s, String filename, int lineno); + private synchronized native void _load(String filename); + + private long _nativeContext; + private JSRuntime _runtime; + private IErrorSink _errorSink; + private IPrintSink _printSink; +} diff --git a/mozilla/js/jsdj/classes/com/netscape/nativejsengine/JSRuntime.java b/mozilla/js/jsdj/classes/com/netscape/nativejsengine/JSRuntime.java new file mode 100644 index 00000000000..be758a87022 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/nativejsengine/JSRuntime.java @@ -0,0 +1,67 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package com.netscape.nativejsengine; + +public class JSRuntime +{ + public static final String NATIVE_LIBRARY_NAME = "nativejsengine"; + public static final String NATIVE_JSD_LIBRARY_NAME = "jsd"; + + public static final boolean ENABLE_DEBUGGING = true; + public static final boolean NO_DEBUGGING = false; + + private JSRuntime() { + // empty + } + public static JSRuntime newRuntime(boolean enableDebugging) { + JSRuntime runtime = new JSRuntime(); + if(enableDebugging && ! _jsdNativesLoaded) { + System.loadLibrary(NATIVE_JSD_LIBRARY_NAME); + _jsdNativesLoaded = true; + } + if(! runtime._init(enableDebugging)) + return null; + return runtime; + } + + static { + System.loadLibrary(NATIVE_LIBRARY_NAME); + } + + public boolean isValid() { + return _nativeRuntime != 0; + } + + // finalization not guaranteed to happen in right order - trust programmer + public void destroy() { + _exit(); + _nativeRuntime = 0; + } + + long getNativeRuntime() {return _nativeRuntime;} + long getNativeDebugSupport() {return _nativeDebugSupport;} + + private native boolean _init(boolean enableDebugging); + private native void _exit(); + + private long _nativeRuntime; + private long _nativeDebugSupport; + + private static boolean _jsdNativesLoaded = false; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/com/netscape/nativejsengine/README b/mozilla/js/jsdj/classes/com/netscape/nativejsengine/README new file mode 100644 index 00000000000..676c3e745c1 --- /dev/null +++ b/mozilla/js/jsdj/classes/com/netscape/nativejsengine/README @@ -0,0 +1,8 @@ +/* jband - 09/14/98 - */ + +com.netscape.nativejsengine is a package which allows starting and running the +native JavaScript engine from a Java application. It is very bare-bones -- +intended ony to support testing. It supports starting the engine (with optional +debugger support), setting the version, sending rping output to the Java app, +and loading/executing .js files. The native code to complete this package lives +in js/jsd/javawrap. \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/DebugBreakHook.java b/mozilla/js/jsdj/classes/netscape/jsdebug/DebugBreakHook.java new file mode 100644 index 00000000000..3c522c713e7 --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/DebugBreakHook.java @@ -0,0 +1,41 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* DebugBreakHook must be subclassed to respond when a debug break is +* requested +* +* @author John Bandhauer +* @version 1.0 +* @since 1.0 +*/ +public class DebugBreakHook extends Hook { + + /** + * Override this method to respond just before a thread + * reaches a particular instruction. + *

+ * @param debug ThreadState representing the current state + * @param pc the location of the instruction about to be executed + */ + public void aboutToExecute(ThreadStateBase debug, PC pc) { + // defaults to no action + } +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/DebugController.java b/mozilla/js/jsdj/classes/netscape/jsdebug/DebugController.java new file mode 100644 index 00000000000..699db987bea --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/DebugController.java @@ -0,0 +1,390 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +import netscape.util.Hashtable; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; + +/** +* This is the master control panel for observing events in the VM. +* Each method setXHook() must be passed an object that extends +* the class XHook. When an event of the specified type +* occurs, a well-known method on XHook will be called (see the +* various XHook classes for details). The method call takes place +* on the same thread that triggered the event in the first place, +* so that any monitors held by the thread which triggered the hook +* will still be owned in the hook method. +*

+* This class is meant to be a singleton and has a private constructor. +* Call the static getDebugController() to get this object. +*

+* Note that all functions use netscape.security.PrivilegeManager to verify +* that the caller has the "Debugger" privilege. The exception +* netscape.security.ForbiddenTargetException will be throw if this is +* not enabled. +* +* @author John Bandhauer +* @author Nick Thompson +* @version 1.0 +* @since 1.0 +* @see netscape.security.PrivilegeManager +* @see netscape.security.ForbiddenTargetException +*/ +public final class DebugController { + + // version 1.0 shipped with all Navigator 4.x + private static final int majorVersion = 1; + private static final int minorVersion = 1; + + private static DebugController controller; + private ScriptHook scriptHook; + private Hashtable instructionHookTable; + private InterruptHook interruptHook; + private DebugBreakHook debugBreakHook; + private JSErrorReporter errorReporter; + + /** + * Get the DebugController object for the current VM. + *

+ * @return the singleton DebugController + */ + public static synchronized DebugController getDebugController() + throws ForbiddenTargetException + { + try { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + if (controller == null) + controller = new DebugController(); + return controller; + } catch (ForbiddenTargetException e) { + System.out.println("failed in check Priv in DebugController.getDebugController()"); + e.printStackTrace(System.out); + throw e; + } + } + + private DebugController() + { + scriptTable = new Hashtable(); + _setController(true); + } + + + + /** + * Request notification of Script loading events. + *

+ * Whenever a Script is loaded into or unloaded from the VM + * the appropriate method of the ScriptHook argument will be called. + * Callers are responsible for chaining hooks if chaining is required. + * + * @param h new script hook + * @return the previous hook object (null if none) + */ + public synchronized ScriptHook setScriptHook(ScriptHook h) + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + ScriptHook oldHook = scriptHook; + scriptHook = h; + return oldHook; + } + + /** + * Get the current observer of Script events. + *

+ * @return the current script hook (null if none) + */ + public ScriptHook getScriptHook() + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + return scriptHook; + } + + /** + * Set a hook at the given program counter value. + *

+ * When a thread reaches that instruction, a ThreadState + * object will be created and the appropriate method + * of the hook object will be called. Callers are responsible + * for chaining hooks if chaining is required. + * + * @param pc pc at which hook should be set + * @param h new hook for this pc + * @return the previous hook object (null if none) + */ + public synchronized InstructionHook setInstructionHook( + PC pc, + InstructionHook h) + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + InstructionHook oldHook; + if (instructionHookTable == null) { + instructionHookTable = new Hashtable(); + } + oldHook = (InstructionHook) instructionHookTable.get(pc); + instructionHookTable.put(pc, h); + setInstructionHook0(pc); + return oldHook; + } + + private native void setInstructionHook0(PC pc); + + /** + * Get the hook at the given program counter value. + *

+ * @param pc pc for which hook should be found + * @return the hook (null if none) + */ + public InstructionHook getInstructionHook(PC pc) + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + return getInstructionHook0(pc); + } + + // called by native function + private InstructionHook getInstructionHook0(PC pc) + { + if (instructionHookTable == null) + return null; + else + return (InstructionHook) instructionHookTable.get(pc); + } + + /**************************************************************/ + + /** + * Set the hook at to be called when interrupts occur. + *

+ * The next instruction which starts to execute after + * sendInterrupt() has been called will + * trigger a call to this hook. A ThreadState + * object will be created and the appropriate method + * of the hook object will be called. Callers are responsible + * for chaining hooks if chaining is required. + * + * @param h new hook + * @return the previous hook object (null if none) + * @see netscape.jsdebug.DebugController#sendInterrupt + */ + public synchronized InterruptHook setInterruptHook( InterruptHook h ) + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + InterruptHook oldHook = interruptHook; + interruptHook = h; + return oldHook; + } + + /** + * Get the current hook to be called on interrupt + *

+ * @return the hook (null if none) + */ + public InterruptHook getInterruptHook() + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + return interruptHook; + } + + /** + * Cause the interrupt hook to be called when the next + * JavaScript instruction starts to execute. + *

+ * The interrupt is self clearing + * @see netscape.jsdebug.DebugController#setInterruptHook + */ + public void sendInterrupt() + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + sendInterrupt0(); + } + + private native void sendInterrupt0(); + + + /**************************************************************/ + + /** + * Set the hook at to be called when a debug break is requested + *

+ * Set the hook to be called when JSErrorReporter.DEBUG is returned + * by the error reporter hook. When that happens a ThreadState + * object will be created and the appropriate method + * of the hook object will be called. Callers are responsible + * for chaining hooks if chaining is required. + * + * @param h new hook + * @return the previous hook object (null if none) + * @see netscape.jsdebug.DebugController#setErrorReporter + * @see netscape.jsdebug.JSErrorReporter + */ + public synchronized DebugBreakHook setDebugBreakHook( DebugBreakHook h ) + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + DebugBreakHook oldHook = debugBreakHook; + debugBreakHook = h; + return oldHook; + } + + /** + * Get the current hook to be called on debug break + *

+ * @return the hook (null if none) + */ + public DebugBreakHook getDebugBreakHook() + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + return debugBreakHook; + } + + + /**************************************************************/ + /** + * Get the 'handle' which cooresponds to the native code representing the + * instance of the underlying JavaScript Debugger context. + *

+ * This would not normally be useful in java. Some of the other classes + * in this package need this. It remains public mostly for historical + * reasons. It serves as a check to see that the native classes have been + * loaded and the built-in native JavaScript Debugger support has been + * initialized. This DebugController is not valid (or useful) when it is + * in a state where this native context equals 0. + * + * @return the native context (0 if none) + */ + public int getNativeContext() + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); +// System.out.println( "nativecontext = " + _nativeContext + "\n" ); + return _nativeContext; + } + + private native void _setController( boolean set ); + private Hashtable scriptTable; + private int _nativeContext; + + /** + * Execute a string as a JavaScript script within a stack frame + *

+ * This method can be used to execute arbitrary sets of statements on a + * stopped thread. It is useful for inspecting and modifying data. + *

+ * This method can only be called while the JavaScript thread is stopped + * - i.e. as part of the code responding to a hook. Thgis method + * must be called on the same thread as was executing when the + * hook was called. + *

+ * If an error occurs while execuing this code, then the error + * reporter hook will be called if present. + * + * @param frame the frame context in which to evaluate this script + * @param text the script text + * @param filename where to tell the JavaScript engine this code came + * from (it is usually best to make this the same as the filename of + * code represented by the frame) + * @param lineno the line number to pass to JS ( >=1 ) + * @return The result of the script execution converted to a string. + * (null if the result was null or void) + */ + public String executeScriptInStackFrame( JSStackFrameInfo frame, + String text, + String filename, + int lineno ) + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + return executeScriptInStackFrame0( frame, text, filename, lineno ); + } + + private native String executeScriptInStackFrame0( JSStackFrameInfo frame, + String text, + String filename, + int lineno ); + + + public Value executeScriptInStackFrameValue( JSStackFrameInfo frame, + String text, + String filename, + int lineno ) + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + return executeScriptInStackFrameValue0( frame, text, filename, lineno ); + } + + private native Value executeScriptInStackFrameValue0( JSStackFrameInfo frame, + String text, + String filename, + int lineno ); + + /** + * Set the hook at to be called when a JavaScript error occurs + *

+ * @param er new error reporter hook + * @return the previous hook object (null if none) + * @see netscape.jsdebug.JSErrorReporter + */ + public JSErrorReporter setErrorReporter(JSErrorReporter er) + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + JSErrorReporter old = errorReporter; + errorReporter = er; + return old; + } + + /** + * Get the hook at to be called when a JavaScript error occurs + *

+ * @return the hook object (null if none) + * @see netscape.jsdebug.JSErrorReporter + */ + public JSErrorReporter getErrorReporter() + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + return errorReporter; + } + + /** + * Get the major version number of this module + *

+ * @return the version number + */ + public static int getMajorVersion() {return majorVersion;} + /** + * Get the minor version number of this module + *

+ * @return the version number + */ + public static int getMinorVersion() {return minorVersion;} + + private static native int getNativeMajorVersion(); + private static native int getNativeMinorVersion(); +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/Hook.java b/mozilla/js/jsdj/classes/netscape/jsdebug/Hook.java new file mode 100644 index 00000000000..243cda54195 --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/Hook.java @@ -0,0 +1,32 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + + +/** +* An instance of this class is returned for each hook set by +* the debugger as a handle for removing the hook later. +* +* @author John Bandhauer +* @author Nick Thompson +* @version 1.0 +* @since 1.0 +*/ +public abstract class Hook { +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/InstructionHook.java b/mozilla/js/jsdj/classes/netscape/jsdebug/InstructionHook.java new file mode 100644 index 00000000000..c8c083a84ef --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/InstructionHook.java @@ -0,0 +1,55 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* InstructionHook must be subclassed to respond to hooks +* at a particular program instruction. +* +* @author John Bandhauer +* @author Nick Thompson +* @version 1.0 +* @since 1.0 +*/ +public class InstructionHook extends Hook { + private PC pc; + + /** + * Create an InstructionHook at the given PC value. + */ + public InstructionHook(PC pc) { + this.pc = pc; + } + + /** + * Get the instruction that the hook is set at. + */ + public PC getPC() { + return pc; + } + + /** + * Override this method to respond just before a thread + * reaches a particular instruction. + */ + /* jband - 03/31/97 - I made this public to allow chaining */ + public void aboutToExecute(ThreadStateBase debug) { + // defaults to no action + } +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/InterruptHook.java b/mozilla/js/jsdj/classes/netscape/jsdebug/InterruptHook.java new file mode 100644 index 00000000000..8f61c350362 --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/InterruptHook.java @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* InterruptHook must be subclassed to respond when interrupts occur +* +* @author John Bandhauer +* @author Nick Thompson +* @version 1.0 +* @since 1.0 +*/ +public class InterruptHook extends Hook { + + /** + * Override this method to respond when interrupts occur + * @param debug the state of this thread + * @param pc the pc of the instruction about to execute + */ + public void aboutToExecute(ThreadStateBase debug, PC pc) { + // defaults to no action + } +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/InvalidInfoException.java b/mozilla/js/jsdj/classes/netscape/jsdebug/InvalidInfoException.java new file mode 100644 index 00000000000..ed88a221aee --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/InvalidInfoException.java @@ -0,0 +1,46 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* Exception to indicate bad thread state etc... +* +* @author John Bandhauer +* @author Nick Thompson +* @version 1.0 +* @since 1.0 +*/ +public class InvalidInfoException extends Exception { + /** + * Constructs a InvalidInfoException without a detail message. + * A detail message is a String that describes this particular exception. + */ + public InvalidInfoException() { + super(); + } + + /** + * Constructs a InvalidInfoException with a detail message. + * A detail message is a String that describes this particular exception. + * @param s the detail message + */ + public InvalidInfoException(String s) { + super(s); + } +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/JSErrorReporter.java b/mozilla/js/jsdj/classes/netscape/jsdebug/JSErrorReporter.java new file mode 100644 index 00000000000..8c128742bc0 --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/JSErrorReporter.java @@ -0,0 +1,70 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* This is a special kind of hook to respond to JavaScript errors +* +* @author John Bandhauer +* @version 1.0 +* @since 1.0 +*/ +public interface JSErrorReporter +{ + /* keep these in sync with the numbers in jsdebug.h */ + + /** + * returned by reportError() to indicate that the error + * should be passed along to the error reporter that would have been + * called had the debugger not been running + */ + public static final int PASS_ALONG = 0; + /** + * returned by reportError() to indicate that the + * normal error reporter should not be called and that the JavaScript + * engine should do whatever it would normally do after calling the + * error reporter. + */ + public static final int RETURN = 1; + /** + * returned by reportError() to indicate that the + * 'debug break' hook should be called to allow the debugger to + * investigate the state of the process when the error occured + */ + public static final int DEBUG = 2; + + /** + * This hook is called when a JavaScript error (compile or runtime) occurs + *

+ * One of the codes above should be returned to tell the engine how to + * proceed. + * @param msg error message passed through from the JavaScript engine + * @param filename filename (or url) of the code with the error + * @param lineno line number where error was detected + * @param linebuf a copy of the line where the error was detected + * @param tokenOffset the offset into linebuf where the error + * was detected + * @returns one of the codes above + */ + public int reportError( String msg, + String filename, + int lineno, + String linebuf, + int tokenOffset ); +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/JSPC.java b/mozilla/js/jsdj/classes/netscape/jsdebug/JSPC.java new file mode 100644 index 00000000000..0dba65786c7 --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/JSPC.java @@ -0,0 +1,76 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* This subclass of PC provides JavaScript-specific information. +* +* @author John Bandhauer +* @version 1.0 +* @since 1.0 +*/ +public final class JSPC extends PC { + private Script script; + private int pc; + + public JSPC(Script script, int pc) { + this.script = script; + this.pc = pc; + } + + public Script getScript() { + return script; + } + + public int getPC() { + return pc; + } + + public boolean isValid() + { + return script.isValid(); + } + + + /** + * Get the SourceLocation associated with this PC value. + * returns null if the source location is unavailable. + */ + public native SourceLocation getSourceLocation(); + + /** + * Ask whether two program counter values are equal. + */ + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!(obj instanceof JSPC)) + return false; + JSPC jspc = (JSPC) obj; + return (jspc.script == script && jspc.pc == pc); + } + + public int hashCode() { + return script.hashCode() + pc; + } + + public String toString() { + return ""; + } +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/JSSourceLocation.java b/mozilla/js/jsdj/classes/netscape/jsdebug/JSSourceLocation.java new file mode 100644 index 00000000000..a471495b905 --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/JSSourceLocation.java @@ -0,0 +1,63 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* JAvaScript specific SourceLocation +* +* @author John Bandhauer +* @version 1.0 +* @since 1.0 +*/ +public class JSSourceLocation extends SourceLocation +{ + public JSSourceLocation( JSPC pc, int line ) + { + _pc = pc; + _line = line; + _url = pc.getScript().getURL(); + } + + /** + * Gets the first line number associated with this SourceLocation. + * This is the lowest common denominator information that will be + * available: some implementations may choose to include more + * specific location information in a subclass of SourceLocation. + */ + public int getLine() {return _line;} + + public String getURL() {return _url;} + + /** + * Get the first PC associated with a given SourceLocation. + * This is the place to set a breakpoint at that location. + * returns null if there is no code corresponding to that source + * location. + */ + public PC getPC() {return _pc;} + + public String toString() + { + return ""; + } + + private JSPC _pc; + private int _line; + private String _url; +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/JSSourceTextProvider.java b/mozilla/js/jsdj/classes/netscape/jsdebug/JSSourceTextProvider.java new file mode 100644 index 00000000000..47100b43262 --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/JSSourceTextProvider.java @@ -0,0 +1,130 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +import netscape.util.Vector; +import netscape.security.PrivilegeManager; +import netscape.security.ForbiddenTargetException; + +/** +* This class provides access to SourceText items. +*

+* This class is meant to be a singleton and has a private constructor. +* Call the static getSourceTextProvider() to get this object. +*

+* Note that all functions use netscape.security.PrivilegeManager to verify +* that the caller has the "Debugger" privilege. The exception +* netscape.security.ForbiddenTargetException will be throw if this is +* not enabled. +* +* @author John Bandhauer +* @version 1.0 +* @since 1.0 +* @see netscape.security.PrivilegeManager +* @see netscape.security.ForbiddenTargetException +*/ +public final class JSSourceTextProvider extends SourceTextProvider +{ + private JSSourceTextProvider( long nativeContext ) + { + _sourceTextVector = new Vector(); + _nativeContext = nativeContext; + } + + + /** + * Get the SourceTextProvider object for the current VM. + *

+ * @return the singleton SourceTextProvider + */ + public static synchronized SourceTextProvider getSourceTextProvider() + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + if( null == _sourceTextProvider ) + { + long nativeContext = DebugController.getDebugController().getNativeContext(); + if( 0 != nativeContext ) + _sourceTextProvider = new JSSourceTextProvider(nativeContext); + } + return _sourceTextProvider; + } + + /** + * Get the SourceText item for the given URL + */ + public SourceTextItem findSourceTextItem( String url ) + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + return findSourceTextItem0(url); + } + + // also called from native code... + private SourceTextItem findSourceTextItem0( String url ) + { + synchronized( _sourceTextVector ) + { + for (int i = 0; i < _sourceTextVector.size(); i++) + { + SourceTextItem src = (SourceTextItem) _sourceTextVector.elementAt(i); + + if( src.getURL().equals(url) ) + return src; + } + return null; + } + } + + /** + * Return the vector of SourceTextItems. + *

+ * This is NOT a copy. nor is it necessarily current + */ + public Vector getSourceTextVector() + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + return _sourceTextVector; + } + + /** + * Load the SourceText item for the given URL + *

+ * This is not guaranteed to be implemented + */ + public synchronized SourceTextItem loadSourceTextItem( String url ) + throws ForbiddenTargetException + { + PrivilegeManager.checkPrivilegeEnabled("Debugger"); + return loadSourceTextItem0( url ); + } + + private native SourceTextItem loadSourceTextItem0( String url ); + + /** + * Refresh the vector to reflect any changes made in the + * underlying native system + */ + public synchronized native void refreshSourceTextVector(); + + private static SourceTextProvider _sourceTextProvider = null; + private Vector _sourceTextVector; + private long _nativeContext; +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/JSStackFrameInfo.java b/mozilla/js/jsdj/classes/netscape/jsdebug/JSStackFrameInfo.java new file mode 100644 index 00000000000..7577ab209cc --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/JSStackFrameInfo.java @@ -0,0 +1,60 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* This interface provides access to the execution stack of a thread. +* It has several subclasses to distinguish between different kinds of +* stack frames: these currently include activations of Java methods +* or JavaScript functions. +* It is possible that synchronize blocks and try blocks deserve their own +* stack frames - to allow for later extensions a debugger should skip over +* stack frames it doesn't understand. +* Note that this appears very Java-specific. However, multiple threads and +* exceptions are relevant to JavaScript as well because of its +* interoperation with Java. +* +* @author John Bandhauer +* @version 1.0 +* @since 1.0 +*/ +public final class JSStackFrameInfo extends StackFrameInfo +{ + public JSStackFrameInfo(JSThreadState threadState) { + super(threadState); + } + + protected native StackFrameInfo getCaller0() + throws InvalidInfoException; + + public native PC getPC() + throws InvalidInfoException; + + public native Value getCallObject() + throws InvalidInfoException; + + public native Value getScopeChain() + throws InvalidInfoException; + + public native Value getThis() + throws InvalidInfoException; + + private int _nativePtr; // used internally +} + diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/JSThreadState.java b/mozilla/js/jsdj/classes/netscape/jsdebug/JSThreadState.java new file mode 100644 index 00000000000..3e5dc99200a --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/JSThreadState.java @@ -0,0 +1,80 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* This is the JavaScript specific implementation of the thread state +* +* @author John Bandhauer +* @version 1.0 +* @since 1.0 +*/ +public final class JSThreadState extends ThreadStateBase +{ + /** + * Not Implemented. + * Always throws InternalError("unimplemented") + */ + public static ThreadStateBase getThreadState(Thread t) + throws InvalidInfoException + { + throw new InternalError("unimplemented"); + } + + /** + * get the count of frames + */ + public native int countStackFrames() + throws InvalidInfoException; + + /** + * get the 'top' frame + */ + public native StackFrameInfo getCurrentFrame() + throws InvalidInfoException; + + /** + * Not Implemented. + * Always throws InternalError("unimplemented") + */ + public Thread getThread() + { + throw new InternalError("unimplemented"); + } + + /** + * Not Implemented. + * Always throws InternalError("unimplemented") + */ + public void leaveSuspended() + { + throw new InternalError("unimplemented"); + } + + /** + * Not Implemented. + * Always throws InternalError("unimplemented") + */ + protected void resume0() + { + throw new InternalError("unimplemented"); + } + + protected int nativeThreadState; /* used internally */ +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/PC.java b/mozilla/js/jsdj/classes/netscape/jsdebug/PC.java new file mode 100644 index 00000000000..7b899af6250 --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/PC.java @@ -0,0 +1,42 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* The PC class is an opaque representation of a program counter. It +* may have different implementations for interpreted Java methods, +* methods compiled by the JIT, JavaScript methods, etc. +* +* @author John Bandhauer +* @author Nick Thompson +* @version 1.0 +* @since 1.0 +*/ +public abstract class PC { + /** + * Get the SourceLocation associated with this PC value. + * returns null if the source location is unavailable. + */ + public abstract SourceLocation getSourceLocation(); + + /** + * Ask whether two program counter values are equal. + */ + public abstract boolean equals(Object obj); +} diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/Property.java b/mozilla/js/jsdj/classes/netscape/jsdebug/Property.java new file mode 100644 index 00000000000..1f55ca0b9e4 --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/Property.java @@ -0,0 +1,129 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* The Property class represents a single property of a JavaScript Value. +* +* @author John Bandhauer +* @version 1.1 +* @since 1.1 +*/ + +public final class Property { + + private Property() {} // can only be made natively + + // these must stay the same as the flags in jsdbgapi.h + + public static int ENUMERATE = 0x01; /* visible to for/in loop */ + public static int READONLY = 0x02; /* assignment is error */ + public static int PERMANENT = 0x04; /* property cannot be deleted */ + public static int ALIAS = 0x08; /* property has an alias id */ + public static int ARGUMENT = 0x10; /* argument to function */ + public static int VARIABLE = 0x20; /* local variable in function */ + public static int HINTED = 0x800; /* found via explicit lookup */ + + + public boolean isNameString() {return 0 != (_internalFlags & NAME_IS_STRING);} + public boolean isAliasString(){return 0 != (_internalFlags & ALIAS_IS_STRING);} + + public String getNameString() { + if(null == _nameString && !isNameString()) + _nameString = Integer.toString(_nameInt); + return _nameString; + } + public int getNameInt() {return _nameInt;} + + public String getAliasString() { + if(!hasAlias()) + return null; + if(null == _aliasString && !isAliasString()) + _aliasString = Integer.toString(_aliasInt); + return _aliasString; + } + public int getAliasInt() {return _aliasInt;} + + public Value getValue() {return _value;} + + public int getVarArgSlot() {return _slot;} + + public int getFlags() {return _flags;} + public boolean canEnumerate() {return 0 != (_flags & ENUMERATE);} + public boolean isReadOnly() {return 0 != (_flags & READONLY );} + public boolean isPermanent() {return 0 != (_flags & PERMANENT);} + public boolean hasAlias() {return 0 != (_flags & ALIAS );} + public boolean isArgument() {return 0 != (_flags & ARGUMENT );} + public boolean isVariable() {return 0 != (_flags & VARIABLE );} + public boolean isHinted() {return 0 != (_flags & HINTED );} + + + // override Object + public String toString() { + if(null == _string4toString) { + _string4toString = _flagsString(); + _string4toString += " name = "+ getNameString(); + if(hasAlias()) + _string4toString += ", alias = " + getAliasString(); + if(isArgument() || isVariable()) + _string4toString += ", vararg slot = " + getVarArgSlot(); + _string4toString += ", val = " + _shortValString(_value); + } + return _string4toString; + } + + private String _shortValString(Value v) { + if(null == v) + return "null"; + else if(v.isFunction()) + return "[function "+v.getFunctionName()+"]"; + else + return v.getString(); + } + + private String _flagsString() { + StringBuffer sb = new StringBuffer(7); + sb.append(canEnumerate() ? 'e' : '.'); + sb.append(isReadOnly() ? 'r' : '.'); + sb.append(isPermanent() ? 'p' : '.'); + sb.append(hasAlias() ? 'a' : '.'); + sb.append(isArgument() ? 'A' : '.'); + sb.append(isVariable() ? 'V' : '.'); + sb.append(isHinted() ? 'H' : '.'); + return sb.toString(); + } + + // private data... + + private Value _value; + private String _nameString; + private int _nameInt; + + private String _aliasString; + private int _aliasInt; + + private int _flags; + private int _slot; + + private static final short NAME_IS_STRING = 0x01; + private static final short ALIAS_IS_STRING = 0x02; + private short _internalFlags; + + private String _string4toString; +} \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/README b/mozilla/js/jsdj/classes/netscape/jsdebug/README new file mode 100644 index 00000000000..ef288969c7c --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/README @@ -0,0 +1,8 @@ +/* jband - 09/14/98 - */ + +netscape.jsdebug reflects the js/jsd/jsdebug.h native debugging api into Java. +This package shipped with Navigator 4.x. It is currently being updated for +mozilla. This package can also be used with the standalone JS shell (or in +non-Netscape embeddings of the C based Netscape JavaScript engine. + +The natives to complete these classes are in js/jsd[/java] \ No newline at end of file diff --git a/mozilla/js/jsdj/classes/netscape/jsdebug/Script.java b/mozilla/js/jsdj/classes/netscape/jsdebug/Script.java new file mode 100644 index 00000000000..1c2a8f96e71 --- /dev/null +++ b/mozilla/js/jsdj/classes/netscape/jsdebug/Script.java @@ -0,0 +1,82 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +package netscape.jsdebug; + +/** +* This instances of this class represent the JavaScript string object. This +* class is intended to only be constructed by the underlying native code. +* The DebugController will construct an instance of this class when scripts +* are created and that instance will always be used to reference the underlying +* script throughout the lifetime of that script. +* +* @author John Bandhauer +* @version 1.0 +* @since 1.0 +*/ +public final class Script +{ + public String getURL() {return _url; } + public String getFunction() {return _function; } + public int getBaseLineNumber() {return _baseLineNumber;} + public int getLineExtent() {return _lineExtent; } + public boolean isValid() {return 0 != _nativePtr;} + + /** + * Get the PC of the first executable code on or after the given + * line in this script. returns null if none + */ + public native JSPC getClosestPC(int line); + + public String toString() + { + int end = _baseLineNumber+_lineExtent-1; + if( null == _function ) + return " + + + + +

+

+

Welcome to the start page for the +Netscape JavaScript Debugger.

+Bookmark this page so you can easily restart the debugger. +

+Be sure and experiment with the JavaScript samples included with this +release.
+ +

Important: Please review the README file for +information about installing the debugger and getting started with +it. This is especially important for Unix users.
+ +For information on features of this release, known problems, and +troubleshooting tips, see the +Release Notes. +

+For information on using the debugger, see Getting +Started with Netscape JavaScript Debugger. + +

Important: When you're stopped in Netscape +JavaScript Debugger, you cannot use many features of Communicator. In +particular, you cannot use Navigator to browse web pages. For this +reason, it is recommended that you download the PDF +version of the +getting started manual before starting the debugger. You can then +either print the PDF file or view it online with Acrobat +Reader.
+ + +
+
+ + + + + diff --git a/mozilla/js/jsdj/ifcui/run/jsdebugger4server.html b/mozilla/js/jsdj/ifcui/run/jsdebugger4server.html new file mode 100644 index 00000000000..af1be477b5d --- /dev/null +++ b/mozilla/js/jsdj/ifcui/run/jsdebugger4server.html @@ -0,0 +1,134 @@ + + + Netscape JavaScript Debugger Start Page + + + + + + +
+

+

Welcome to the start page for the +Netscape JavaScript Debugger.

+Bookmark this page so you can easily restart the debugger. +

+Be sure and experiment with the JavaScript samples included with this +release.
+ +

Important: Please review the README file for +information about installing the debugger and getting started with +it. This is especially important for Unix users.
+ +For information on features of this release, known problems, and +troubleshooting tips, see the +Release Notes. +

+For information on using the debugger, see Getting +Started with Netscape JavaScript Debugger. + +

Important: When you're stopped in Netscape +JavaScript Debugger, you cannot use many features of Communicator. In +particular, you cannot use Navigator to browse web pages. For this +reason, it is recommended that you download the PDF +version of the +getting started manual before starting the debugger. You can then +either print the PDF file or view it online with Acrobat +Reader.
+ + +
+
+ + + + + diff --git a/mozilla/js/jsdj/ifcui/run/license.html b/mozilla/js/jsdj/ifcui/run/license.html new file mode 100644 index 00000000000..f95dec95fc4 --- /dev/null +++ b/mozilla/js/jsdj/ifcui/run/license.html @@ -0,0 +1,296 @@ + + + + + BY CLICKING ON THE "ACCEPT" BUTTON OR OPENING THE PACKAGE, YOU ARE CONSENTING TO BE BOUND BY AND ARE BECOMING A PARTY TO THIS AGREEMENT + + + +BY +CLICKING THE ACCEPTANCE BUTTON OR INSTALLING THE SOFTWARE, YOU ARE CONSENTING +TO BE BOUND BY AND ARE BECOMING A PARTY TO THIS AGREEMENT. IF YOU DO NOT +AGREE TO ALL OF THE TERMS OF THIS AGREEMENT, CLICK THE BUTTON THAT INDICATES +YOU DO NOT ACCEPT THE TERMS, AND DO NOT INSTALL THE SOFTWARE. (IF APPLICABLE, +YOU MAY RETURN THE PRODUCT TO THE PLACE OF PURCHASE FOR A FULL REFUND.) +IF THE COPY OF THE SOFTWARE YOU RECEIVED WAS ACCOMPANIED BY A PRINTED OR +OTHER FORM OF "HARD-COPY" END USER LICENSE AGREEMENT WHOSE TERMS VARY FROM +THIS AGREEMENT, THEN THE HARD-COPY END USER LICENSE AGREEMENT GOVERNS YOUR +USE OF THE SOFTWARE. +
+ +
NETSCAPE TOOLS END USER +LICENSE AGREEMENT
+ +
REDISTRIBUTION (EXCEPT +FOR REDISTRIBUTABLE ELEMENTS)
+ +
OR RENTAL NOT PERMITTED
+ + +

This Agreement sets forth the +terms and conditions of your use of the accompanying Netscape tool software +product(s) (the "Software"). Any third party software that is provided +with the Software with such third party's license agreement (in either +electronic or printed form) is included for use at your option. If you +choose to use such software, then such use shall be governed by such third +party's license agreement and not by this Agreement. As used in this Agreement, +for residents of Europe, the Middle East and Africa, "Netscape" shall mean +Netscape Communications Ireland Limited; for residents of Japan, "Netscape" +shall mean Netscape Communications (Japan), Ltd.; for residents of all +other countries, "Netscape" shall mean Netscape Communications Corporation. +For purposes of this Agreement, "Licensor" shall be defined as follows: +If you have acquired a third party product or service and such product +or service included the Software, then such third party shall be the Licensor. +Otherwise, Netscape shall be the Licensor. + +

LICENSE GRANT. Licensor +hereby grants to you a non-exclusive and non-transferable license to use +the Software and related documentation ("Documentation") according to the +provisions contained herein and subject to payment of applicable license +fees. Unless you have purchased a subscription for the Software, the license +granted under this Agreement does not grant you any right to any enhancement +or update to the Software. + +

You may: + +

use the Software on any single +computer; + +

run multiple instances of the +Software on a single computer; + +

except for the Oracle Software +(described below), use the Software on a second computer so long as only +one (1) copy is used at a time; + +

make a single copy of the Software +for archival purposes, provided the copy must contain all of the original +Software's proprietary notices; + +

if Netscape Navigator software +or Netscape Communicator software ("Client Software") is provided with +the Software, use the Client Software solely for developing and testing +applications you are creating using the Software, and for no other purpose; + +

if a Netscape server product +("Server Software") such as Netscape Enterprise Server or Netscape Directory +Server is provided with the Software, use the Server Software only in conjunction +with the Software and solely for the purpose of developing and testing +applications you are creating using the Software, and for no other purpose. + +

LIMITATIONS. You may not: + +

permit other individuals to +use the Software except under the terms listed above; + +

permit concurrent use of the +Software; + +

modify, translate, reverse engineer, +decompile, disassemble (except to the extent applicable laws specifically +prohibit such restriction), or create derivative works (except as provided +otherwise herein) of the Software; + +

copy or use the Software other +than as specified above; + +

redistribute the Software or +any portion of the Software except for the redistribution of the Redistributable +Elements as provided for herein; + +

rent, lease, grant a security +interest in, or otherwise transfer rights to the Software; + +

publish or provide any results +of benchmark tests run on the Software to a third party without Licensor's +prior written consent; or + +

remove or alter any trademark, +logo, copyright or other proprietary notices, legends, symbols or labels +from the Software. + +

ORACLE DATABASE RIGHTS AND +LIMITATIONS. If +the Software includes Personal Oracle Lite software ("Oracle Software"), +you are licensed to run the Oracle Software only on a single computer upon +which Netscape Visual JavaScript software ("VJS") is installed for use +with a single operating system, for internal purposes only, and only permitting +access by a single named user. The Oracle Software may be used only in +conjunction with the VJS software and only for the purpose of developing +applications. You may not distribute the Oracle Software with your applications. +In order to provide a deployment or runtime version of the Oracle Software +with your application, you must separately license it from Oracle Corporation. +In order to receive technical support for the Oracle Software after the +initial 90 day warranty period (as described below), you will need to order +technical support services directly from Oracle. + +

REDISTRIBUTABLE ELEMENTS. +If the Software includes the Netscape Component Developer's Kit (the "CDK"), +the CDK contains source code elements ("Source Code") that can be used +to create components. If the Software includes VJS, VJS contains components +in the component palette ("Components") that can be used to create applications. +Together, the Source Code and Components are referred to herein as "Redistributable +Elements." In addition to the rights and limitations described above, the +following terms govern your use of Restributable Elements: You may use, +but not modify, the Components to create applications. You may use the +Source Code in applications that you create, and you may modify the Source +Code for use in your applications. You also may reproduce and distribute +the Redistributable Elements as part of your application, provided that +your application adds substantial and primary functionality to the Redistributable +Elements, that you do not permit further redistribution by your end users +and that you do not under any circumstances distribute the Redistributable +Elements as part of a tool designed to build other applications. + +

LIMITED WARRANTY. Licensor +warrants that for a period of ninety (90) days from the date of acquisition, +the Software (other than the Netscape Component Developer's Kit, "CDK"), +if operated as directed, will substantially achieve the functionality described +in the Documentation. Licensor does not warrant, however, that your use +of the Software will be uninterrupted or that the operation of the Software +will be error-free or secure. In addition, the security mechanisms implemented +by the Software have inherent limitations, and you must determine that +the Software sufficiently meets your requirements. Licensor also warrants +that the media containing the Software, if provided by Licensor, is free +from defects in material and workmanship and will so remain for ninety +(90) days from the date you acquired the Software. Licensor's sole liability +for any breach of this warranty shall be, in Licensor's sole discretion: +(i) to replace your defective media or Software; or (ii) to advise you +how to achieve substantially the same functionality with the Software as +described in the Documentation through a procedure different from that +set forth in the Documentation; or (iii) if the above remedies are impracticable, +to refund the license fee you paid for the Software. Repaired, corrected, +or replaced Software and Documentation shall be covered by this limited +warranty for the period remaining under the warranty that covered the original +Software, or if longer, for thirty (30) days after the date (a) of delivery +to you of the repaired or replaced Software, or (b) Licensor advised you +how to operate the Software so as to achieve substantially the same functionality +described in the Documentation. + +

Only if you inform Licensor +of your problem with the Software during the applicable warranty period +and provide evidence of the date you purchased a license to the Software +will Licensor be obligated to honor this warranty. Licensor will use reasonable +commercial efforts to repair, replace, advise or, for individual +consumers, refund pursuant to the foregoing warranty within thirty +(30) days of being so notified. + +

If any modifications are made +to the Software by you during the warranty period; if the media is subjected +to accident, abuse, or improper use; or if you violate the terms of this +Agreement, then this warranty shall immediately terminate. This warranty +shall not apply if the Software is used on or in conjunction with hardware +or software other than the unmodified version of hardware and software +with which the Software was designed to be used as described in the Documentation. + +

THIS IS A LIMITED WARRANTY, +AND IT IS THE ONLY WARRANTY MADE BY LICENSOR OR ITS SUPPLIERS. LICENSOR +MAKES NO OTHER WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND +NONINFRINGEMENT OF THIRD PARTIES' RIGHTS. YOU MAY HAVE OTHER STATUTORY +RIGHTS. HOWEVER, TO THE FULL EXTENT PERMITTED BY LAW, THE DURATION OF STATUTORILY +REQUIRED WARRANTIES, IF ANY, SHALL BE LIMITED TO THE ABOVE LIMITED WARRANTY +PERIOD. MOREOVER, IN NO EVENT WILL WARRANTIES PROVIDED BY LAW, IF ANY, +APPLY UNLESS THEY ARE REQUIRED TO APPLY BY STATUTE NOTWITHSTANDING THEIR +EXCLUSION BY CONTRACT. NO DEALER, AGENT, OR EMPLOYEE OF LICENSOR IS AUTHORIZED +TO MAKE ANY MODIFICATIONS, EXTENSIONS, OR ADDITIONS TO THIS LIMITED WARRANTY. + +

DISCLAIMER OF WARRANTY FOR +CDK. The CDK is provided on an "AS IS" basis, without warranty of any +kind, including without limitation the warranties that it is free of defects, +merchantable, fit for a particular purpose or non-infringing. The entire +risk as to the quality and performance of the CDK is borne by you. Should +the CDK prove defective or inaccurate, as the case may be, you and not +Netscape or its suppliers assume the entire cost of any service and repair. +In addition, the security mechanisms, if any, implemented by the CDK have +inherent limitations, and you must determine that the CDK sufficiently +meets your requirements. This disclaimer of warranty constitutes an essential +part of this Agreement. + +

TITLE. Title, ownership +rights, and intellectual property rights in the Software shall remain in +Netscape and/or its suppliers. The Software is protected by copyright and +other intellectual property laws and by international treaties. Title and +related rights in the content accessed through the Software is the property +of the applicable content owner and is protected by applicable law. The +license granted under this Agreement gives you no rights to such content. + +

TERMINATION. This Agreement +and the license granted hereunder will terminate automatically if you fail +to comply with the limitations described herein. Upon termination, you +must destroy all copies of the Software and Documentation. Your obligations +to pay accrued charges and fees shall survive any termination of this Agreement. + +

EXPORT CONTROLS. None +of the Software or underlying information or technology may be downloaded +or otherwise exported or reexported (i) into (or to a national or resident +of) Cuba, Iraq, Libya, Sudan, North Korea, Iran, Syria or any other country +to which the U.S. has embargoed goods; or (ii) to anyone on the U.S. Treasury +Department's list of Specially Designated Nationals or the U.S. Commerce +Department's Table of Denial Orders. By downloading or using the Software, +you are agreeing to the foregoing and you are representing and warranting +that you are not located in, under the control of, or a national or resident +of any such country or on any such list. + +

In addition, if the licensed +Software is identified as a not-for-export product (for example, on the +box, media or in the installation process), then, unless you have an exemption +from the United States Department of State, the following applies: EXCEPT +FOR EXPORT TO CANADA FOR USE IN CANADA BY CANADIAN CITIZENS, THE SOFTWARE +AND ANY UNDERLYING TECHNOLOGY MAY NOT BE EXPORTED OUTSIDE THE UNITED STATES +OR TO ANY FOREIGN ENTITY OR "FOREIGN PERSON" AS DEFINED BY U.S. GOVERNMENT +REGULATIONS, INCLUDING WITHOUT LIMITATION, ANYONE WHO IS NOT A CITIZEN, +NATIONAL OR LAWFUL PERMANENT RESIDENT OF THE UNITED STATES. BY DOWNLOADING +OR USING THE SOFTWARE, YOU ARE AGREEING TO THE FOREGOING AND YOU ARE WARRANTING +THAT YOU ARE NOT A "FOREIGN PERSON" OR UNDER THE CONTROL OF A FOREIGN PERSON. + +

LIMITATION OF LIABILITY. +UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT, CONTRACT, +OR OTHERWISE, SHALL LICENSOR OR ITS SUPPLIERS OR RESELLERS BE LIABLE TO +YOU OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS +OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND +ALL OTHER COMMERCIAL DAMAGES OR LOSSES. IN NO EVENT WILL LICENSOR BE LIABLE +FOR ANY DAMAGES EVEN IF LICENSOR SHALL HAVE BEEN INFORMED OF THE POSSIBILITY +OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. THIS LIMITATION OF +LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING +FROM LICENSOR'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH +LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION +OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION +MAY NOT APPLY TO YOU. + +

INDEMNIFICATION. You +defend, indemnify and hold harmless Licensor, its suppliers and its resellers +from and against liabilities, costs, damages and expenses (including settlement +costs and reasonable attorneys' fees) arising from any claims that result +from or relate to the use, reproduction or distribution of your application. + +

HIGH RISK ACTIVITIES. +The Software is not fault-tolerant and is not designed, manufactured or +intended for use or resale as on-line control equipment in hazardous environments +requiring fail-safe performance, such as in the operation of nuclear facilities, +aircraft navigation or communication systems, air traffic control, direct +life support machines, or weapons systems, in which the failure of the +Software could lead directly to death, personal injury, or severe physical +or environmental damage ("High Risk Activities"). Licensor and its suppliers +specifically disclaim any express or implied warranty of fitness for High +Risk Activities. + +

MISCELLANEOUS. This Agreement +represents the complete agreement concerning the license granted hereunder +and may be amended only by a writing executed by both parties. If any provision +of this Agreement is held to be unenforceable, such provision shall be +reformed only to the extent necessary to make it enforceable. This Agreement +shall be governed by California law, excluding conflict of law provisions +(except to the extent applicable law, if any, provides otherwise). The +application of the United Nations Convention on Contracts for the International +Sale of Goods is expressly excluded. + +

U.S. GOVERNMENT END USERS. +The Software is a "commercial item," as that term is defined in 48 C.F.R. +2.101 (Oct. 1995), consisting of "commercial computer software" and "commercial +computer software documentation," as such terms are used in 48 C.F.R. 12.212 +(Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 +through 227.7202-4 (June 1995), all U.S. Government End Users acquire the +Software with only those rights set forth herein. + + diff --git a/mozilla/js/jsdj/ifcui/run/readme.txt b/mozilla/js/jsdj/ifcui/run/readme.txt new file mode 100644 index 00000000000..811e91f31d5 --- /dev/null +++ b/mozilla/js/jsdj/ifcui/run/readme.txt @@ -0,0 +1,125 @@ + ==================================================================== + Netscape JavaScript Debugger 1.1 + ==================================================================== + + Netscape JavaScript Debugger is subject to the terms detailed in the + license agreement accompanying it. + + "Getting Started with the JavaScript Debugger" describes how to use + the debugger. This document is available online at the following URL: + + http://developer.netscape.com/library/documentation/jsdebug/index.htm + + In addition, a PDF version of the document is available for download + at the following URL: + + http://developer.netscape.com/library/documentation/jsdebug/jsd.pdf + + Release Notes (detailing known problems and workarounds) are + available online at the following URL: + + http://home.netscape.com/eng/Tools/JSDebugger/relnotes/relnotes11.html + + + ==================================================================== + System Requirements + ==================================================================== + + Netscape JavaScript Debugger is available on the following operating + systems: + Windows 95/NT + Macintosh PowerPC + Solaris 2.4, 2.5, 2.6 + SunOS 4.1.3 + Irix 5.3, 6.2, 6.3 + + The recommended memory configurations are as follows: + Windows 95/NT: 16MB + Macintosh PPC: 16MB + Unix: 64MB + + + ==================================================================== + Installation Requirements + ==================================================================== + + * Before installing Netscape JavaScript Debugger, you must install + and run Netscape Communicator version 4.02 or later. + + * For UNIX users: Before installing Netscape JavaScript Debugger, you + must set the following environment variables and restart Communicator: + + MOZILLA_HOME + Set to the directory in which Communicator is installed. (You may + have done this when installing Communicator.) If you installed + Communicator in /communicator_installation_directory, you could use + a call such as: + + setenv MOZILLA_HOME /communicator_installation_directory + + LD_LIBRARY_PATH + Add MOZILLA_HOME to this path. If you already have this variable + set, you can add MOZILLA_HOME with a call such as the following: + + setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${MOZILLA_HOME} + + If you do not already have this variable set, you can set it with a + call such as the following: + + setenv LD_LIBRARY_PATH ${MOZILLA_HOME} + + * IMPORTANT NOTE to Visual JavaScript PR1 users: Due to a CLASSPATH + conflict, you must uninstall Visual JavaScript PR1 *before* + starting Netscape JavaScript Debugger. + + If you do not do this, the debugger displays a message box + notifying you to uninstall Visual JavaScript PR1, and then quits. + + To uninstall an application under Windows 95/NT: + + 1. Click the Start menu and choose Settings|Control Panel. + + 2. Open the Add/Remove Programs control panel and specify Visual + JavaScript 1.0 PR1. + + ==================================================================== + What Gets Installed + ==================================================================== + + Netscape JavaScript Debugger is installed using the SoftUpdate + mechanism. By default, the debugger files are placed where you + installed Netscape Communicator. For example, assume you installed + Communicator for Win95/NT in: + + c:\program files\netscape\communicator\program + + In this case, the debugger files would be installed in: + + c:\program files\netscape\communicator\program\jsdebug + + The following files and directories are installed in the jsdebug + directory or folder: + + jsdebugger.html (open this page in Navigator to start the debugger) + jsdeb11.jar + sounds\*.au + images\*.gif + samples\*.* + + ==================================================================== + What To Do First + ==================================================================== + + The first time you run the debugger, Navigator displays several + security dialogs that describe special privileges that the debugger + requires to run. You *must* grant those privileges in order for the + debugger to function. + + NOTE: To prevent these dialogs from appearing the next time you run + the debugger, check the "Remember this decision" box. + + For convenience, you should add the Debugger location to your bookmarks, + or to your personal toolbar in Navigator. + + ==================================================================== + Copyright (c) 1997, Netscape Communications Corporation diff --git a/mozilla/js/jsdj/ifcui/run/samples/badlines.html b/mozilla/js/jsdj/ifcui/run/samples/badlines.html new file mode 100644 index 00000000000..2677043b823 --- /dev/null +++ b/mozilla/js/jsdj/ifcui/run/samples/badlines.html @@ -0,0 +1,54 @@ + +Source Alignment Problem Sample + + + + + + + + + diff --git a/mozilla/js/jsdj/ifcui/run/samples/images/item1.gif b/mozilla/js/jsdj/ifcui/run/samples/images/item1.gif new file mode 100644 index 0000000000000000000000000000000000000000..ee60b83a7c3f96a1d9857da87b01f93e473f725d GIT binary patch literal 658 zcmV;D0&V?ANk%v~VN(D=0J8u9000082nY}m5F8vFEiElcNlABicc7r4y}iB8&d%1> z*52OU=jZ3|@9+2b_y7O@EC2ui08;=!000F3@X1N5y*TU5yZ>M)j$~<`XsWJk>%MR- z&vb3yc&_h!@BhG{a7Zlj8VH0j)i@Lk%hSRD02CV0QL`YZ5)xUF;$R?D2ZwNIv0xmk z0;pP)s9NWvu9bnWG!zVc7X@BQY7JNtQw0MB2#FL_0BCA%2L}obWqOVlZvb&C3=5DF zh9L|HV`iXF24rw@6byC+CaGjk2c-%If*lEEtp)|G0t5>W3bhvlUJ4_*1OoyBU=*62 z77Ymq2agZjl9LAv%T=}#ddL=pk4>Ph%C zK$Zx7XYfg2ATQ1sLkYMjp(0?H1XliEB)FsWKoUs`2;ig}p}<|J2?+E|(ne?iGz4a} znZ(CXPD)S?B{Z-zAkeQ5nwXg)Fb@--1UZ#t1iCPmDU}mzm3qKnpcPD8I~-VNaKY4f z3%d~b=7azNIp^+3s3i#GHLk%3=t7X-=!XNWPCoebaxfgduMh-OhpuiRk+BS>;tMD& z2#8c+V!hfJ142VP8BEoSNvK~FQ#MbaDK1tq#*|G02q+` zt!klOi4$bf-QvLOdb882yi_0^MS@Qdm}{d0XG98wpsi)c}a6g0{QtcmKTc+Mu-586ljEVu_%TGH!EFvck3j5OA0M)j$~<`XsWJk>%MR- z&vb3yc&_h!@BhG{a7Zlj76*gjpfHvk2toibB_Nz5gaE+p5)xQYqW~Bbq+LTJ>_HR` z4rpNtC@k0=gnE)7*By8q3t$rt23!S!7l0ZDQ*eqC3kU}XYZ#7JYz_-|4-N+eTmuH4 z6^3=DFP9_@2WJHcZf9Hs2Nw$k0=FoW2MDa6ydMpEZw6=p1aC-O0tOce0*NFJ2}x&G zst<146AcZF!lD2I%Sl}YYYXWXhF=rE;vAK_qlDjQR~8D`2cE^c3~0g*5hHR0no#It zAWj2@B0|;L7jM9TVG>kjThfTg#l@o}M@^U9VVdy4OOuDn2zAynK~risyNCq<2?Q#G z67&q1$S6u31e3^+3R|vgyHDvZEg;u)SX9x=g)HOjeY+KQR=*I9`+9w>`@4)&-)a6%So bURh z&f41A=jZ3|@9+2b_y7O@EC2ui08;=!000F3@X1N5y*TU5yZ>M)j$~<`XsWJk>%MR- z&vb3yc&_h!@BhG{a7Zlj7zabafM6I)ioyUu6&M;%5raVO0t5(b*3&Q$meTHZ>`^c! zZo${UZigobF5yt`G{h1OQw4y16onQD16Bu4h7t@22M3671ziIM30VybjtvJ~0GW;x z3}#*egfEpKpao}>N}_ue3bIpF1DhlZl9Y#ht_TJONd$5Lu?q*fbQcW_msG%Hx3hbt z5(otg7=M7Eq64u8T?AMRT?HBo)50E;X`>1i4X_9o*98aO4-E(~)l)|WodjC-G8`B% z0N#gC1sy(E*wCJV0ZWh(@b}=H7=->3rq#-jhk!N@38rPDpn!`20%n9Q1mNv}90QJM z@iM1OrZZCtv?UlB!d(@15*8Rp#>m?iW%XJr%lCk1#fd*3BsdC(3qL1iaE>VBaofd$ zcP4sm!fn*EW^UoE3siRIr~4!5w%dWK^TQ&^UuOcJ4oUt7z+Eswe7ckLAAAvsfRgV~M z#Dbv_=&7=r7?34!k|B^Sb;f+PJ)!|X;*mF?iygE` z*52OU=jZ3|@9+2b_y7O@EC2ui08;=!000F3@X1N5y*TU5yZ>M)j$~<`XsWJk>%MR- z&vb3yc&_h!@BhG{a7Zi$69}UU5hy584MKpxc$yA_Y0^4k6as<4fjdG-0|Em% z(>2JO$W9gViUZ^Jg2j0f4G0GZcoYo=V+Vg~PYw(V4tr)`0tE>a2L)A3XihKw+p-D?Ag-K|GAi;tL4uVZV2SQ&gT8Wf;R3PvRpqC6KoJ^Au4k!n)CW2EqZr%r+ zQ!+hB(C*KHiOHtiO7%&?0|BZFi5iDVOtTGLoJ77x*lQ-K`=5R!=l+L#iU6&;NeoB@grP=H_z zEOTHH6}i=&UF}RqS{?$Pk^ndhj1~w5{s=I@bf{4EVg}3=rNDJJYLH%!Kn5w~kVF<~ T"); +document.writeln( "this was written from include.js
"); +document.writeln( "
"); diff --git a/mozilla/js/jsdj/ifcui/run/samples/index.html b/mozilla/js/jsdj/ifcui/run/samples/index.html new file mode 100644 index 00000000000..b49ca3b9d00 --- /dev/null +++ b/mozilla/js/jsdj/ifcui/run/samples/index.html @@ -0,0 +1,15 @@ + + +JavaScript Debugger Samples + + + +

Some simple samples

+Properties display sample

+A recursion sample

+Runtime Error sample

+A layers sample

+Some misc. samples on one page

+A sample requiring source adjustment

+ + diff --git a/mozilla/js/jsdj/ifcui/run/samples/layers.html b/mozilla/js/jsdj/ifcui/run/samples/layers.html new file mode 100644 index 00000000000..e6b08a58d83 --- /dev/null +++ b/mozilla/js/jsdj/ifcui/run/samples/layers.html @@ -0,0 +1,139 @@ + + + +Layers Example + + + + + +


+

Welcome to the Layers Sample

+
+ +

+ + + + +

Select an item:

+
+ + +
+ + + + + + + + +
+ +

Item1

+
This is item 1 +
+
+ +
+ + + + +
+ +

Item2

+
This is item 2 +
+
+ +
+ + + +
+ +

Item3

+
This is item 3 +
+
+ +
+ + +
+ +

Item4

+
This is item 4 +
+
+ +
+ + + diff --git a/mozilla/js/jsdj/ifcui/run/samples/misc.html b/mozilla/js/jsdj/ifcui/run/samples/misc.html new file mode 100644 index 00000000000..5348ffe2c8f --- /dev/null +++ b/mozilla/js/jsdj/ifcui/run/samples/misc.html @@ -0,0 +1,43 @@ + + +Misc. Samples + + + + + +click me (onclick) debugger detects
+click me (javascript:) debugger ignores
+ + + +
+ + + + + + diff --git a/mozilla/js/jsdj/ifcui/run/samples/props.html b/mozilla/js/jsdj/ifcui/run/samples/props.html new file mode 100644 index 00000000000..34378de6522 --- /dev/null +++ b/mozilla/js/jsdj/ifcui/run/samples/props.html @@ -0,0 +1,45 @@ + + +Properties Display Sample + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/mozilla/js/jsdj/ifcui/run/samples/recursion.html b/mozilla/js/jsdj/ifcui/run/samples/recursion.html new file mode 100644 index 00000000000..615d562f707 --- /dev/null +++ b/mozilla/js/jsdj/ifcui/run/samples/recursion.html @@ -0,0 +1,48 @@ + + +Recursion Sample + + + + + +Recursion:
+ + + + \ No newline at end of file diff --git a/mozilla/js/jsdj/ifcui/run/samples/runerr.html b/mozilla/js/jsdj/ifcui/run/samples/runerr.html new file mode 100644 index 00000000000..b1b0a931a7d --- /dev/null +++ b/mozilla/js/jsdj/ifcui/run/samples/runerr.html @@ -0,0 +1,46 @@ + + +Runtime Error Sample + + + + + + + + + + diff --git a/mozilla/js/jsdj/ifcui/run/sounds/droplet.au b/mozilla/js/jsdj/ifcui/run/sounds/droplet.au new file mode 100644 index 0000000000000000000000000000000000000000..337a2a333a6af0b4d536ef8a18c33d99f299ae3d GIT binary patch literal 1256 zcmXX@`BxfO6sG6&&*(XfiW?wA9hPAk6a^870T;v#O{__@)#Rim=d|YJZ()!|1!WMB zWmpwKTtGA$Be=w9liJ1FHti3dCb4g9?=SCu-~I0Q-o1}E{$Pl~V0^(~e4YX4XAB0j z?!S}4xPJWg@cof5?|=K@;&?y1np{f6<53VHzkAMMcR1Zt^2pdAm&)q!2V02@PdQy4KNXE967dM-bKj^)w?Dj?&g3@N zQt@zb!81Sa_6EX<%)!NzCl`h6ax@eS1gXf<#>t>T+tjS0D!Ety3q-O;{r$K3{rz{t?M)~m6bJ-}T;1{L^?v^BQHL6p07i(& zRfdswFSqwjMuCW48zOJi_5YUN$^Uv+-$)z5LJ6wY4~&0!_Enz_FmNp_5X+QU-#33= zPTX$OC}fC8B$g^PZNnEQr|*YaHFYwHSS*n@v~-QXJ1m?{m~oXtE|V)%Sl?fT?ai(I zpY9pd3YiovT5EcG_#*e>@MDj*L4l(68soDuHta3(T9s((&-B48>`vng4o&xn*|g-7#o6^rAYKSKvt)j15j~wYRUq_aYdsde(E^@#H_J`32HD! z_f2}mB>=Hd(hAVjHXC9>5NCrHT0O#IP%6b7w1?eL3P6c`jsReKpo|6$cDgcyv1r-E zjk!}$#AHI;0Ijm+ZdC0zg#d@iWEP2L0Z;h2paH6Nf_yR#9s?Djw9|AGeP2b)3h1SB zFk5lUl!YK%Jdi@5ld#OeAfrtPf~)}}v3h~GHNplKJinE&*qd1pv#j4vSY}>>k=b{h zlizza6;Mg-irwbe;1@GXrQw+=cPASv;uw9iu3ce88Lu@&dJ7_UWzDGH>CQ>HT=5&f zEBK4FM%*3qcvE@_f~ObUp}bCQUZec6!*=~?)Z>Zlb(>x<1_IHw+QI%;r(s%*bgV)nQ%kzKqrp3_jc*j zYF%%?L9JBdrZ$~UkGE(vc;7&$PK)6NeOu4qfDy+qyw%j#Z|>{q?(Asmy3>Dmu)E7- L>M`GYIC1?i1$9wH literal 0 HcmV?d00001 diff --git a/mozilla/js/jsdj/jslogger/JSLogger.html b/mozilla/js/jsdj/jslogger/JSLogger.html new file mode 100644 index 00000000000..67a908348d0 --- /dev/null +++ b/mozilla/js/jsdj/jslogger/JSLogger.html @@ -0,0 +1,21 @@ + + + JSLogger + + + + + +This applet will log JavaScript activity to log.txt + + + + + + + diff --git a/mozilla/js/jsdj/stub_classes/README b/mozilla/js/jsdj/stub_classes/README new file mode 100644 index 00000000000..14ceac50c01 --- /dev/null +++ b/mozilla/js/jsdj/stub_classes/README @@ -0,0 +1,7 @@ +/* jband - 09/14/98 - */ + +jsdj/stub_classes contains stubbed out versions of some Netscape classes which +might be needed for compatability. For instance, the graphical debugger (in +com.netscape.jsdebugging.ifcui) used the netscape.security calsses when running +in Navigator, but needs stubbed out versions of a couple of those classes to +function in a stand-alone environment. diff --git a/mozilla/js/jsdj/stub_classes/netscape/applet/EmbeddedProgramOwner.java b/mozilla/js/jsdj/stub_classes/netscape/applet/EmbeddedProgramOwner.java new file mode 100644 index 00000000000..e5b90d19343 --- /dev/null +++ b/mozilla/js/jsdj/stub_classes/netscape/applet/EmbeddedProgramOwner.java @@ -0,0 +1,26 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// jband - Sept 2 1998 - this is a stubbed out version of the real file + +package netscape.applet; + +public interface EmbeddedProgramOwner { + public void programDidInit(EmbeddedProgramTracker ept); + public boolean programCanShutdown(EmbeddedProgramTracker ept); +} diff --git a/mozilla/js/jsdj/stub_classes/netscape/applet/EmbeddedProgramTracker.java b/mozilla/js/jsdj/stub_classes/netscape/applet/EmbeddedProgramTracker.java new file mode 100644 index 00000000000..c6362ea4f95 --- /dev/null +++ b/mozilla/js/jsdj/stub_classes/netscape/applet/EmbeddedProgramTracker.java @@ -0,0 +1,23 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +// jband - Sept 2 1998 - this is a stubbed out version of the real file + +package netscape.applet; + +public class EmbeddedProgramTracker {} diff --git a/mozilla/js/jsdj/stub_classes/netscape/javascript/JSException.java b/mozilla/js/jsdj/stub_classes/netscape/javascript/JSException.java new file mode 100644 index 00000000000..53ca4b3fa19 --- /dev/null +++ b/mozilla/js/jsdj/stub_classes/netscape/javascript/JSException.java @@ -0,0 +1,74 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* jband Sept 1998 - **NOT original file** - copied here for simplicity */ + +package netscape.javascript; + +/** + * JSException is an exception which is thrown when JavaScript code + * returns an error. + */ + +public +class JSException extends Exception { + String filename; + int lineno; + String source; + int tokenIndex; + + /** + * Constructs a JSException without a detail message. + * A detail message is a String that describes this particular exception. + */ + public JSException() { + super(); + filename = "unknown"; + lineno = 0; + source = ""; + tokenIndex = 0; + } + + /** + * Constructs a JSException with a detail message. + * A detail message is a String that describes this particular exception. + * @param s the detail message + */ + public JSException(String s) { + super(s); + filename = "unknown"; + lineno = 0; + source = ""; + tokenIndex = 0; + } + + /** + * Constructs a JSException with a detail message and all the + * other info that usually comes with a JavaScript error. + * @param s the detail message + */ + public JSException(String s, String filename, int lineno, + String source, int tokenIndex) { + super(s); + this.filename = filename; + this.lineno = lineno; + this.source = source; + this.tokenIndex = tokenIndex; + } +} + diff --git a/mozilla/js/jsdj/stub_classes/netscape/javascript/JSObject.java b/mozilla/js/jsdj/stub_classes/netscape/javascript/JSObject.java new file mode 100644 index 00000000000..280232c6167 --- /dev/null +++ b/mozilla/js/jsdj/stub_classes/netscape/javascript/JSObject.java @@ -0,0 +1,168 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* jband Sept 1998 - **NOT original file** - copied here for simplicity */ + +/* more doc todo: + * threads + * gc + * + * + */ + +package netscape.javascript; + +import java.applet.Applet; + +/** + * JSObject allows Java to manipulate objects that are + * defined in JavaScript. + * Values passed from Java to JavaScript are converted as + * follows:
    + *
  • JSObject is converted to the original JavaScript object + *
  • Any other Java object is converted to a JavaScript wrapper, + * which can be used to access methods and fields of the java object. + * Converting this wrapper to a string will call the toString method + * on the original object, converting to a number will call the + * doubleValue method if possible and fail otherwise. Converting + * to a boolean will try to call the booleanValue method in the + * same way. + *
  • Java arrays are wrapped with a JavaScript object that understands + * array.length and array[index] + *
  • A Java boolean is converted to a JavaScript boolean + *
  • Java byte, char, short, int, long, float, and double are converted + * to JavaScript numbers + *
+ * Values passed from JavaScript to Java are converted as follows:
    + *
  • objects which are wrappers around java objects are unwrapped + *
  • other objects are wrapped with a JSObject + *
  • strings, numbers and booleans are converted to String, Double, + * and Boolean objects respectively + *
  • undefined is converted to a string + *
+ * This means that all JavaScript values show up as some kind + * of java.lang.Object in Java. In order to make much use of them, + * you will have to cast them to the appropriate subclass of Object, + * e.g. (String) window.getMember("name"); or + * (JSObject) window.getMember("document");. + */ +public final class JSObject { + /* the internal object data */ + private int internal; + + /** + * initialize + */ + private static native void initClass(); + static { + String liveConnectLibrary = null; + String OSName = System.getProperty("os.name", null); + + // On MRJ, this property won't exist, because the library is preloaded. + liveConnectLibrary = System.getProperty("netscape.jsj.dll", null); + + // On Mac, native methods are statically linked and manually registered. + if ((liveConnectLibrary == null) && (OSName.indexOf("Mac") == -1)) + liveConnectLibrary = "LiveConnect"; + + if (liveConnectLibrary != null) { + System.loadLibrary(liveConnectLibrary); + initClass(); + } + } + + /** + * it is illegal to construct a JSObject manually + */ + private JSObject(int jsobj_addr) { + internal = jsobj_addr; + } + + /** + * Retrieves a named member of a JavaScript object. + * Equivalent to "this.name" in JavaScript. + */ + public native Object getMember(String name); + + /** + * Retrieves an indexed member of a JavaScript object. + * Equivalent to "this[index]" in JavaScript. + */ +// public Object getMember(int index) { return getSlot(index); } + public native Object getSlot(int index); + + /** + * Sets a named member of a JavaScript object. + * Equivalent to "this.name = value" in JavaScript. + */ + public native void setMember(String name, Object value); + + /** + * Sets an indexed member of a JavaScript object. + * Equivalent to "this[index] = value" in JavaScript. + */ +// public void setMember(int index, Object value) { +// setSlot(index, value); +// } + public native void setSlot(int index, Object value); + + /** + * Removes a named member of a JavaScript object. + */ + public native void removeMember(String name); + + /** + * Calls a JavaScript method. + * Equivalent to "this.methodName(args[0], args[1], ...)" in JavaScript. + */ + public native Object call(String methodName, Object args[]); + + /** + * Evaluates a JavaScript expression. The expression is a string + * of JavaScript source code which will be evaluated in the context + * given by "this". + */ + public native Object eval(String s); + + /** + * Converts a JSObject to a String. + */ + public native String toString(); + + // should use some sort of identifier rather than String + // is "property" the right word? + // native String[] listProperties(); + + + /** + * get a JSObject for the window containing the given applet + */ + public static native JSObject getWindow(Applet applet); + + /** + * Finalization decrements the reference count on the corresponding + * JavaScript object. + */ + protected native void finalize(); + + /** + * Override java.lang.Object.equals() because identity is not preserved + * with instances of JSObject. + */ + public native boolean equals(Object obj); +} diff --git a/mozilla/js/jsdj/stub_classes/netscape/javascript/JSProxy.java b/mozilla/js/jsdj/stub_classes/netscape/javascript/JSProxy.java new file mode 100644 index 00000000000..92f5fdc1ac7 --- /dev/null +++ b/mozilla/js/jsdj/stub_classes/netscape/javascript/JSProxy.java @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* jband Sept 1998 - **NOT original file** - copied here for simplicity */ + +/** + * The JSProxy interface allows applets and plugins to + * share javascript contexts. + */ + +package netscape.javascript; +import java.applet.Applet; + +public interface JSProxy { + Object getMember(JSObject jso, String name); + Object getSlot(JSObject jso, int index); + void setMember(JSObject jso, String name, Object value); + void setSlot(JSObject jso, int index, Object value); + void removeMember(JSObject jso, String name); + Object call(JSObject jso, String methodName, Object args[]); + Object eval(JSObject jso, String s); + String toString(JSObject jso); + JSObject getWindow(Applet applet); +} diff --git a/mozilla/js/jsdj/stub_classes/netscape/javascript/JSRunnable.java b/mozilla/js/jsdj/stub_classes/netscape/javascript/JSRunnable.java new file mode 100644 index 00000000000..e04b616ea7f --- /dev/null +++ b/mozilla/js/jsdj/stub_classes/netscape/javascript/JSRunnable.java @@ -0,0 +1,51 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* jband Sept 1998 - **NOT original file** - copied here for simplicity */ + +package netscape.javascript; + +/** + * Runs a JavaScript object with a run() method in a separate thread. + */ +public class JSRunnable implements Runnable { + private JSObject runnable; + + public JSRunnable(JSObject runnable) { + this.runnable = runnable; + synchronized(this) { + new Thread(this).start(); + try { + this.wait(); + } catch (InterruptedException ie) { + } + } + } + + public void run() { + try { + runnable.call("run", null); + synchronized(this) { + notifyAll(); + } + } catch (Throwable t) { + System.err.println(t); + t.printStackTrace(System.err); + } + } +} diff --git a/mozilla/js/jsdj/stub_classes/netscape/javascript/JSUtil.java b/mozilla/js/jsdj/stub_classes/netscape/javascript/JSUtil.java new file mode 100644 index 00000000000..c864eb74cc3 --- /dev/null +++ b/mozilla/js/jsdj/stub_classes/netscape/javascript/JSUtil.java @@ -0,0 +1,39 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* jband Sept 1998 - **NOT original file** - copied here for simplicity */ + +package netscape.javascript; +import java.io.*; + +public class JSUtil { + + /* Return the stack trace of an exception or error as a String */ + public static String getStackTrace(Throwable t) { + ByteArrayOutputStream captureStream; + PrintStream p; + + captureStream = new ByteArrayOutputStream(); + p = new PrintStream(captureStream); + + t.printStackTrace(p); + p.flush(); + + return captureStream.toString(); + } +} diff --git a/mozilla/js/jsdj/stub_classes/netscape/security/ForbiddenTargetException.java b/mozilla/js/jsdj/stub_classes/netscape/security/ForbiddenTargetException.java new file mode 100644 index 00000000000..c8c0759ae74 --- /dev/null +++ b/mozilla/js/jsdj/stub_classes/netscape/security/ForbiddenTargetException.java @@ -0,0 +1,48 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* jband Sept 1998 - **NOT original file** - copied here for simplicity */ + +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/jsdj/stub_classes/netscape/security/PrivilegeManager.java b/mozilla/js/jsdj/stub_classes/netscape/security/PrivilegeManager.java new file mode 100644 index 00000000000..a266b269455 --- /dev/null +++ b/mozilla/js/jsdj/stub_classes/netscape/security/PrivilegeManager.java @@ -0,0 +1,64 @@ +/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +/* jband Sept 1998 - **NOT original file** - this version is stubbed out */ + +package netscape.security; + +/** +* Non-functional stubbed out version +*

+* This supports only the entry points used by the JSD system +* @author John Bandhauer +*/ +public +class PrivilegeManager { + + /* + * This is a hack to fool the symantec optimizer. When compiling this + * stubbed out version of this class the compiler was determining that + * the calls to enablePrivilege() had no real effect and was + * optimizing them away. However, when the application was running in + * Navigator (with the REAL version of this class) security checks were + * failing because the enablePrivilege() call was not calling the real + * thing + */ + private static int _bogus; + + /** + * 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) {_bogus++;} +} diff --git a/mozilla/js/jsdj/test/jsdb.bat b/mozilla/js/jsdj/test/jsdb.bat new file mode 100755 index 00000000000..b76b5d1e7c3 --- /dev/null +++ b/mozilla/js/jsdj/test/jsdb.bat @@ -0,0 +1,6 @@ +@echo off + +copy *.js ..\dist\bin\Debug >NUL +cd ..\dist\bin\Debug +jre -classpath ..\..\classes;..\..\classes\ifc11.jar;..\..\..\..\rhino;%CLASSPATH% com.netscape.jsdebugging.jsdb.Main %1 %2 %3 %4 %6 %7 %8 +cd ..\..\..\test diff --git a/mozilla/js/jsdj/test/objects.js b/mozilla/js/jsdj/test/objects.js new file mode 100644 index 00000000000..356046c2625 --- /dev/null +++ b/mozilla/js/jsdj/test/objects.js @@ -0,0 +1,40 @@ +// some tests... + +function set_a(a) {this.a = a;} +function set_b(b) {this.b = b;} +function set_c(c) {this.c = c;} + +function f_ctor(a,b,c) +{ + this.set_a = set_a; + this.set_b = set_b; + this.set_c = set_c; + + this.get_a = new Function("return this.a;"); + this.get_b = new Function("return this.b;"); + this.get_c = new Function("return this.c;"); + + this.set_a(a); + this.set_b(b); + this.set_c(c); +} + +function f2_ctor(param) +{ + this.A = new f_ctor(1,2,3); + this.b = new f_ctor("A","B","C"); + this.number = param; +} + +function callMe() +{ + var A = new f2_ctor(1); + var b = new f2_ctor(5); +} + +A = new f2_ctor(0); +AA = new f2_ctor(100); +callMe(); + +A.A.set_b(8); +print(A.A.get_b()); diff --git a/mozilla/js/jsdj/test/sample.js b/mozilla/js/jsdj/test/sample.js new file mode 100644 index 00000000000..5ecd9eb5df4 --- /dev/null +++ b/mozilla/js/jsdj/test/sample.js @@ -0,0 +1,11 @@ +a=1; +for (i=0; i<10; i++){ + a = inc (inc(a)); +} + +c = a+2; + +// Increment function +function inc (b){ + return b+1; +} \ No newline at end of file