Re: Java enum in JPL
Paul Singleton <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Organization | Jambusters Ltd |
| Message-ID | <[email protected]> |
JPL was conceived before Java acquired enums (in 1.5) and is still
compiled to target Java 1.4, so it is enum-oblivious :-/
It's a JNI application, and so I guess we first need to understand how
the JNI handles enums.
JPL is entirely "call-by-name", so maybe it should treat enums as
opaque values; first you would jpl_get/3 the value of the named enum
field, then pass it back as an arg?
Do enums correspond to anything which Java 1.4 knows about?
How would we do this from C/C++?
Paul Singleton
On 18/07/2013 12:14, Jerry wrote:
> All,
>
> I have been researching the web to find out how to create enum variables in
> JPL. So far I have found now examples and trial and error has been mostly
> error. Here is the fragment I need to emulate from SWI Prolog:
>
>
> ArrayList< String > namesOfInterest = new ArrayList< String >();
>
> AppTierSourceUsageRequestMessage.MessageType messageType =
> getInvokeArgs( args, namesOfInterest );
>
> ArrayList< String > result = null;
>
> try {
> result = invoke( messageType, namesOfInterest );
> }
> catch( CannotProcessException ex ) {
> System.out.println( "MakeAppTierRequest.invoke() failed! Got ex=" +
> ex );
> System.exit( 1 );
> }
>
>
> MessageType is an enum. I know how to make an array of strings as needed
> for the 2nd argument of invoke but not so much luck with the first
> argument. I want to pass the constant enum value:
> GET_FILE_NAMES_AND_TOKEN_NAMES.
>
> My call so far looks like:
>
> jpl_call( 'com.xxxxxx.xxxxx.messages.MakeAppTierRequest', invoke,
> ['????',Ac], F),
> Ac is an array of Strings and seems to be correct.
>
>
> Any thoughts or example uses of enum variables in JPL would be appreciated!
>
> Thanks!
>
> Jerry
> -------------- next part --------------
> HTML attachment scrubbed and removed
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>