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. Like:<br><br>public class JavaEnvironment {<br>
public void someMethod(String someArg) {<br> // ... do something<br> }<br><br> public void runScheme(String expression) {<br> // ... all that setup code, and then:<br> interpreter.define(...); // define this to be *ME*<br>
interpreter.eval(expression);<br> }<br><br> public static void main(String[] args) {<br> JavaEnvironment je = new JavaEnvironment();<br> je.runScheme("(import s2j) ... (define-generic-java-method some-method) (some-method this)");<br>
}<br>}<br><br>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.<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"><<a href="mailto:[email protected]">[email protected]</a>></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("(define foobar 'bar)"); ?<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'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).<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==--