Bill Allombert on Fri, 26 Aug 2011 14:11:09 +0200

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: embedding GP in GUI applications (android-port)

On Wed, Aug 24, 2011 at 10:50:10PM -0400, Charles Boyd wrote:
> Hello,
> I have produced a statically compiled GP binary for Android, and now want to
> build a light graphical application to improve the usability of PARI/GP on
> Android <>.
> Android applications are written in Java, and may interface with native
> C/C++ functions via the Java Native Interface (JNI).
> Is there a relatively simple way to send commands for evaluation by GP from
> an external application?

There is a distinction to make between the gp programm and the GP interpreter. 
The gp programm is a standalone exectutable that provide an interface to the
GP interpretor which is included in libpari. In the context of a graphical
application you probably want to use the GP interpreter directly since gp mostly 
provide the text-based user interface which you do not need.

> For example, if it is possible to embed the GP interpreter in a C program
> (similar to Python embedding <>) --
> then I could write a small wrapper library in C that interfaces with GP and
> then load this library in the Java GUI application via JNI. For example,
> this library would provide simple functions...roughly prototyped as:

Yes, you can embed the GP interpretor in your C program, since the GP interpretor
is part of the libpari library. See examples/minigp.c in the distribution for
an example.

Basically you do
out = gp_read_str(in);
where 'in' is the input and 'out' is the output.
You can convert 'out' to a char * using GENtostr.