First implementation of the include() function

This commit is contained in:
Eric van der Vlist 2021-04-25 11:58:26 +02:00
parent 122c73ef1f
commit bf538745d7
3 changed files with 62 additions and 34 deletions

View File

@ -14,4 +14,13 @@ startDebugger = function () {
main.setExitAction(java.lang.Runnable(runnable)); // , clean the resources at exit time...
main.setVisible(true); // and make it visible/
}
include = function (filepath, isAbsolute) {
if (isAbsolute === undefined || isAbsolute == false) {
filepath = Packages.ro.sync.ecss.extensions.commons.operations.CommonsOperationsUtil.expandAndResolvePath(authorAccess, filepath);
}
var text = new java.lang.String(java.nio.file.Files.readAllBytes(java.nio.file.Paths.get('/home/vdv/projects/tea/dyomedea/ramblings/oxygen/js-debugger-importer/test.js')));
text = String(text);
eval(text);
}

View File

@ -808,6 +808,56 @@
<Boolean>false</Boolean>
</field>
</action>
<action>
<field name="id">
<String>hello</String>
</field>
<field name="name">
<String>hello</String>
</field>
<field name="description">
<String>Hello world</String>
</field>
<field name="largeIconPath">
<String></String>
</field>
<field name="smallIconPath">
<String></String>
</field>
<field name="accessKey">
<String></String>
</field>
<field name="accelerator">
<String>ctrl shift H</String>
</field>
<field name="actionModes">
<actionMode-array>
<actionMode>
<field name="xpathCondition">
<String></String>
</field>
<field name="argValues">
<serializableOrderedMap>
<entry>
<String>script</String>
<String>
doOperation = function () {
include('test.js');
hello();
}</String>
</entry>
</serializableOrderedMap>
</field>
<field name="operationID">
<String>ro.sync.ecss.extensions.commons.operations.JSOperation</String>
</field>
</actionMode>
</actionMode-array>
</field>
<field name="enabledInReadOnlyContext">
<Boolean>false</Boolean>
</field>
</action>
</action-array>
</field>
<field name="menubarDescriptor">

View File

@ -1,34 +1,3 @@
/*
* Unexpected things happen here...
*/
function a() {}
b = function() {}
// Notice the weird behavior :
typeof a; // object
typeof b; // function
aclass = function () {
this.setFoo(1);
return this;
}
typeof aclass;
aclass.prototype.setFoo = function (v) {
this.foo = v;
}
anObject = new aclass() ;
anObject.setFoo(2);
anObject.foo;
// Also worth mentionning, you ***must*** use new and this doesn't work :
//
// anobject = aclass();
hello = function (){
Packages.java.lang.System.out.println("Hello world.");
}