summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-10-05 21:45:52 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-10-05 21:45:52 +0200
commite65feb6fd3d035f06f7439c79b5eea37946eea5e (patch)
treecedd91d741161e7f5bc45b50a1006905699a5ecd
parent3639520b85a4c05334b7e8920d42a33b0831c3f0 (diff)
downloadeva-e65feb6fd3d035f06f7439c79b5eea37946eea5e.zip
eva-e65feb6fd3d035f06f7439c79b5eea37946eea5e.tar
Include erl_interface.vapi
-rw-r--r--.gitmodules3
-rw-r--r--CMakeLists.txt5
m---------cmake/erlang0
-rw-r--r--src/CMakeLists.txt10
-rw-r--r--test/CMakeLists.txt9
-rw-r--r--vapi/erl_interface.vapi162
6 files changed, 179 insertions, 10 deletions
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..565d4bc
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "cmake/erlang"]
+ path = cmake/erlang
+ url = git://git.universe-factory.net/cmake-erlang
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 844570d..e3d1e8f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
project("eva" C)
cmake_minimum_required(VERSION 2.6)
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/vala)
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/erlang ${CMAKE_SOURCE_DIR}/cmake/vala)
include(ValaPrecompile)
include(ValaVersion)
@@ -8,12 +8,13 @@ include(ValaVersion)
find_package(Vala REQUIRED)
ensure_vala_version("0.8" MINIMUM)
+find_package(Erlang REQUIRED)
+erl_check_library(EI REQUIRED erl_interface)
find_package(PkgConfig)
pkg_check_modules(GEE REQUIRED gee-1.0)
pkg_check_modules(GIO REQUIRED gio-2.0)
pkg_check_modules(GIO_UNIX REQUIRED gio-unix-2.0)
-pkg_check_modules(ERL REQUIRED erl_interface)
add_subdirectory(src)
add_subdirectory(test)
diff --git a/cmake/erlang b/cmake/erlang
new file mode 160000
+Subproject ecc44209d33f59c7c653b1527253a5cfd7227ce
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f6208a6..0a431a6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,7 @@
-add_definitions(${GEE_CFLAGS} ${GEE_CFLAGS_OTHER} ${GIO_CFLAGS} ${GIO_CFLAGS_OTHER} ${ERL_CFLAGS} ${ERL_CFLAGS_OTHER})
-link_libraries(${GEE_LIBRARIES} ${GIO_LIBRARIES} ${ERL_LIBRARIES})
-link_directories(${GEE_LIBRARY_DIRS} ${GIO_LIBRARY_DIRS} ${ERL_LIBRARY_DIRS})
+add_definitions(${GEE_CFLAGS} ${GEE_CFLAGS_OTHER} ${GIO_CFLAGS} ${GIO_CFLAGS_OTHER})
+include_directories(${EI_INCLUDE_DIR})
+link_libraries(${GEE_LIBRARIES} ${GIO_LIBRARIES} "${EI_LIBRARY_DIR}/libei.a")
+link_directories(${GEE_LIBRARY_DIRS} ${GIO_LIBRARY_DIRS})
vala_precompile(EVA_C
Atom.vala
@@ -20,10 +21,11 @@ vala_precompile(EVA_C
UInt.vala
Util.vala
Var.vala
+CUSTOM_VAPIS
+ ${eva_SOURCE_DIR}/vapi/erl_interface.vapi
PACKAGES
gee-1.0
gio-2.0
- erl_interface
GENERATE_VAPI
eva
)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index bad2b58..810a90d 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,6 +1,7 @@
-add_definitions(${GEE_CFLAGS} ${GEE_CFLAGS_OTHER} ${GIO_CFLAGS} ${GIO_CFLAGS_OTHER} ${GIO_UNIX_CFLAGS} ${GIO_UNIX_CFLAGS_OTHER} ${ERL_CFLAGS} ${ERL_CFLAGS_OTHER})
-link_libraries(${GEE_LIBRARIES} ${GIO_LIBRARIES} ${GIO_UNIX_LIBRARIES} ${ERL_LIBRARIES})
-link_directories(${GEE_LIBRARY_DIRS} ${GIO_LIBRARY_DIRS} ${GIO_UNIX_LIBRARY_DIRS} ${ERL_LIBRARY_DIRS})
+add_definitions(${GEE_CFLAGS} ${GEE_CFLAGS_OTHER} ${GIO_CFLAGS} ${GIO_CFLAGS_OTHER} ${GIO_UNIX_CFLAGS} ${GIO_UNIX_CFLAGS_OTHER})
+include_directories(${EI_INCLUDE_DIR})
+link_libraries(${GEE_LIBRARIES} ${GIO_LIBRARIES} ${GIO_UNIX_LIBRARIES})
+link_directories(${GEE_LIBRARY_DIRS} ${GIO_LIBRARY_DIRS} ${GIO_UNIX_LIBRARY_DIRS})
vala_precompile(TEST_C
Test.vala
@@ -8,8 +9,8 @@ PACKAGES
gee-1.0
gio-2.0
gio-unix-2.0
- erl_interface
CUSTOM_VAPIS
+ ${eva_SOURCE_DIR}/vapi/erl_interface.vapi
${eva_BINARY_DIR}/src/eva.vapi
)
diff --git a/vapi/erl_interface.vapi b/vapi/erl_interface.vapi
new file mode 100644
index 0000000..55b89c2
--- /dev/null
+++ b/vapi/erl_interface.vapi
@@ -0,0 +1,162 @@
+[CCode (cheader_filename = "ei.h", cprefix = "ei_", lower_case_cprefix = "ei_")]
+namespace Erl {
+ /*public int errno;
+
+ [CCode (cname = "ei_cnode")]
+ [Compact]
+ public struct Node {
+ [CCode (cname = "ei_connect_init")]
+ public Node(string this_node_name, string cookie, short creation);
+
+ public Connection connect(string nodename);
+
+ public Pid* self();
+ }
+
+ [CCode (cname="int", cprefix="ERL_")]
+ public enum ReceiveType {
+ ERROR, TICK, MSG
+ }
+ [CCode (cname="int", cprefix="E")]
+ public enum Error {
+ TIMEDOUT
+ }
+
+ [CCode (cname = "int")]
+ [Compact]
+ public struct Connection : int {
+ public bool is_valid() {
+ return (this >= 0);
+ }
+
+ private ReceiveType xreceive_msg_tmo(Msg msg, Buffer buffer, uint timeout);
+
+ [CCode (cname = "erl_receive_vala")]
+ public ReceiveType receive(out Buffer buffer, uint timeout = 0) {
+ buffer = Buffer();
+ Msg msg;
+ ReceiveType ret = xreceive_msg_tmo(msg, buffer, timeout);
+ return ret;
+ }
+ }*/
+
+
+ [CCode (cname="MAXATOMLEN")]
+ public const int MAXATOMLEN;
+
+ [CCode (cname="char")]
+ public enum TermType {
+ [CCode (cname="ERL_SMALL_INTEGER_EXT")]
+ SMALL_INTEGER,
+ [CCode (cname="ERL_INTEGER_EXT")]
+ INTEGER,
+ [CCode (cname="ERL_FLOAT_EXT")]
+ FLOAT,
+ [CCode (cname="ERL_ATOM_EXT")]
+ ATOM,
+ [CCode (cname="ERL_REFERENCE_EXT")]
+ REFERENCE,
+ [CCode (cname="ERL_NEW_REFERENCE_EXT")]
+ NEW_REFERENCE,
+ [CCode (cname="ERL_PORT_EXT")]
+ PORT,
+ [CCode (cname="ERL_PID_EXT")]
+ PID,
+ [CCode (cname="ERL_SMALL_TUPLE_EXT")]
+ SMALL_TUPLE,
+ [CCode (cname="ERL_LARGE_TUPLE_EXT")]
+ LARGE_TUPLE,
+ [CCode (cname="ERL_NIL_EXT")]
+ NIL,
+ [CCode (cname="ERL_STRING_EXT")]
+ STRING,
+ [CCode (cname="ERL_LIST_EXT")]
+ LIST,
+ [CCode (cname="ERL_BINARY_EXT")]
+ BINARY,
+ [CCode (cname="ERL_SMALL_BIG_EXT")]
+ SMALL_BIG,
+ [CCode (cname="ERL_LARGE_BIG_EXT")]
+ LARGE_BIG,
+ [CCode (cname="ERL_NEW_FUN_EXT")]
+ NEW_FUN,
+ [CCode (cname="ERL_FUN_EXT")]
+ FUN
+ }
+
+ public int get_type(char *buf, ref int index, out int type, out int size);
+
+ public int decode_version(char *buf, ref int index, out int version);
+ public int decode_char(char *buf, ref int index, out char value);
+ public int decode_long(char *buf, ref int index, out long value);
+ public int decode_double(char *buf, ref int index, out double value);
+ public int decode_atom(char *buf, ref int index, char *p);
+ public int decode_tuple_header(char *buf, ref int index, out int arity);
+ public int decode_list_header(char *buf, ref int index, out int arity);
+ public int decode_string(char *buf, ref int index, char *p);
+ public int decode_binary(char *buf, ref int index, char *p, out long len);
+ public int decode_pid(char *buf, ref int index, out Pid pid);
+ public int decode_port(char *buf, ref int index, out Port port);
+ public int decode_ref(char *buf, ref int index, out Ref reference);
+
+
+ [CCode (cname = "ei_x_buff", cprefix = "ei_x_", destroy_function = "ei_x_free")]
+ [Compact]
+ public struct Buffer {
+ [CCode (array_length_cname = "index", array_length_type = "int")]
+ public char[] buff;
+
+ [CCode (cname = "ei_x_new")]
+ public Buffer();
+
+ [CCode (cname = "ei_x_new_with_version")]
+ public Buffer.with_version();
+
+ public int encode_long(long p);
+ public int encode_ulong(ulong p);
+ public int encode_double(double p);
+ [CCode (cname = "ei_x_encode_atom_len")]
+ public int encode_atom(char[] p);
+ public int encode_tuple_header(int arity);
+ public int encode_list_header(int arity);
+ public int encode_empty_list();
+ [CCode (cname = "ei_x_encode_string_len")]
+ public int encode_string(char[] p);
+ public int encode_binary(char* p, long len);
+ public int encode_pid(Pid pid);
+ public int encode_port(Port port);
+ public int encode_ref(Ref reference);
+ }
+
+ [CCode (cname = "erlang_pid", destroy_function = "")]
+ [Compact]
+ public struct Pid {
+ public char[] node;
+ public uint num;
+ public uint serial;
+ public uint creation;
+ }
+
+ [CCode (cname = "erlang_port", destroy_function = "")]
+ [Compact]
+ public struct Port {
+ public char[] node;
+ public uint id;
+ public uint creation;
+ }
+
+ [CCode (cname = "erlang_ref", destroy_function = "")]
+ [Compact]
+ public struct Ref {
+ public char[] node;
+ public int len;
+ public uint* n;
+ public uint creation;
+ }
+
+ /*[CCode (cname = "erlang_msg", destroy_function = "")]
+ [Compact]
+ private struct Msg {
+ public Pid from;
+ }*/
+}