summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2010-10-06 00:16:24 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2010-10-06 00:16:24 +0200
commit196cb4979e8a1e26a7e46091d0f0291812c7dcd1 (patch)
tree9d21052dde067f726a059f6e5e8e7e1e7e545bcf
parente65feb6fd3d035f06f7439c79b5eea37946eea5e (diff)
downloadeva-196cb4979e8a1e26a7e46091d0f0291812c7dcd1.tar
eva-196cb4979e8a1e26a7e46091d0f0291812c7dcd1.zip
Got rid of that nasty ei.h dependency
-rw-r--r--src/Atom.vala4
-rw-r--r--src/Binary.vala4
-rw-r--r--src/Buffer.vala10
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Double.vala4
-rw-r--r--src/Int.vala4
-rw-r--r--src/List.vala8
-rw-r--r--src/PacketHandler.vala11
-rw-r--r--src/Pid.vala6
-rw-r--r--src/Port.vala6
-rw-r--r--src/Ref.vala6
-rw-r--r--src/String.vala4
-rw-r--r--src/Term.vala2
-rw-r--r--src/Tuple.vala4
-rw-r--r--src/UInt.vala4
-rw-r--r--src/Var.vala2
-rw-r--r--test/Test.vala12
17 files changed, 54 insertions, 38 deletions
diff --git a/src/Atom.vala b/src/Atom.vala
index 012b506..29c6654 100644
--- a/src/Atom.vala
+++ b/src/Atom.vala
@@ -45,10 +45,10 @@ namespace Eva {
}
}
- public void encode(Erl.Buffer buffer) {
+ internal void encode(Buffer buffer) {
char[]? array = string_to_binary(value);
assert(array != null);
- buffer.encode_atom(array);
+ buffer.buffer.encode_atom(array);
}
}
}
diff --git a/src/Binary.vala b/src/Binary.vala
index 11ad775..35a01fa 100644
--- a/src/Binary.vala
+++ b/src/Binary.vala
@@ -37,8 +37,8 @@ namespace Eva {
}
- public void encode(Erl.Buffer buffer) {
- buffer.encode_binary(data, len);
+ internal void encode(Buffer buffer) {
+ buffer.buffer.encode_binary(data, len);
}
}
}
diff --git a/src/Buffer.vala b/src/Buffer.vala
new file mode 100644
index 0000000..597c9de
--- /dev/null
+++ b/src/Buffer.vala
@@ -0,0 +1,10 @@
+namespace Eva {
+ [Compact]
+ public static class Buffer {
+ public Erl.Buffer buffer;
+
+ public Buffer() {
+ buffer = Erl.Buffer.with_version();
+ }
+ }
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0a431a6..2e1c1ea 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -5,6 +5,7 @@ link_directories(${GEE_LIBRARY_DIRS} ${GIO_LIBRARY_DIRS})
vala_precompile(EVA_C
Atom.vala
+ Buffer.vala
Binary.vala
Double.vala
Int.vala
diff --git a/src/Double.vala b/src/Double.vala
index 924d5f6..ea1244d 100644
--- a/src/Double.vala
+++ b/src/Double.vala
@@ -49,8 +49,8 @@ namespace Eva {
}
}
- public void encode(Erl.Buffer buffer) {
- buffer.encode_double(value);
+ internal void encode(Buffer buffer) {
+ buffer.buffer.encode_double(value);
}
}
}
diff --git a/src/Int.vala b/src/Int.vala
index b881a2c..5e840b2 100644
--- a/src/Int.vala
+++ b/src/Int.vala
@@ -52,8 +52,8 @@ namespace Eva {
}
}
- public void encode(Erl.Buffer buffer) {
- buffer.encode_long(value);
+ internal void encode(Buffer buffer) {
+ buffer.buffer.encode_long(value);
}
}
}
diff --git a/src/List.vala b/src/List.vala
index 5706792..5ea7ff6 100644
--- a/src/List.vala
+++ b/src/List.vala
@@ -42,8 +42,8 @@ namespace Eva {
}
}
- public void encode(Erl.Buffer buffer) {
- buffer.encode_empty_list();
+ internal void encode(Buffer buffer) {
+ buffer.buffer.encode_empty_list();
}
}
}
@@ -94,8 +94,8 @@ namespace Eva {
return ret + "]";
}
- public void encode(Erl.Buffer buffer) {
- buffer.encode_list_header(1);
+ internal void encode(Buffer buffer) {
+ buffer.buffer.encode_list_header(1);
head.encode(buffer);
tail.encode(buffer);
}
diff --git a/src/PacketHandler.vala b/src/PacketHandler.vala
index b2ef1f7..4b1c926 100644
--- a/src/PacketHandler.vala
+++ b/src/PacketHandler.vala
@@ -19,9 +19,12 @@ namespace Eva {
}
public void send(Term term) throws Error {
- Erl.Buffer buffer = Erl.Buffer.with_version();
- term.encode(buffer);
-
+ Buffer buf = new Buffer();
+ unowned Erl.Buffer buffer = buf.buffer;
+ term.encode(buf);
+
+ buffer = buf.buffer;
+
switch(sizeLength) {
case 1:
ostream.put_byte((uchar)buffer.buff.length, null);
@@ -33,7 +36,7 @@ namespace Eva {
ostream.put_uint32((uint32)buffer.buff.length, null);
break;
}
-
+
ostream.write(buffer.buff, buffer.buff.length, null);
}
diff --git a/src/Pid.vala b/src/Pid.vala
index 68f9a4f..d82f1c3 100644
--- a/src/Pid.vala
+++ b/src/Pid.vala
@@ -5,7 +5,7 @@ namespace Eva {
public uint serial {get; construct;}
public uint creation {get; construct;}
- public Pid(Erl.Pid pid) {
+ internal Pid(Erl.Pid pid) {
this.create(binary_to_string(pid.node, Erl.MAXATOMLEN), pid.num, pid.serial, pid.creation);
}
@@ -30,7 +30,7 @@ namespace Eva {
return (node == p.node && num == p.num && serial == p.serial && creation == p.creation);
}
- public void encode(Erl.Buffer buffer) {
+ internal void encode(Buffer buffer) {
Erl.Pid pid = Erl.Pid();
char[]? nodedata = string_to_binary(node);
assert(nodedata != null);
@@ -42,7 +42,7 @@ namespace Eva {
pid.serial = serial;
pid.creation = creation;
- buffer.encode_pid(pid);
+ buffer.buffer.encode_pid(pid);
}
}
}
diff --git a/src/Port.vala b/src/Port.vala
index ae3980d..6c33383 100644
--- a/src/Port.vala
+++ b/src/Port.vala
@@ -4,7 +4,7 @@ namespace Eva {
public uint id {get; construct;}
public uint creation {get; construct;}
- public Port(Erl.Port port) {
+ internal Port(Erl.Port port) {
this.create(binary_to_string(port.node, Erl.MAXATOMLEN), port.id, port.creation);
}
@@ -29,7 +29,7 @@ namespace Eva {
return (node == p.node && id == p.id && creation == p.creation);
}
- public void encode(Erl.Buffer buffer) {
+ internal void encode(Buffer buffer) {
Erl.Port port = Erl.Port();
char[]? nodedata = string_to_binary(node);
assert(nodedata != null);
@@ -40,7 +40,7 @@ namespace Eva {
port.id = id;
port.creation = creation;
- buffer.encode_port(port);
+ buffer.buffer.encode_port(port);
}
}
}
diff --git a/src/Ref.vala b/src/Ref.vala
index 17ae2cf..8ed6d0e 100644
--- a/src/Ref.vala
+++ b/src/Ref.vala
@@ -5,7 +5,7 @@ namespace Eva {
public uint[] n {get; private set;}
public uint creation {get; construct;}
- public Ref(Erl.Ref reference) {
+ internal Ref(Erl.Ref reference) {
this.create(binary_to_string(reference.node, Erl.MAXATOMLEN), reference.len, reference.n, reference.creation);
}
@@ -55,7 +55,7 @@ namespace Eva {
return true;
}
- public void encode(Erl.Buffer buffer) {
+ internal void encode(Buffer buffer) {
Erl.Ref reference = Erl.Ref();
char[]? nodedata = string_to_binary(node);
assert(nodedata != null);
@@ -71,7 +71,7 @@ namespace Eva {
reference.creation = creation;
- buffer.encode_ref(reference);
+ buffer.buffer.encode_ref(reference);
}
}
}
diff --git a/src/String.vala b/src/String.vala
index ea749c1..2bee7dc 100644
--- a/src/String.vala
+++ b/src/String.vala
@@ -26,10 +26,10 @@ namespace Eva {
}
}
- public void encode(Erl.Buffer buffer) {
+ internal void encode(Buffer buffer) {
char[]? array = string_to_binary(value);
if(array != null) {
- buffer.encode_string(array);
+ buffer.buffer.encode_string(array);
}
else {
string_to_list(value).encode(buffer);
diff --git a/src/Term.vala b/src/Term.vala
index 5c1c968..93070b0 100644
--- a/src/Term.vala
+++ b/src/Term.vala
@@ -26,7 +26,7 @@ namespace Eva {
protected abstract bool do_match(Term o, Gee.Map<string, Term> vars, Gee.Map<string, string> aliases);
- public abstract void encode(Erl.Buffer buffer);
+ internal abstract void encode(Buffer buffer);
public static Term decode(void *buffer) {
int index = 0;
diff --git a/src/Tuple.vala b/src/Tuple.vala
index 7423bce..4061479 100644
--- a/src/Tuple.vala
+++ b/src/Tuple.vala
@@ -56,8 +56,8 @@ namespace Eva {
return true;
}
- public void encode(Erl.Buffer buffer) {
- buffer.encode_tuple_header(size);
+ internal void encode(Buffer buffer) {
+ buffer.buffer.encode_tuple_header(size);
foreach(Term term in elements) {
term.encode(buffer);
diff --git a/src/UInt.vala b/src/UInt.vala
index 84e09aa..c36fef6 100644
--- a/src/UInt.vala
+++ b/src/UInt.vala
@@ -53,8 +53,8 @@ namespace Eva {
}
- public void encode(Erl.Buffer buffer) {
- buffer.encode_ulong(value);
+ internal void encode(Buffer buffer) {
+ buffer.buffer.encode_ulong(value);
}
}
}
diff --git a/src/Var.vala b/src/Var.vala
index 177e2fa..1c11f76 100644
--- a/src/Var.vala
+++ b/src/Var.vala
@@ -59,7 +59,7 @@ namespace Eva {
}
}
- public void encode(Erl.Buffer buffer) {
+ internal void encode(Buffer buffer) {
assert_not_reached();
}
}
diff --git a/test/Test.vala b/test/Test.vala
index 85afc6a..2861233 100644
--- a/test/Test.vala
+++ b/test/Test.vala
@@ -1,13 +1,15 @@
namespace Eva {
class Test {
public static int main(string[] args) {
- MainLoop main = new MainLoop();
+ // MainLoop main = new MainLoop();
- PacketHandler handler = new PacketHandler(new UnixInputStream(3, true), new UnixOutputStream(4, true), 4);
- handler.received_term.connect((term) => {stdout.printf("Received term %s\n", term.to_string()); handler.send(term); main.quit();});
- handler.start();
+ // PacketHandler handler = new PacketHandler(new UnixInputStream(3, true), new UnixOutputStream(4, true), 4);
+ // handler.received_term.connect((term) => {stdout.printf("Received term %s\n", term.to_string()); handler.send(term); main.quit();});
+ // handler.start();
- main.run();
+ //main.run();
+ PacketHandler handler = new PacketHandler(new UnixInputStream(1, true), new UnixOutputStream(2, true), 4);
+ handler.send(new Atom("foo"));
return 0;
}