Charles Boyd on Thu, 25 Aug 2011 07:16:12 +0200


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

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


Hello again,

Here is some code showing what I mean: gp_pipe.c

I haven't come up with a way to read the output correctly though.

This should end up being really simple, but if there is a better way to do it I would like to know.

- Charles

On Wed, Aug 24, 2011 at 10:50 PM, Charles Boyd <csboyd07@gmail.com> 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?

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:

// return a file descriptor for the gp process, or error status
int gp_start();

// evaluate a gp command and return output, or error message
const char *gp_eval(const char *cmd);

// terminate the gp process, returning exit status
int gp_kill(int pid);

Any suggestions/ideas about how to do this are greatly appreciated, as always.

- Charles