From c0cfadf55a4a3aee4e18f5d3ca88d319e9fd2ca3 Mon Sep 17 00:00:00 2001 From: Marenz Date: Sun, 12 Jun 2011 13:13:17 +0200 Subject: [PATCH] more work on the d binding --- d/include/psyc/common.d | 5 ++++- d/include/psyc/packet.d | 35 +++++++++++++++++++++++++++++++++-- d/include/psyc/render.d | 3 +++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/d/include/psyc/common.d b/d/include/psyc/common.d index b873bfa..8a39604 100644 --- a/d/include/psyc/common.d +++ b/d/include/psyc/common.d @@ -66,11 +66,14 @@ enum ListType LIST_BINARY = 2, } +/+ struct String { size_t length; ubyte *ptr; -} +}+/ + +alias char[] String; struct MatchVar { diff --git a/d/include/psyc/packet.d b/d/include/psyc/packet.d index b9584cb..9817ad3 100644 --- a/d/include/psyc/packet.d +++ b/d/include/psyc/packet.d @@ -8,6 +8,8 @@ import psyc.common; import psyc.syntax; +extern (C): + /** Modifier flags. */ enum ModifierFlag { @@ -46,11 +48,40 @@ enum PacketFlag /** Structure for a modifier. */ struct Modifier { - char oper; + char operator; String name; String value; ModifierFlag flag; -} ; + + static Modifier opCall ( char op, char[] nam, char[] val ) + { + Modifier v; + + with (v) + { + operator = op; + name = nam; + value = val; + } + + return v; + } + + bool opEquals ( ref Modifier n ) + { + return operator == n.operator && + value == n.value && + name == n.name; + } + + Modifier dup ( ) + { + auto v = M(operator, name.dup, value.dup); + return v; + } +}; + +alias Modifier M; /** Structure for an entity or routing header. */ struct Header diff --git a/d/include/psyc/render.d b/d/include/psyc/render.d index f12bbbe..c02a188 100644 --- a/d/include/psyc/render.d +++ b/d/include/psyc/render.d @@ -2,6 +2,9 @@ module psyc.render; import psyc.packet; + +extern (C): + /* * All rendering functions and the definitions they use are defined here. */