Re: Newb question about calling Scheme from Java

"Mike J. Bell" <[email protected]> Tue, 2 Sep 2008 16:48:20 -0400
Newsgroups gmane.comp.java.sisc.user
Message-ID <[email protected]>
--===============0824979249==
Content-Type: multipart/alternative; 
	boundary="----=_Part_14267_32823048.1220388500206"

------=_Part_14267_32823048.1220388500206
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Well, the problem is the Java object that is running the SISC interpreter
needs to pass in a reference to itself so that the Scheme interpreter can
perform callbacks on it.  Like:

public class JavaEnvironment {
    public void someMethod(String someArg) {
        // ... do something
    }

    public void runScheme(String expression) {
        // ... all that setup code, and then:
        interpreter.define(...);  // define this to be *ME*
        interpreter.eval(expression);
    }

    public static void main(String[] args) {
        JavaEnvironment je = new JavaEnvironment();
        je.runScheme("(import s2j) ... (define-generic-java-method
some-method) (some-method this)");
    }
}

See what I mean?  I need to pass "this" into Scheme, and then scheme can
essentially reenter the Java code.  The called Java code will NOT re-call
Scheme; i.e., there should never be a case of Java->Scheme->Java->Scheme,
only Java->Scheme->Java.

Thanks again...

Mike

On Tue, Sep 2, 2008 at 3:56 PM, Antonio <[email protected]> wrote:

> What about interpreter.eval("(define foobar 'bar)"); ?
>
> Mike J. Bell wrote:
>
>> I'm trying to integrate SISC as a Scheme interpreter into a larger,
>> established product written in Java.  Anybody else do this, open-source
>> like, so I might peek at the ways and means?  Any advice on trying to
>> "replicate" a Java "programmer's" API inside SISC?  (i.e., ways to automate
>> all the (->jstring ...) and wrap/unwrap code that must go on with s2j).
>> [snip]
>>
>
>


-- 
Mike J. Bell on gmail

------=_Part_14267_32823048.1220388500206
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div dir="ltr">Well, the problem is the Java object that is running the SISC interpreter needs to pass in a reference to itself so that the Scheme interpreter can perform callbacks on it.&nbsp; Like:<br><br>public class JavaEnvironment {<br>
&nbsp;&nbsp;&nbsp; public void someMethod(String someArg) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // ... do something<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; public void runScheme(String expression) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // ... all that setup code, and then:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; interpreter.define(...);&nbsp; // define this to be *ME*<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; interpreter.eval(expression);<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp; public static void main(String[] args) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; JavaEnvironment je = new JavaEnvironment();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; je.runScheme(&quot;(import s2j) ... (define-generic-java-method some-method) (some-method this)&quot;);<br>
&nbsp;&nbsp;&nbsp; }<br>}<br><br>See what I mean?&nbsp; I need to pass &quot;this&quot; into Scheme, and then scheme can essentially reenter the Java code.&nbsp; The called Java code will NOT re-call Scheme; i.e., there should never be a case of Java-&gt;Scheme-&gt;Java-&gt;Scheme, only Java-&gt;Scheme-&gt;Java.<br>
<br>Thanks again...<br><br>Mike<br><br><div class="gmail_quote">On Tue, Sep 2, 2008 at 3:56 PM, Antonio <span dir="ltr">&lt;<a href="mailto:[email protected]">[email protected]</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
What about interpreter.eval(&quot;(define foobar &#39;bar)&quot;); ?<br>
<br>
Mike J. Bell wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="Wj3C7c">
I&#39;m trying to integrate SISC as a Scheme interpreter into a larger, established product written in Java. &nbsp;Anybody else do this, open-source like, so I might peek at the ways and means? &nbsp;Any advice on trying to &quot;replicate&quot; a Java &quot;programmer&#39;s&quot; API inside SISC? &nbsp;(i.e., ways to automate all the (-&gt;jstring ...) and wrap/unwrap code that must go on with s2j).<br>

[snip]<br></div></div></blockquote><br>
</blockquote></div><br><br clear="all"><br>-- <br>Mike J. Bell on gmail<br>
</div>

------=_Part_14267_32823048.1220388500206--


--===============0824979249==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
--===============0824979249==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Sisc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sisc-users

--===============0824979249==--