at:tutorial:symbiosis
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
at:tutorial:symbiosis [2008/10/22 18:31] – updated tvcutsem | at:tutorial:symbiosis [2013/05/17 20:25] (current) – updated tvcutsem | ||
---|---|---|---|
Line 11: | Line 11: | ||
When AmbientTalk values and Java values cross language boundaries (e.g. when they are passed as arguments of or return values from a method that is invoked from the other language), these values are converted. AmbientTalk features a number of built-in conversions that maps AmbientTalk' | When AmbientTalk values and Java values cross language boundaries (e.g. when they are passed as arguments of or return values from a method that is invoked from the other language), these values are converted. AmbientTalk features a number of built-in conversions that maps AmbientTalk' | ||
- | ^ Java type and value ^ AmbientTalk value ^ | + | ^ Java value : type ^ AmbientTalk value ^ |
| null: Object | nil | | | null: Object | nil | | ||
| n: int | a number n | | | n: int | a number n | | ||
Line 19: | Line 19: | ||
| array: T[] | a table (of converted values) | | | array: T[] | a table (of converted values) | | ||
| e: Exception | an exception e | | | e: Exception | an exception e | | ||
- | | c: Class | class wrapper(c) | | + | | c: Class | class wrapper( c ) | |
| o: ATObject | o | | | o: ATObject | o | | ||
| o: Type | java wrapper(o : Type) | | | o: Type | java wrapper(o : Type) | | ||
Line 33: | Line 33: | ||
| a class wrapper( c ) | c : Class | | | a class wrapper( c ) | c : Class | | ||
| a java wrapper(obj : Type) | obj : Type | | | a java wrapper(obj : Type) | obj : Type | | ||
- | | any object o | AT wrapper (o) : Interface | + | | any object o | AT wrapper (o) : I | |
Note that non-native Java or AmbientTalk objects are represented in the other language by means of " | Note that non-native Java or AmbientTalk objects are represented in the other language by means of " | ||
+ | |||
+ | In the last conversion rule of the second table, '' | ||
===== Accessing Java from within AmbientTalk ===== | ===== Accessing Java from within AmbientTalk ===== | ||
Line 49: | Line 51: | ||
A class is represented as a normal AmbientTalk object. All '' | A class is represented as a normal AmbientTalk object. All '' | ||
+ | |||
+ | < | ||
+ | If you want to load your own Java class make sure that the .class file is in the classpath of the JVM running AmbientTalk. By default, the iat script adds the standard $CLASSPATH classpath. | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Please do not name your own Java packages starting with a capital letter. Otherwise, AmbientTalk will confuse the package with a Java class. | ||
+ | </ | ||
==== Creating Java objects ==== | ==== Creating Java objects ==== | ||
Line 75: | Line 85: | ||
>>nil | >>nil | ||
>aVector | >aVector | ||
- | >>< | + | >>< |
</ | </ | ||
Line 169: | Line 179: | ||
>>42 | >>42 | ||
</ | </ | ||
+ | |||
==== Starting an AmbientTalk interpreter from Java ==== | ==== Starting an AmbientTalk interpreter from Java ==== | ||
Line 174: | Line 185: | ||
So far, the examples have illustrated how to reuse Java code from within AmbientTalk. They have shown how to access Java classes, instantiate them and invoke methods on the resulting objects. Moreover, | So far, the examples have illustrated how to reuse Java code from within AmbientTalk. They have shown how to access Java classes, instantiate them and invoke methods on the resulting objects. Moreover, | ||
- | Embedding AmbientTalk in an application, | + | Embedding AmbientTalk in an application, |
+ | |||
+ | Once an instance of an EmbeddableAmbientTalk subclass is created, the AmbientTalk VM can be started by sending it the '' | ||
< | < | ||
- | EmbeddedAmbientTalk | + | EmbeddableAmbientTalk |
vm.initialize( | vm.initialize( | ||
NATParser.parse( | NATParser.parse( | ||
Line 190: | Line 203: | ||
The code excerpt also illustrates that the EmbeddableAmbientTalk class provides methods to create definitions for fields such as '' | The code excerpt also illustrates that the EmbeddableAmbientTalk class provides methods to create definitions for fields such as '' | ||
- | Once the virtual machine is properly initialized, | + | Once the virtual machine is properly initialized, |
< | < | ||
Line 208: | Line 221: | ||
< | < | ||
- | When starting an AmbientTalk virtual machine from a Java application, | + | When starting an AmbientTalk virtual machine from a Java application, |
</ | </ |
at/tutorial/symbiosis.1224693105.txt.gz · Last modified: 2008/10/22 18:32 (external edit)