Details

    • Type: New Feature New Feature
    • Status: In Progress
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Scripting
    • Labels:
      None

      Description

      This is the suggestion as distilled from the mailing list:

      a) Add the return value to the eval() method

      b) Wwe create a new SlingScript.call(String method,
      Object... args) method which will be implemented such, that a new
      (virtual) script is created from the original script appended with the
      method call.

      Example: Let the script source be

      function sampleFunction()

      { ... }
      function anotherFunction(arg1, arg2) { ... }

      Now, we call script.call("sampleFunction", null).

      This would result in the virtual (combined) script:

      function sampleFunction()

      { ... }
      function anotherFunction(arg1, arg2) { ... }

      sampleFunction();

      Likewise, calling script.call("anotherFunction", 5, "astring") would get
      the virtual script:

      function sampleFunction()

      { ... }
      function anotherFunction(arg1, arg2) { ... }

      anotherFunction(5, "astring");

      To build the method call, we may use the
      ScriptEngineFactory.getMethodCallSyntax().

      Finally the virtual script is actually evaluated.

      This would also allow this for any scripting language ...

        Activity

        Hide
        Carsten Ziegeler added a comment -

        If SLING-324 is implemented we should remove the method call appending and just rely on Invocable.

        Show
        Carsten Ziegeler added a comment - If SLING-324 is implemented we should remove the method call appending and just rely on Invocable.
        Hide
        Carsten Ziegeler added a comment -

        I added the return value to eval() and added a new call() method.

        We can't use ScriptEngineFactory.getMethodCallSyntax() as this requires a java object to be called.

        The current implementation tries javax.script.Invocable. If the underlying script engine does not support this (like our rhino impl) it just appends the method call as text - which obviously does not work for all languages and lacks proper type support.

        Show
        Carsten Ziegeler added a comment - I added the return value to eval() and added a new call() method. We can't use ScriptEngineFactory.getMethodCallSyntax() as this requires a java object to be called. The current implementation tries javax.script.Invocable. If the underlying script engine does not support this (like our rhino impl) it just appends the method call as text - which obviously does not work for all languages and lacks proper type support.

          People

          • Assignee:
            Unassigned
            Reporter:
            Carsten Ziegeler
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:

              Development