Skip to content

Commit

Permalink
feat: expose rhino context and scope (#15)
Browse files Browse the repository at this point in the history
Add method in `RhinoContext` class to expose the `Context` and the
`Scope` (`ScriptableObject`) from `Rhino`
  • Loading branch information
rapatao authored Nov 20, 2023
1 parent 8f49756 commit 2baea45
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import org.mozilla.javascript.ScriptableObject
* RhinoContext is a class that implements the EvalContext interface.
* It provides the ability to process expressions using the Rhino JavaScript engine.
*
* @param context The Rhino Context object.
* @param scope The ScriptableObject representing the scope in which the expressions will be executed.
* @property context The Rhino Context object.
* @property scope The ScriptableObject representing the scope in which the expressions will be executed.
*/
class RhinoContext(
private val context: Context,
Expand All @@ -30,6 +30,20 @@ class RhinoContext(
.exec(context, scope)
}

/**
* Returns the Rhino context.
*
* @return The Rhino context.
*/
fun context() = context

/**
* Returns the Rhino scope.
*
* @return The Rhino scope.
*/
fun scope() = scope

private fun Expression.asScript(context: Context): Script {
val script = Parser.parse(this)

Expand Down

0 comments on commit 2baea45

Please sign in to comment.