droid
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
//
|
||||
// Created by vsc on 7/6/17.
|
||||
// Created by vsc on 7/6/17->
|
||||
//
|
||||
/* File : example.cxx */
|
||||
/* File : example->cxx */
|
||||
|
||||
#include "streamer.h"
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern void Java_pt_up_yap_streamerJNI_swig_1module_1init(void);
|
||||
|
||||
}
|
||||
|
||||
static AndroidStreamer * streamerInstance = 0;
|
||||
|
||||
void setStreamer(AndroidStreamer* streamer) {
|
||||
streamerInstance = streamer;
|
||||
Java_pt_up_yap_streamerJNI_swig_1module_1init();
|
||||
}
|
||||
|
||||
AndroidStreamer& getStreamer() {
|
||||
@@ -25,13 +31,11 @@ extern "C" {
|
||||
#include <yapio.h>
|
||||
#include <iopreds.h>
|
||||
|
||||
extern void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void);
|
||||
|
||||
static VFS_t andstream;
|
||||
|
||||
void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void) {
|
||||
// streamerInstance = 0;
|
||||
} ;
|
||||
|
||||
static VFS_t *andstream;
|
||||
|
||||
|
||||
static std::string buff0;
|
||||
|
||||
@@ -83,21 +87,34 @@ streamerInstance->display(buff0);
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
AndroidStreamer::bind() {
|
||||
buff0 = *new std::string[256];
|
||||
andstream.name = "/android/user_error";
|
||||
andstream.vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX;
|
||||
andstream.prefix = "/android";
|
||||
andstream.suffix = NULL;
|
||||
andstream.open = and_open;
|
||||
andstream.close = and_close;
|
||||
andstream.get_char = and_get;
|
||||
andstream.put_char = and_put;
|
||||
andstream.flush = and_flush;
|
||||
andstream.seek = and_seek;
|
||||
andstream.next = GLOBAL_VFS;
|
||||
GLOBAL_VFS = &andstream;
|
||||
Yap_InitStdStream(StdOutStream, Output_Stream_f | Append_Stream_f, NULL, &andstream);
|
||||
Yap_InitStdStream(StdErrStream, Output_Stream_f | Append_Stream_f, NULL, &andstream);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
||||
void Java_pt_up_yap_streamerJNI_swig_1module_1init(void) {
|
||||
if (andstream)
|
||||
return;
|
||||
andstream = new VFS_t();
|
||||
|
||||
andstream->name = "android output window";
|
||||
andstream->vflags = VFS_CAN_WRITE | VFS_HAS_PREFIX;
|
||||
andstream->prefix = "/android";
|
||||
andstream->suffix = NULL;
|
||||
andstream->open = and_open;
|
||||
andstream->close = and_close;
|
||||
andstream->get_char = and_get;
|
||||
andstream->put_char = and_put;
|
||||
andstream->flush = and_flush;
|
||||
andstream->seek = and_seek;
|
||||
andstream->next = GLOBAL_VFS;
|
||||
GLOBAL_VFS = andstream;
|
||||
|
||||
YAP_Term ts[1], args[1], goal;
|
||||
ts[0] = MkAtomTerm(Yap_LookupAtom("android"));
|
||||
args[0] = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("library"),1), 1, ts);
|
||||
goal = Yap_MkApplTerm(Yap_MkFunctor(Yap_LookupAtom("compile"),1), 1, args);
|
||||
YAP_RunGoalOnce(goal);
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user