Add docs to codes
This commit is contained in:
parent
dbdf93ab6f
commit
aec7f39886
2 changed files with 21 additions and 5 deletions
4
LICENSE
4
LICENSE
|
@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively
|
|||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
Eval GJS
|
||||
Copyright (C) 2021 Tamado Sitohang <ramot@ramottamado.dev>
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -40,6 +40,22 @@ class EvalGjs {
|
|||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(EvalGjsIface, this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Eval:
|
||||
* @param {string} code: A string containing JavaScript code
|
||||
* @returns {Array}
|
||||
*
|
||||
* This function executes arbitrary code in the main
|
||||
* loop, and returns a boolean success and
|
||||
* JSON representation of the object as a string.
|
||||
*
|
||||
* If evaluation completes without throwing an exception,
|
||||
* then the return value will be [true, JSON.stringify(result)].
|
||||
* If evaluation fails, then the return value will be
|
||||
* [false, JSON.stringify(exception)];
|
||||
*
|
||||
*/
|
||||
Eval(code) {
|
||||
let returnValue;
|
||||
let success;
|
||||
|
@ -47,9 +63,9 @@ class EvalGjs {
|
|||
try {
|
||||
returnValue = JSON.stringify(eval(code));
|
||||
|
||||
returnValue = returnValue == undefined
|
||||
? ''
|
||||
: returnValue;
|
||||
// A hack; DBus doesn't have null/undefined
|
||||
if (returnValue == undefined)
|
||||
returnValue = '';
|
||||
|
||||
success = true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue