Revision: 6024
Author: iratqq
Date: Sat Oct 10 22:22:36 2009
Log: * configure.ac:
- Add check libffi.
* uim/Makefile.am:
- Add FFI case to create modle 'ffi' and 'lolevel'.
* uim/ffi.c:
- New file. operating libffi.
* uim/lolevel.c:
- New file. chicken like low level memory accress utilities.
Add new module for accessing libffi.
If you want to load DSO without compiling uim module,
this module may be helpful.
uim> (module-load "ffi")
uim> (define libm
(dlopen "libm.so" (assq-cdr '$RTLD_LAZY (dlopen-mode))))
uim> (define atan (dlsym libm "atan"))
uim> (ffi-call 'double atan '((double . "1.0"))) ;; => pi/4
uim> (dlclose libm)
http://code.google.com/p/uim/source/detail?r=6024
Added:
/trunk/uim/ffi.c
/trunk/uim/lolevel.c
Modified:
/trunk/configure.ac
/trunk/uim/Makefile.am
=======================================
--- /dev/null
+++ /trunk/uim/ffi.c Sat Oct 10 22:22:36 2009
@@ -0,0 +1,404 @@
+/*
+
+ Copyright (c) 2009 uim Project http://code.google.com/p/uim/
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+#include <errno.h>
+#include <dlfcn.h>
+#include <ffi.h>
+
+#include "uim.h"
+#include "uim-scm.h"
+#include "uim-scm-abbrev.h"
+#include "uim-posix.h"
+#include "uim-notify.h"
+#include "dynlib.h"
+
+static const char *ffi_strerr_;
+
+typedef struct {
+ int flag;
+ char *arg;
+} opt_args;
+
+static uim_lisp
+make_arg_cons(const opt_args *arg)
+{
+ return CONS(MAKE_SYM(arg->arg), MAKE_INT(arg->flag));
+}
+
+static uim_lisp
+make_arg_list(const opt_args *list)
+{
+ uim_lisp ret_;
+ int i = 0;
+
+ ret_ = uim_scm_null();
+ while (list[i].arg != 0) {
+ ret_ =
CONS((uim_lisp)uim_scm_call_with_gc_ready_stack((uim_gc_gate_func_ptr)make_arg_cons,
+ (void
*)&list[i]), ret_);
+ i++;
+ }
+ return ret_;
+}
+
+static const opt_args dlopen_mode[] = {
+#ifdef RTLD_LAZY
+ { RTLD_LAZY, "$RTLD_LAZY" },
+#endif
+#ifdef RTLD_NOW
+ { RTLD_NOW, "$RTLD_NOW" },
+#endif
+#ifdef RTLD_GLOBAL
+ { RTLD_GLOBAL, "$RTLD_GLOBAL" },
+#endif
+#ifdef RTLD_LOCAL
+ { RTLD_LOCAL, "$RTLD_LOCAL" },
+#endif
+#ifdef DL_LAZY
+ { DL_LAZY, "$DL_LAZY" },
+#endif
+#ifdef RTLD_TRACE
+ { RTLD_TRACE, "$RTLD_TRACE" },
+#endif
+ { 0, 0 }
+};
+
+static uim_lisp uim_lisp_dlopen_mode_;
+static uim_lisp
+c_uim_lisp_dlopen_mode(void)
+{
+ return uim_lisp_dlopen_mode_;
+}
+
+static uim_lisp
+c_dlstrerr(void)
+{
+ return MAKE_STR(ffi_strerr_);
+}
+
+static uim_lisp
+c_dlopen(uim_lisp path_, uim_lisp mode_)
+{
+ const char *s;
+ void *handle = dlopen(REFER_C_STR(path_), C_INT(mode_));
+
+ if ((s = dlerror()) != NULL) {
+ ffi_strerr_ = s;
+ return uim_scm_f();
+ }
+ ffi_strerr_ = NULL;
+ return MAKE_PTR(handle);
+}
+
+static uim_lisp
+c_dlclose(uim_lisp handle_)
+{
+ if (!PTRP(handle_))
+ return uim_scm_f();
+ dlclose(C_PTR(handle_));
+ ffi_strerr_ = NULL;
+ return uim_scm_t();
+}
+
+static uim_lisp
+c_dlsym(uim_lisp handle_, uim_lisp symbol_)
+{
+ const char *s;
+ void *fun;
+
+ fun = dlsym(C_PTR(handle_), REFER_C_STR(symbol_));
+ if ((s = dlerror()) != NULL) {
+ ffi_strerr_ = s;
+ return uim_scm_f();
+ }
+ ffi_strerr_ = NULL;
+ return MAKE_PTR(fun);
+}
+
+typedef enum {
+ RET_UNKNOWN,
+ RET_UCHAR, RET_SCHAR,
+ RET_UINT, RET_SINT,
+ RET_DOUBLE,
+ RET_STR,
+ RET_PTR,
+ RET_SCM
+} object_type;
+
+#define FFI_STRERR_BAD_TYPEDEF 0
+#define FFI_STRERR_BAD_ABI 1
+#define FFI_STRERR_UNKOWN 2
+
+static const char *ffi_strerr_messages[] = {
+ "ffi_prep_cif: FFI_BAD_TYPEDEF\n",
+ "ffi_prep_cif: FFI_BAD_ABI\n",
+ "ffi_prep_cif: unkown error\n"
+};
+
+static object_type
+select_object_type(uim_lisp type_)
+{
+ if (strcmp(REFER_C_STR(type_), "unsigned-char") == 0)
+ return RET_UCHAR;
+ if (strcmp(REFER_C_STR(type_), "signed-char") == 0)
+ return RET_SCHAR;
+ if (strcmp(REFER_C_STR(type_), "char") == 0)
+ return RET_SCHAR;
+ if (strcmp(REFER_C_STR(type_), "unsigned-int") == 0)
+ return RET_SINT;
+ if (strcmp(REFER_C_STR(type_), "signed-int") == 0)
+ return RET_SINT;
+ if (strcmp(REFER_C_STR(type_), "int") == 0)
+ return RET_SINT;
+ if (strcmp(REFER_C_STR(type_), "double") == 0)
+ return RET_DOUBLE;
+ if (strcmp(REFER_C_STR(type_), "string") == 0)
+ return RET_STR;
+ if (strcmp(REFER_C_STR(type_), "pointer") == 0)
+ return RET_PTR;
+ if (strcmp(REFER_C_STR(type_), "scheme-object") == 0)
+ return RET_SCM;
+
+ ERROR_OBJ("unknown object type", type_);
+ return RET_UNKNOWN;
+}
+
+static uim_lisp
+c_ffi_call(uim_lisp result_, uim_lisp fun_, uim_lisp argv_)
+{
+ ffi_cif cif;
+ ffi_type **arg_types;
+ void **arg_values;
+ ffi_status status;
+ ffi_type *result_type = NULL;
+ void *result;
+ int args;
+ int i;
+ void *p;
+ uim_lisp ret_;
+ object_type return_object_type;
+
+ args = uim_scm_length(argv_);
+ arg_types = uim_malloc(args * sizeof(void *));
+ arg_values = uim_malloc(args * sizeof(ffi_type *));
+
+ return_object_type = select_object_type(result_);
+
+ switch (return_object_type) {
+ case RET_UNKNOWN:
+ break;
+ case RET_UCHAR:
+ result_type = &ffi_type_uchar;
+ break;
+ case RET_SCHAR:
+ result_type = &ffi_type_schar;
+ break;
+ case RET_UINT:
+ result_type = &ffi_type_uint;
+ break;
+ case RET_SINT:
+ result_type = &ffi_type_sint;
+ break;
+ case RET_DOUBLE:
+ result_type = &ffi_type_double;
+ break;
+ case RET_STR:
+ result_type = &ffi_type_pointer;
+ break;
+ case RET_PTR:
+ result_type = &ffi_type_pointer;
+ break;
+ case RET_SCM:
+ result_type = &ffi_type_pointer;
+ break;
+ }
+
+ result = uim_malloc(1024); /* huge? */
+
+ for (i = 0; i < args; i++) {
+ uim_lisp arg_ = CAR(argv_);
+
+ switch (select_object_type(CAR(arg_))) {
+ case RET_UNKNOWN:
+ break;
+ case RET_UCHAR:
+ p = uim_malloc(sizeof(unsigned char));
+ *((unsigned char *)p) = C_CHAR(CDR(arg_));
+ arg_types[i] = &ffi_type_uchar;
+ arg_values[i] = p;
+ break;
+ case RET_SCHAR:
+ p = uim_malloc(sizeof(signed char));
+ *((signed char *)p) = C_CHAR(CDR(arg_));
+ arg_types[i] = &ffi_type_schar;
+ arg_values[i] = p;
+ break;
+ case RET_UINT:
+ p = uim_malloc(sizeof(unsigned int));
+ *((unsigned int *)p) = C_INT(CDR(arg_));
+ arg_types[i] = &ffi_type_uint;
+ arg_values[i] = p;
+ break;
+ case RET_SINT:
+ p = uim_malloc(sizeof(signed int));
+ *((signed int *)p) = C_INT(CDR(arg_));
+ arg_types[i] = &ffi_type_sint;
+ arg_values[i] = p;
+ break;
+ case RET_DOUBLE:
+ {
+ char *endptr;
+ p = uim_malloc(sizeof(double));
+ *((double *)p) = strtod(REFER_C_STR(CDR(arg_)), &endptr);
+ arg_types[i] = &ffi_type_double;
+ arg_values[i] = p;
+ }
+ break;
+ case RET_STR:
+ p = uim_malloc(sizeof(void *));
+ *((void **)p) = (void *)REFER_C_STR(CDR(arg_));
+ arg_types[i] = &ffi_type_pointer;
+ arg_values[i] = p;
+ break;
+ case RET_PTR:
+ p = uim_malloc(sizeof(void *));
+ if (NULLP(CDR(arg_)))
+ *((void **)p) = NULL;
+ else
+ *((void **)p) = C_PTR(CDR(arg_));
+ arg_types[i] = &ffi_type_pointer;
+ arg_values[i] = p;
+ case RET_SCM:
+ p = uim_malloc(sizeof(void *));
+ *((void **)p) = CDR(arg_);
+ arg_types[i] = &ffi_type_pointer;
+ arg_values[i] = p;
+ }
+ argv_ = CDR(argv_);
+ }
+
+ status = ffi_prep_cif(&cif, FFI_DEFAULT_ABI, args, result_type,
arg_types);
+ switch (status) {
+ case FFI_OK:
+ break;
+ case FFI_BAD_TYPEDEF:
+ ffi_strerr_ = ffi_strerr_messages[FFI_STRERR_BAD_TYPEDEF];
+ break;
+ case FFI_BAD_ABI:
+ ffi_strerr_ = ffi_strerr_messages[FFI_STRERR_BAD_ABI];
+ break;
+ default:
+ ffi_strerr_ = ffi_strerr_messages[FFI_STRERR_UNKOWN];
+ }
+
+ if (status == FFI_OK)
+ ffi_call(&cif, (void (*)(void))C_PTR(fun_), result, arg_values);
+
+ for (i = 0; i < args; i++)
+ free(arg_values[i]);
+ free(arg_types);
+ free(arg_values);
+
+ if (status != FFI_OK) {
+ free(result);
+ return uim_scm_f();
+ }
+ ret_ = uim_scm_f();
+
+ switch (return_object_type) {
+ case RET_UNKNOWN:
+ break;
+ case RET_UCHAR:
+ ret_ = MAKE_CHAR(*(unsigned char *)result);
+ break;
+ case RET_SCHAR:
+ ret_ = MAKE_CHAR(*(signed char *)result);
+ break;
+ case RET_UINT:
+ ret_ = MAKE_INT(*(unsigned int *)result);
+ break;
+ case RET_SINT:
+ ret_ = MAKE_INT(*(signed int *)result);
+ break;
+ case RET_DOUBLE:
+ {
+ char str[1024];
+ snprintf(str, sizeof(str), "%f", *((double *)result));
+ ret_ = MAKE_STR(str);
+ }
+ break;
+ case RET_STR:
+ ret_ = MAKE_STR(*((char **)result));
+ break;
+ case RET_PTR:
+ ret_ = MAKE_PTR(*((void **)result));
+ break;
+ case RET_SCM:
+ ret_ = *(uim_lisp *)result;
+ break;
+ }
+
+ free(result);
+
+ ffi_strerr_ = NULL;
+
+ return ret_;
+}
+
+
+void
+uim_plugin_instance_init(void)
+{
+ uim_scm_init_proc0("dlstrerr", c_dlstrerr);
+
+ uim_lisp_dlopen_mode_ = make_arg_list(dlopen_mode);
+ uim_scm_gc_protect(&uim_lisp_dlopen_mode_);
+ uim_scm_init_proc0("dlopen-mode", c_uim_lisp_dlopen_mode);
+ uim_scm_init_proc2("dlopen", c_dlopen);
+
+ uim_scm_init_proc1("dlclose", c_dlclose);
+ uim_scm_init_proc2("dlsym", c_dlsym);
+
+ uim_scm_init_proc3("ffi-call", c_ffi_call);
+}
+
+void
+uim_plugin_instance_quit(void)
+{
+ uim_scm_gc_unprotect(&uim_lisp_dlopen_mode_);
+}
=======================================
--- /dev/null
+++ /trunk/uim/lolevel.c Sat Oct 10 22:22:36 2009
@@ -0,0 +1,238 @@
+/*
+
+ Copyright (c) 2009 uim Project http://code.google.com/p/uim/
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ 3. Neither the name of authors nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
IS'' AND
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+*/
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdint.h>
+
+#include "uim.h"
+#include "uim-scm.h"
+#include "uim-scm-abbrev.h"
+#include "uim-posix.h"
+#include "uim-notify.h"
+#include "dynlib.h"
+
+static uim_lisp
+c_allocate(uim_lisp len_)
+{
+ return MAKE_PTR(malloc(C_INT(len_)));
+}
+static uim_lisp
+c_free(uim_lisp pointer_)
+{
+ free(C_PTR(pointer_));
+ return uim_scm_t();
+}
+static uim_lisp
+
+c_memory_fill(uim_lisp pointer_, uim_lisp c_, uim_lisp len_)
+{
+ memset(C_PTR(pointer_), C_INT(c_), C_INT(len_));
+ return uim_scm_t();
+}
+static uim_lisp
+c_memory_move(uim_lisp dest_, uim_lisp src_, uim_lisp len_)
+{
+ memmove(C_PTR(dest_), C_PTR(src_), C_INT(len_));
+ return uim_scm_t();
+}
+
+static uim_lisp
+c_null_pointer(void)
+{
+ return MAKE_PTR(NULL);
+}
+
+static uim_lisp
+c_pointer_offset(uim_lisp pointer_, uim_lisp nth_)
+{
+ return MAKE_PTR((char *)C_PTR(pointer_) + C_INT(nth_));
+}
+
+#define c_pointer_X_ref(X, type) \
+ static uim_lisp \
+ c_pointer_ ## X ## _ref(uim_lisp pointer_) \
+ { \
+ type *p = C_PTR(pointer_); \
+ return MAKE_INT(*p); \
+ }
+
+c_pointer_X_ref(u8, uint8_t)
+c_pointer_X_ref(s8, int8_t)
+c_pointer_X_ref(u16, uint16_t)
+c_pointer_X_ref(s16, int16_t)
+c_pointer_X_ref(u32, uint32_t)
+c_pointer_X_ref(s32, int32_t)
+c_pointer_X_ref(u64, uint64_t)
+c_pointer_X_ref(s64, int64_t)
+
+#define c_pointer_X_set(X, type) \
+ static uim_lisp \
+ c_pointer_ ## X ## _set(uim_lisp pointer_, uim_lisp val_) \
+ { \
+ type *p = C_PTR(pointer_); \
+ *p = C_INT(val_); \
+ return uim_scm_t(); \
+ }
+
+c_pointer_X_set(u8, uint8_t)
+c_pointer_X_set(s8, int8_t)
+c_pointer_X_set(u16, uint16_t)
+c_pointer_X_set(s16, int16_t)
+c_pointer_X_set(u32, uint32_t)
+c_pointer_X_set(s32, int32_t)
+c_pointer_X_set(u64, uint64_t)
+c_pointer_X_set(s64, int64_t)
+
+static uim_lisp
+c_string_to_pointer(uim_lisp str_)
+{
+ return MAKE_PTR(C_STR(str_));
+}
+static uim_lisp
+c_pointer_to_string(uim_lisp pointer_)
+{
+ return MAKE_STR(C_PTR(pointer_));
+}
+
+
+#define c_Xlist_to_pointer(X, type) \
+ static uim_lisp \
+ c_ ## X ## list_to_pointer(uim_lisp l_) \
+ { \
+ type *p; \
+ int i, len = uim_scm_length(l_); \
+ \
+ p = malloc(len * sizeof(type)); \
+ for (i = 0; i < len; i++) { \
+ uim_lisp h_ = CAR(l_); \
+ \
+ p[i] = (type)C_INT(h_); \
+ l_ = CDR(l_); \
+ } \
+ return MAKE_PTR(p);
\
+ }
+
+c_Xlist_to_pointer(s8, int8_t)
+c_Xlist_to_pointer(u8, uint8_t)
+c_Xlist_to_pointer(s16, int16_t)
+c_Xlist_to_pointer(u16, uint16_t)
+c_Xlist_to_pointer(s32, int32_t)
+c_Xlist_to_pointer(u32, uint32_t)
+c_Xlist_to_pointer(s64, int64_t)
+c_Xlist_to_pointer(u64, uint64_t)
+
+#define c_pointer_to_Xlist(X, type) \
+ static uim_lisp \
+ c_pointer_to_ ## X ## list(uim_lisp pointer_, uim_lisp len_) \
+ { \
+ uim_lisp ret_ = uim_scm_null(); \
+ type *p = C_PTR(pointer_); \
+ int len = C_INT(len_); \
+ int i; \
+ \
+ for (i = 0; i < len; i++) \
+ ret_ = CONS(MAKE_INT(*p++), ret_); \
+ return uim_scm_callf("reverse", "o", ret_); \
+ }
+
+c_pointer_to_Xlist(u8, uint8_t)
+c_pointer_to_Xlist(s8, int8_t)
+c_pointer_to_Xlist(u16, uint16_t)
+c_pointer_to_Xlist(s16, int16_t)
+c_pointer_to_Xlist(u32, uint32_t)
+c_pointer_to_Xlist(s32, int32_t)
+c_pointer_to_Xlist(u64, uint64_t)
+c_pointer_to_Xlist(s64, int64_t)
+
+
+void
+uim_plugin_instance_init(void)
+{
+ uim_scm_init_proc1("allocate", c_allocate);
+ uim_scm_init_proc1("free", c_free);
+
+ uim_scm_init_proc3("memory-fill!", c_memory_fill);
+ uim_scm_init_proc3("memory-move!", c_memory_move);
+
+ uim_scm_init_proc0("null-pointer", c_null_pointer);
+
+ uim_scm_init_proc2("pointer-offset", c_pointer_offset);
+
+ uim_scm_init_proc1("pointer-u8-ref", c_pointer_u8_ref);
+ uim_scm_init_proc1("pointer-s8-ref", c_pointer_s8_ref);
+ uim_scm_init_proc1("pointer-u16-ref", c_pointer_u16_ref);
+ uim_scm_init_proc1("pointer-s16-ref", c_pointer_s16_ref);
+ uim_scm_init_proc1("pointer-u32-ref", c_pointer_u32_ref);
+ uim_scm_init_proc1("pointer-s32-ref", c_pointer_s32_ref);
+ uim_scm_init_proc1("pointer-u64-ref", c_pointer_u64_ref);
+ uim_scm_init_proc1("pointer-s64-ref", c_pointer_s64_ref);
+
+ uim_scm_init_proc2("pointer-u8-set!", c_pointer_u8_set);
+ uim_scm_init_proc2("pointer-s8-set!", c_pointer_s8_set);
+ uim_scm_init_proc2("pointer-u16-set!", c_pointer_u16_set);
+ uim_scm_init_proc2("pointer-s16-set!", c_pointer_s16_set);
+ uim_scm_init_proc2("pointer-u32-set!", c_pointer_u32_set);
+ uim_scm_init_proc2("pointer-s32-set!", c_pointer_s32_set);
+ uim_scm_init_proc2("pointer-u64-set!", c_pointer_u64_set);
+ uim_scm_init_proc2("pointer-s64-set!", c_pointer_s64_set);
+
+ uim_scm_init_proc1("string->pointer", c_string_to_pointer);
+ uim_scm_init_proc1("pointer->string", c_pointer_to_string);
+
+ uim_scm_init_proc1("u8list->pointer", c_u8list_to_pointer);
+ uim_scm_init_proc1("s8list->pointer", c_s8list_to_pointer);
+ uim_scm_init_proc1("u16list->pointer", c_u16list_to_pointer);
+ uim_scm_init_proc1("s16list->pointer", c_s16list_to_pointer);
+ uim_scm_init_proc1("u32list->pointer", c_u32list_to_pointer);
+ uim_scm_init_proc1("s32list->pointer", c_s32list_to_pointer);
+ uim_scm_init_proc1("u64list->pointer", c_u64list_to_pointer);
+ uim_scm_init_proc1("s64list->pointer", c_s64list_to_pointer);
+
+ uim_scm_init_proc2("pointer->u8list", c_pointer_to_u8list);
+ uim_scm_init_proc2("pointer->s8list", c_pointer_to_s8list);
+ uim_scm_init_proc2("pointer->u16list", c_pointer_to_u16list);
+ uim_scm_init_proc2("pointer->s16list", c_pointer_to_s16list);
+ uim_scm_init_proc2("pointer->u32list", c_pointer_to_u32list);
+ uim_scm_init_proc2("pointer->s32list", c_pointer_to_s32list);
+ uim_scm_init_proc2("pointer->u64list", c_pointer_to_u64list);
+ uim_scm_init_proc2("pointer->s64list", c_pointer_to_s64list);
+}
+
+void
+uim_plugin_instance_quit(void)
+{
+}
=======================================
--- /trunk/configure.ac Sat Sep 26 12:33:47 2009
+++ /trunk/configure.ac Sat Oct 10 22:22:36 2009
@@ -298,6 +298,22 @@
use_sqlite3="no"
])
+# ************************
+# *** Tests for libffi ***
+# ************************
+AC_ARG_WITH(curl,
+ AS_HELP_STRING([--with-ffi], [Build with libffi
+ @<:@default=no@:>@]),
+ [
+ if test "x$with_ffi" = "xyes"; then
+ PKG_CHECK_MODULES(FFI, libffi >= 3.0.0, use_ffi="yes",
use_ffi="no")
+ else
+ use_ffi="no"
+ fi
+ ],[
+ use_ffi="no"
+])
+
PKG_CHECK_MODULES(X11, x11, x11_use_new_dir="yes", x11_use_new_dir="no")
AC_PATH_XTRA
@@ -1075,6 +1091,7 @@
AM_CONDITIONAL(EXPAT, test x$expat_found = xyes)
AM_CONDITIONAL(OPENSSL, test x$use_openssl = xyes)
AM_CONDITIONAL(SQLITE3, test x$use_sqlite3 = xyes)
+AM_CONDITIONAL(FFI, test x$use_ffi = xyes)
AM_CONDITIONAL(GTK2, test x$use_gtk2 = xyes)
AM_CONDITIONAL(GTK2_4, test x$use_gtk2_4 = xyes)
AM_CONDITIONAL(DEFAULT_TOOLKIT_GTK, test x$default_toolkit = xgtk)
@@ -1697,6 +1714,7 @@
expat : ${expat_found}
OpenSSL : ${use_openssl}
SQLite3 : ${use_sqlite3}
+ ffi : ${use_ffi}
Gtk+ : ${use_gtk2}
Gnome Applet : ${use_applet_gnome}
Qt3 : ${use_qt}
=======================================
--- /trunk/uim/Makefile.am Mon Aug 17 04:12:15 2009
+++ /trunk/uim/Makefile.am Sat Oct 10 22:22:36 2009
@@ -182,6 +182,20 @@
libuim_sqlite3_la_CPPFLAGS = -I$(top_srcdir) @SQLITE3_CFLAGS@
endif
+if FFI
+uim_plugin_LTLIBRARIES += libuim-ffi.la
+libuim_ffi_la_SOURCES = ffi.c
+libuim_ffi_la_LIBADD = @FFI_LIBS@ libuim.la
+libuim_ffi_la_LDFLAGS = -rpath $(uim_plugindir) -avoid-version -module
+libuim_ffi_la_CPPFLAGS = -I$(top_srcdir) @FFI_CFLAGS@
+
+uim_plugin_LTLIBRARIES += libuim-lolevel.la
+libuim_lolevel_la_SOURCES = lolevel.c
+libuim_lolevel_la_LIBADD = libuim.la
+libuim_lolevel_la_LDFLAGS = -rpath $(uim_plugindir) -avoid-version -module
+libuim_lolevel_la_CPPFLAGS = -I$(top_srcdir)
+endif
+
uim_plugin_LTLIBRARIES += libuim-skk.la
libuim_skk_la_SOURCES = skk.c bsdlook.h
libuim_skk_la_LIBADD = libuim-scm.la libuim.la libuim-bsdlook.la @NETLIBS@