celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [4/6] celix git commit: CELIX-309: Move dfi to top-level subdir
Date Fri, 27 Nov 2015 14:56:33 GMT
http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/private/test/json_serializer_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/json_serializer_tests.cpp b/dfi/private/test/json_serializer_tests.cpp
new file mode 100644
index 0000000..70b0147
--- /dev/null
+++ b/dfi/private/test/json_serializer_tests.cpp
@@ -0,0 +1,508 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+#include <CppUTest/TestHarness.h>
+#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
+
+extern "C" {
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include <ffi.h>
+
+#include "dyn_common.h"
+#include "dyn_type.h"
+#include "json_serializer.h"
+
+static void stdLog(void *handle, int level, const char *file, int line, const char *msg, ...) {
+    va_list ap;
+    const char *levels[5] = {"NIL", "ERROR", "WARNING", "INFO", "DEBUG"};
+    fprintf(stderr, "%s: FILE:%s, LINE:%i, MSG:",levels[level], file, line);
+    va_start(ap, msg);
+    vfprintf(stderr, msg, ap);
+    fprintf(stderr, "\n");
+}
+
+/*********** example 1 ************************/
+/** struct type ******************************/
+const char *example1_descriptor = "{DJISF a b c d e}";
+
+const char *example1_input = "{ \
+    \"a\" : 1.0, \
+    \"b\" : 22, \
+    \"c\" : 32, \
+    \"d\" : 42, \
+    \"e\" : 4.4 \
+}";
+
+struct example1 {
+    double a;   //0
+    int64_t b;  //1
+    int32_t c;  //2
+    int16_t d;  //3
+    float e;    //4
+};
+
+static void check_example1(void *data) {
+    struct example1 *ex = (struct example1 *)data;
+    CHECK_EQUAL(1.0, ex->a);
+    LONGS_EQUAL(22, ex->b);
+    LONGS_EQUAL(32, ex->c);
+    LONGS_EQUAL(42, ex->d);
+    CHECK_EQUAL(4.4f, ex->e);
+}
+
+/*********** example 2 ************************/
+const char *example2_descriptor = "{BJJDFD byte long1 long2 double1 float1 double2}";
+
+const char *example2_input = "{ \
+    \"byte\" : 42, \
+    \"long1\" : 232, \
+    \"long2\" : 242, \
+    \"double1\" : 4.2, \
+    \"float1\" : 3.2, \
+    \"double2\" : 4.4 \
+}";
+
+struct example2 {
+    char byte;      //0
+    int64_t long1;     //1
+    int64_t long2;     //2
+    double double1; //3
+    float float1;   //4
+    double double2; //5
+};
+
+static void check_example2(void *data) {
+    struct example2 *ex = (struct example2 *)data;
+    CHECK_EQUAL(42, ex->byte);
+    LONGS_EQUAL(232, ex->long1);
+    LONGS_EQUAL(242, ex->long2);
+    CHECK_EQUAL(4.2, ex->double1);
+    CHECK_EQUAL(3.2f, ex->float1);
+    CHECK_EQUAL(4.4, ex->double2);
+}
+
+
+/*********** example 3 ************************/
+/** sequence with a simple type **************/
+const char *example3_descriptor = "{[I numbers}";
+
+const char *example3_input = "{ \
+    \"numbers\" : [22,32,42] \
+}";
+
+struct example3 {
+    struct {
+        uint32_t cap;
+        uint32_t len;
+        int32_t *buf;
+    } numbers;
+};
+
+static void check_example3(void *data) {
+    struct example3 *ex = (struct example3 *)data;
+    CHECK_EQUAL(3, ex->numbers.len);
+    CHECK_EQUAL(22, ex->numbers.buf[0]);
+    CHECK_EQUAL(32, ex->numbers.buf[1]);
+    CHECK_EQUAL(42, ex->numbers.buf[2]);
+}
+
+/*********** example 4 ************************/
+/** structs within a struct (by reference)*******/
+const char *example4_descriptor = "{{IDD index val1 val2}{IDD index val1 val2} left right}";
+
+static const char *example4_input =  "{ \
+    \"left\" : {\"index\":1, \"val1\":1.0, \"val2\":2.0 }, \
+    \"right\" : {\"index\":2, \"val1\":5.0, \"val2\":4.0 } \
+}";
+
+struct ex4_leaf {
+    int32_t index;
+    double val1;
+    double val2;
+};
+
+struct example4 {
+    struct ex4_leaf left;
+    struct ex4_leaf right;
+};
+
+static void check_example4(void *data) {
+    struct example4 *ex = (struct example4 *)data;
+    CHECK_EQUAL(1, ex->left.index);
+    CHECK_EQUAL(1.0, ex->left.val1);
+    CHECK_EQUAL(2.0, ex->left.val2);
+    CHECK_EQUAL(2, ex->right.index);
+    CHECK_EQUAL(5.0, ex->right.val1);
+    CHECK_EQUAL(4.0, ex->right.val2);
+}
+
+
+/*********** example 5 ************************/
+/** structs within a struct (by reference)*******/
+const char *example5_descriptor = "Tleaf={ts name age};Tnode={Lnode;Lnode;Lleaf; left right value};{Lnode; head}";
+
+static const char *example5_input =  "{ \
+    \"head\" : {\
+        \"left\" : {\
+            \"value\" : {\
+                \"name\" : \"John\",\
+                \"age\" : 44 \
+            }\
+        },\
+        \"right\" : {\
+            \"value\" : {\
+                \"name\" : \"Peter\", \
+                \"age\" : 55 \
+            }\
+        }\
+    }\
+}";
+
+struct leaf {
+    const char *name;
+    uint16_t age;
+};
+
+struct node {
+    struct node *left;
+    struct node *right;
+    struct leaf *value;
+};
+
+struct example5 {
+    struct node *head;
+};
+
+static void check_example5(void *data) {
+    struct example5 *ex = (struct example5 *)data;
+    CHECK_TRUE(ex->head != NULL);
+
+    CHECK(ex->head->left != NULL);
+    CHECK(ex->head->left->value != NULL);
+    STRCMP_EQUAL("John", ex->head->left->value->name);
+    CHECK_EQUAL(44, ex->head->left->value->age);
+    CHECK(ex->head->left->left == NULL);
+    CHECK(ex->head->left->right == NULL);
+
+    CHECK(ex->head->right != NULL);
+    CHECK(ex->head->right->value != NULL);
+    STRCMP_EQUAL("Peter", ex->head->right->value->name);
+    CHECK_EQUAL(55, ex->head->right->value->age);
+    CHECK(ex->head->right->left == NULL);
+    CHECK(ex->head->right->right == NULL);
+}
+
+static const char *example6_descriptor = "Tsample={DD v1 v2};[lsample;";
+
+static const char *example6_input = "[{\"v1\":0.1,\"v2\":0.2},{\"v1\":1.1,\"v2\":1.2},{\"v1\":2.1,\"v2\":2.2}]";
+
+struct ex6_sample {
+    double v1;
+    double v2;
+};
+
+struct ex6_sequence {
+    uint32_t cap;
+    uint32_t len;
+    struct ex6_sample *buf;
+};
+
+static void check_example6(struct ex6_sequence seq) {
+    CHECK_EQUAL(3, seq.cap);
+    CHECK_EQUAL(3, seq.len);
+    CHECK_EQUAL(0.1, seq.buf[0].v1);
+    CHECK_EQUAL(0.2, seq.buf[0].v2);
+    CHECK_EQUAL(1.1, seq.buf[1].v1);
+    CHECK_EQUAL(1.2, seq.buf[1].v2);
+    CHECK_EQUAL(2.1, seq.buf[2].v1);
+    CHECK_EQUAL(2.2, seq.buf[2].v2);
+}
+
+
+/*********** example 7 ************************/
+const char *example7_descriptor = "{t a}";
+
+const char *example7_input = "{ \
+    \"a\" : \"apache celix\" \
+}";
+
+struct example7 {
+    char* a;   //0
+};
+
+static void check_example7(void *data) {
+    struct example7 *ex = (struct example7 *)data;
+    STRCMP_EQUAL("apache celix", ex->a);
+}
+
+static void parseTests(void) {
+    dyn_type *type;
+    void *inst;
+    int rc;
+
+    type = NULL;
+    inst = NULL;
+    rc = dynType_parseWithStr(example1_descriptor, NULL, NULL, &type);    
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_deserialize(type, example1_input, &inst);
+    CHECK_EQUAL(0, rc);
+    check_example1(inst);
+    dynType_free(type, inst);
+    dynType_destroy(type);
+
+    type = NULL;
+    inst = NULL;
+    rc = dynType_parseWithStr(example2_descriptor, NULL, NULL, &type);
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_deserialize(type, example2_input, &inst);
+    CHECK_EQUAL(0, rc);
+    check_example2(inst);
+    dynType_free(type, inst);
+    dynType_destroy(type);
+
+    type = NULL;
+    inst = NULL;
+    rc = dynType_parseWithStr(example3_descriptor, NULL, NULL, &type);
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_deserialize(type, example3_input, &inst);
+    CHECK_EQUAL(0, rc);
+    check_example3(inst);
+    dynType_free(type, inst);
+    dynType_destroy(type);
+
+    type = NULL;
+    inst = NULL;
+    rc = dynType_parseWithStr(example4_descriptor, NULL, NULL, &type);
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_deserialize(type, example4_input, &inst);
+    CHECK_EQUAL(0, rc);
+    check_example4(inst);
+    dynType_free(type, inst);
+    dynType_destroy(type);
+
+    type = NULL;
+    inst = NULL;
+    rc = dynType_parseWithStr(example5_descriptor, NULL, NULL, &type);
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_deserialize(type, example5_input, &inst);
+    CHECK_EQUAL(0, rc);
+    check_example5(inst);
+    dynType_free(type, inst);
+    dynType_destroy(type);
+
+    type = NULL;
+    struct ex6_sequence *seq;
+    rc = dynType_parseWithStr(example6_descriptor, NULL, NULL, &type);
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_deserialize(type, example6_input, (void **)&seq);
+    CHECK_EQUAL(0, rc);
+    check_example6((*seq));
+    dynType_free(type, seq);
+    dynType_destroy(type);
+
+
+    type = NULL;
+    inst = NULL;
+    rc = dynType_parseWithStr(example7_descriptor, NULL, NULL, &type);
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_deserialize(type, example7_input, &inst);
+    CHECK_EQUAL(0, rc);
+    check_example7(inst);
+    dynType_free(type, inst);
+    dynType_destroy(type);
+}
+
+const char *write_example1_descriptor = "{BSIJsijFDN a b c d e f g h i j}";
+
+struct write_example1 {
+    char a;
+    int16_t b;
+    int32_t c;
+    int64_t d;
+    uint16_t e;
+    uint32_t f;
+    uint64_t g;
+    float h;
+    double i;
+    int j;
+};
+
+void writeTest1(void) {
+    struct write_example1 ex1;
+    ex1.a=1;
+    ex1.b=2;
+    ex1.c=3;
+    ex1.d=4;
+    ex1.e=5;
+    ex1.f=6;
+    ex1.g=7;
+    ex1.h=8.8f;
+    ex1.i=9.9;
+    ex1.j=10;
+
+    dyn_type *type = NULL;
+    char *result = NULL;
+    int rc = dynType_parseWithStr(write_example1_descriptor, "ex1", NULL, &type);
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_serialize(type, &ex1, &result);
+    CHECK_EQUAL(0, rc);
+    STRCMP_CONTAINS("\"a\":1", result);
+    STRCMP_CONTAINS("\"b\":2", result);
+    STRCMP_CONTAINS("\"c\":3", result);
+    STRCMP_CONTAINS("\"d\":4", result);
+    STRCMP_CONTAINS("\"e\":5", result);
+    STRCMP_CONTAINS("\"f\":6", result);
+    STRCMP_CONTAINS("\"g\":7", result);
+    STRCMP_CONTAINS("\"h\":8.8", result);
+    STRCMP_CONTAINS("\"i\":9.9", result);
+    STRCMP_CONTAINS("\"j\":10", result);
+    //printf("example 1 result: '%s'\n", result);
+    dynType_destroy(type);
+    free(result);
+}
+
+const char *write_example2_descriptor = "{*{JJ a b}{SS c d} sub1 sub2}";
+
+struct write_example2_sub {
+        int64_t a;
+        int64_t b;
+};
+
+struct write_example2 {
+    struct write_example2_sub *sub1;
+    struct {
+        int16_t c;
+        int16_t d;
+    } sub2;
+};
+
+void writeTest2(void) {
+    struct write_example2_sub sub1;
+    sub1.a = 1;
+    sub1.b = 2;
+
+    struct write_example2 ex;
+    ex.sub1=&sub1;
+    ex.sub2.c = 3;
+    ex.sub2.d = 4;
+
+    dyn_type *type = NULL;
+    char *result = NULL;
+    int rc = dynType_parseWithStr(write_example2_descriptor, "ex2", NULL, &type);
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_serialize(type, &ex, &result);
+    CHECK_EQUAL(0, rc);
+    STRCMP_CONTAINS("\"a\":1", result);
+    STRCMP_CONTAINS("\"b\":2", result);
+    STRCMP_CONTAINS("\"c\":3", result);
+    STRCMP_CONTAINS("\"d\":4", result);
+    //printf("example 2 result: '%s'\n", result);
+    dynType_destroy(type);
+    free(result);
+}
+
+const char *write_example3_descriptor = "Tperson={ti name age};[Lperson;";
+
+struct write_example3_person {
+    const char *name;
+    uint32_t age;
+};
+
+struct write_example3 {
+    uint32_t cap;
+    uint32_t len;
+    struct write_example3_person **buf;
+};
+
+void writeTest3(void) {
+    struct write_example3_person p1;
+    p1.name = "John";
+    p1.age = 33;
+
+    struct write_example3_person p2;
+    p2.name = "Peter";
+    p2.age = 44;
+
+    struct write_example3_person p3;
+    p3.name = "Carol";
+    p3.age = 55;
+
+    struct write_example3_person p4;
+    p4.name = "Elton";
+    p4.age = 66;
+
+    struct write_example3 seq;
+    seq.buf = (struct write_example3_person **) calloc(4, sizeof(void *));
+    seq.len = seq.cap = 4;
+    seq.buf[0] = &p1;
+    seq.buf[1] = &p2;
+    seq.buf[2] = &p3;
+    seq.buf[3] = &p4;
+
+    dyn_type *type = NULL;
+    char *result = NULL;
+    int rc = dynType_parseWithStr(write_example3_descriptor, "ex3", NULL, &type);
+    CHECK_EQUAL(0, rc);
+    rc = jsonSerializer_serialize(type, &seq, &result);
+    CHECK_EQUAL(0, rc);
+    STRCMP_CONTAINS("\"age\":33", result);
+    STRCMP_CONTAINS("\"age\":44", result);
+    STRCMP_CONTAINS("\"age\":55", result);
+    STRCMP_CONTAINS("\"age\":66", result);
+    //printf("example 3 result: '%s'\n", result);
+    free(seq.buf);
+    dynType_destroy(type);
+    free(result);
+}
+
+
+
+}
+
+TEST_GROUP(JsonSerializerTests) {
+    void setup() {
+        int lvl = 1;
+        dynCommon_logSetup(stdLog, NULL, lvl);
+        dynType_logSetup(stdLog, NULL,lvl);
+        jsonSerializer_logSetup(stdLog, NULL, lvl);
+    }
+};
+
+TEST(JsonSerializerTests, ParseTests) {
+    //TODO split up
+    parseTests();
+}
+
+TEST(JsonSerializerTests, WriteTest1) {
+    writeTest1();
+}
+
+TEST(JsonSerializerTests, WriteTest2) {
+    writeTest2();
+}
+
+TEST(JsonSerializerTests, WriteTest3) {
+    writeTest3();
+}
+
+

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/private/test/run_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/run_tests.cpp b/dfi/private/test/run_tests.cpp
new file mode 100644
index 0000000..786f4bf
--- /dev/null
+++ b/dfi/private/test/run_tests.cpp
@@ -0,0 +1,24 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+#include <CppUTest/TestHarness.h>
+#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
+
+int main(int argc, char** argv) {
+        return RUN_ALL_TESTS(argc, argv);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/private/test/schemas/complex.avdl
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/complex.avdl b/dfi/private/test/schemas/complex.avdl
new file mode 100644
index 0000000..eff1fd8
--- /dev/null
+++ b/dfi/private/test/schemas/complex.avdl
@@ -0,0 +1,30 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+
+protocol Complex {
+
+  record StatResult {
+    double sum;
+    double min;
+    double max;
+    array<double> input;
+  }
+
+  StatResult stats(array<double> input);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/private/test/schemas/complex.avpr
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/complex.avpr b/dfi/private/test/schemas/complex.avpr
new file mode 100644
index 0000000..ca39b56
--- /dev/null
+++ b/dfi/private/test/schemas/complex.avpr
@@ -0,0 +1,55 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+
+{
+  "protocol" : "Complex",
+  "namespace" : null,
+  "types" : [ {
+    "type" : "record",
+    "name" : "StatResult",
+    "fields" : [ {
+      "name" : "sum",
+      "type" : "double"
+    }, {
+      "name" : "min",
+      "type" : "double"
+    }, {
+      "name" : "max",
+      "type" : "double"
+    }, {
+      "name" : "input",
+      "type" : {
+        "type" : "array",
+        "items" : "double"
+      }
+    } ]
+  } ],
+  "messages" : {
+    "stats" : {
+      "request" : [ {
+        "name" : "input",
+        "type" : {
+          "type" : "array",
+          "items" : "double"
+        }
+      } ],
+      "response" : "StatResult"
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/private/test/schemas/invalid1.avpr
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/invalid1.avpr b/dfi/private/test/schemas/invalid1.avpr
new file mode 100644
index 0000000..bbf77ee
--- /dev/null
+++ b/dfi/private/test/schemas/invalid1.avpr
@@ -0,0 +1,47 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+{
+  "protocol" : "Complex",
+  "namespace" : null,
+  "types" : [ {
+    "type" : "record",
+    "name" : "StatResult",
+    "fields" : [ {
+      "name" : "sum",
+      "type" : "double"
+    }, {
+      "name" : "min",
+      "type" : "double"
+    }, {
+      "name" : "max",
+      "type" : "double"
+    }, {
+      "name" : "input",
+      "type" : {
+        "type" : "array",
+        "items" : "double"
+      }
+    } ]
+  } ],
+  "messages" : {
+    "stats" : {
+      "response" : "StatResult"
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/private/test/schemas/invalid2.avpr
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/invalid2.avpr b/dfi/private/test/schemas/invalid2.avpr
new file mode 100644
index 0000000..9eb9209
--- /dev/null
+++ b/dfi/private/test/schemas/invalid2.avpr
@@ -0,0 +1,49 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+ {
+  "protocol" : "Simple",
+  "types" : [ ],
+  "messages" : {
+    "sum" : {
+      "request" : [ {
+        "name" : "a"
+      }, {
+        "name" : "b",
+        "type" : "double"
+      } ],
+      "response" : "double"
+    },
+    "sub" : {
+      "request" : [ {
+        "name" : "a",
+        "type" : "double"
+      }, {
+        "name" : "b",
+        "type" : "double"
+      } ],
+      "response" : "double"
+    },
+    "sqrt" : {
+      "request" : [ {
+        "name" : "a"
+      } ],
+      "response" : "double"
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/private/test/schemas/simple.avdl
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/simple.avdl b/dfi/private/test/schemas/simple.avdl
new file mode 100644
index 0000000..a03e352
--- /dev/null
+++ b/dfi/private/test/schemas/simple.avdl
@@ -0,0 +1,24 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+ @namespace("org.apache.avro.test")
+protocol Simple {
+  double sum(double a, double b);
+  double sub(double a, double b);
+  double sqrt(double a);
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/private/test/schemas/simple.avpr
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/simple.avpr b/dfi/private/test/schemas/simple.avpr
new file mode 100644
index 0000000..4910346
--- /dev/null
+++ b/dfi/private/test/schemas/simple.avpr
@@ -0,0 +1,51 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+ {
+  "protocol" : "Simple",
+  "types" : [ ],
+  "messages" : {
+    "sum" : {
+      "request" : [ {
+        "name" : "a",
+        "type" : "double"
+      }, {
+        "name" : "b",
+        "type" : "double"
+      } ],
+      "response" : "double"
+    },
+    "sub" : {
+      "request" : [ {
+        "name" : "a",
+        "type" : "double"
+      }, {
+        "name" : "b",
+        "type" : "double"
+      } ],
+      "response" : "double"
+    },
+    "sqrt" : {
+      "request" : [ {
+        "name" : "a",
+        "type" : "double"
+      } ],
+      "response" : "double"
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/private/test/schemas/simple_min.avpr
----------------------------------------------------------------------
diff --git a/dfi/private/test/schemas/simple_min.avpr b/dfi/private/test/schemas/simple_min.avpr
new file mode 100644
index 0000000..f5c6673
--- /dev/null
+++ b/dfi/private/test/schemas/simple_min.avpr
@@ -0,0 +1,19 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+ {"protocol":"Simple","types":[],"messages":{"sum":{"request":[{"name":"a","type":"double"},{"name":"b","type":"double"}],"response":"double"},"sub":{"request":[{"name":"a","type":"double"},{"name":"b","type":"double"}],"response":"double"},"sqrt":{"request":[{"name":"a","type":"double"}],"response":"double"}}}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/dfi_log_util.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dfi_log_util.h b/dfi/public/include/dfi_log_util.h
new file mode 100644
index 0000000..2bcd8fa
--- /dev/null
+++ b/dfi/public/include/dfi_log_util.h
@@ -0,0 +1,63 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+#ifndef _DFI_LOG_UTIL_H_
+#define _DFI_LOG_UTIL_H_
+
+typedef void (*logf_ft)(void *handle, int level, const char *file, int line, const char *format, ...); 
+
+#define DFI_SETUP_LOG_HEADER(cmp) \
+    void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel);
+
+#define DFI_SETUP_LOG(cmp) \
+    static logf_ft g_logf = NULL; \
+    static void *g_logHandle = NULL; \
+    static int g_currentLogLevel = 1; \
+    \
+    void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel) { \
+        g_currentLogLevel = currentLogLevel; \
+        g_logHandle = handle; \
+        g_logf = logf; \
+    }  
+
+#define LOG_LVL_ERROR    1
+#define LOG_LVL_WARNING  2
+#define LOG_LVL_INFO     3
+#define LOG_LVL_DEBUG    4
+
+#define LOG_ERROR(msg, ...) \
+    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_ERROR) { \
+        g_logf(g_logHandle, LOG_LVL_ERROR, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
+    } 
+
+#define LOG_WARNING(msg, ...) \
+    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_WARNING) { \
+        g_logf(g_logHandle, LOG_LVL_WARNING, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
+    } 
+
+#define LOG_INFO(msg, ...) \
+    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_INFO) { \
+        g_logf(g_logHandle, LOG_LVL_INFO, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
+    } 
+
+#define LOG_DEBUG(msg, ...) \
+    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_DEBUG) { \
+        g_logf(g_logHandle, LOG_LVL_DEBUG, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
+    } 
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/dyn_common.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dyn_common.h b/dfi/public/include/dyn_common.h
new file mode 100644
index 0000000..6ec236f
--- /dev/null
+++ b/dfi/public/include/dyn_common.h
@@ -0,0 +1,47 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+#ifndef _DYN_COMMON_H_
+#define _DYN_COMMON_H_
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/queue.h>
+
+#include "dfi_log_util.h"
+
+//logging
+DFI_SETUP_LOG_HEADER(dynCommon);
+
+TAILQ_HEAD(namvals_head, namval_entry);
+
+struct namval_entry {
+    char *name;
+    char *value;
+    TAILQ_ENTRY(namval_entry) entries;
+};
+
+int dynCommon_parseName(FILE *stream, char **result);
+int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result);
+int dynCommon_parseNameValue(FILE *stream, char **name, char **value);
+int dynCommon_eatChar(FILE *stream, int c);
+
+void dynCommon_clearNamValHead(struct namvals_head *head);
+
+#endif 

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/dyn_function.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dyn_function.h b/dfi/public/include/dyn_function.h
new file mode 100644
index 0000000..792691e
--- /dev/null
+++ b/dfi/public/include/dyn_function.h
@@ -0,0 +1,61 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+#ifndef __DYN_FUNCTION_H_
+#define __DYN_FUNCTION_H_
+
+#include <ffi.h>
+#include "dyn_type.h"
+#include "dfi_log_util.h"
+
+/**
+ * Uses the following schema
+ * (Name)([Type]*)Type
+ *
+ * Dyn fynction argument meta (am) as meta info, with the following possible values
+ * am=handle #void pointer for the handle
+ * am=pre #output pointer with memory preallocated
+ * am=out #output pointer
+ */
+
+typedef struct _dyn_function_type dyn_function_type;
+
+DFI_SETUP_LOG_HEADER(dynFunction);
+
+enum dyn_function_argument_meta {
+    DYN_FUNCTION_ARGUMENT_META__STD = 0,
+    DYN_FUNCTION_ARGUMENT_META__HANDLE = 1,
+    DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT = 2,
+    DYN_FUNCTION_ARGUMENT_META__OUTPUT = 3
+};
+
+int dynFunction_parse(FILE *descriptorStream, struct types_head *refTypes, dyn_function_type **dynFunc);
+int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **dynFunc);
+
+int dynFunction_nrOfArguments(dyn_function_type *dynFunc);
+dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr);
+enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr);
+dyn_type * dynFunction_returnType(dyn_function_type *dynFunction);
+
+void dynFunction_destroy(dyn_function_type *dynFunc);
+int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues);
+
+int dynFunction_createClosure(dyn_function_type *func, void (*bind)(void *, void **, void*), void *userData, void(**fn)(void));
+int dynFunction_getFnPointer(dyn_function_type *func, void (**fn)(void));
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/dyn_interface.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dyn_interface.h b/dfi/public/include/dyn_interface.h
new file mode 100644
index 0000000..51a2f41
--- /dev/null
+++ b/dfi/public/include/dyn_interface.h
@@ -0,0 +1,63 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+#ifndef __DYN_INTERFACE_H_
+#define __DYN_INTERFACE_H_
+
+#include "dyn_common.h"
+#include "dyn_type.h"
+#include "dyn_function.h"
+#include "dfi_log_util.h"
+
+DFI_SETUP_LOG_HEADER(dynInterface);
+
+/* Description string
+ *
+ * Descriptor (interface) = HeaderSection AnnotationSection TypesSection MethodsSection
+ *
+ * HeaderSection=
+ * ':header\n' [NameValue]*
+ * ':annotations\n' [NameValue]*
+ * ':types\n' [TypeIdValue]*
+ * ':methods\n' [MethodIdValue]
+ *
+ */
+typedef struct _dyn_interface_type dyn_interface_type;
+
+TAILQ_HEAD(methods_head, method_entry);
+struct method_entry {
+    int index;
+    char *id;
+    char *name;
+    dyn_function_type *dynFunc;
+
+    TAILQ_ENTRY(method_entry) entries; 
+};
+
+int dynInterface_parse(FILE *descriptor, dyn_interface_type **out);
+void dynInterface_destroy(dyn_interface_type *intf);
+
+int dynInterface_getName(dyn_interface_type *intf, char **name);
+int dynInterface_getVersion(dyn_interface_type *intf, char **version);
+int dynInterface_getHeaderEntry(dyn_interface_type *intf, const char *name, char **value);
+int dynInterface_getAnnotationEntry(dyn_interface_type *intf, const char *name, char **value);
+int dynInterface_methods(dyn_interface_type *intf, struct methods_head **list);
+int dynInterface_nrOfMethods(dyn_interface_type *intf);
+
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/dyn_message.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dyn_message.h b/dfi/public/include/dyn_message.h
new file mode 100644
index 0000000..b2f5f0e
--- /dev/null
+++ b/dfi/public/include/dyn_message.h
@@ -0,0 +1,53 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+#ifndef __DYN_MESSAGE_H_
+#define __DYN_MESSAGE_H_
+
+#include "dyn_common.h"
+#include "dyn_type.h"
+#include "dfi_log_util.h"
+
+DFI_SETUP_LOG_HEADER(dynMessage);
+
+/* Description string
+ *
+ * Descriptor (message) = HeaderSection AnnotationSection TypesSection MessageSection
+ *
+ * HeaderSection=
+ * ':header\n' [NameValue]*
+ * ':annotations\n' [NameValue]*
+ * ':types\n' [TypeIdValue]*
+ * ':message\n' [MessageIdValue]
+ *
+ */
+typedef struct _dyn_message_type dyn_message_type;
+
+
+int dynMessage_parse(FILE *descriptor, dyn_message_type **out);
+void dynMessage_destroy(dyn_message_type *msg);
+
+int dynMessage_getName(dyn_message_type *msg, char **name);
+int dynMessage_getVersion(dyn_message_type *msg, char **version);
+int dynMessage_getHeaderEntry(dyn_message_type *msg, const char *name, char **value);
+int dynMessage_getAnnotationEntry(dyn_message_type *msg, const char *name, char **value);
+int dynMessage_getMessageType(dyn_message_type *msg, dyn_type **type);
+
+
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/dyn_type.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/dyn_type.h b/dfi/public/include/dyn_type.h
new file mode 100644
index 0000000..b2b84ef
--- /dev/null
+++ b/dfi/public/include/dyn_type.h
@@ -0,0 +1,157 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+
+#ifndef _DYN_TYPE_H_
+#define _DYN_TYPE_H_
+
+#include <stdio.h>
+#include <sys/queue.h>
+#include <stdbool.h>
+
+#include <ffi.h>
+#include <stdint.h>
+
+#include "dfi_log_util.h"
+
+#if defined(BSD) || defined(__APPLE__)
+#include "memstream/open_memstream.h"
+#include "memstream/fmemopen.h"
+#endif
+
+/* Description string
+ *
+ * Type = [TypeDef]* (MetaInfo)* (SimpleType | ComplexType | SequenceType | TypedPointer | PointerReference ) [TypeDef]*
+ * Name = alpha[(alpha|numeric)*]
+ * SPACE = ' ' 
+ *
+ * SimplesTypes (based on java bytecode method signatures)
+ * //Java based:
+ * B char
+ * C (not supported)
+ * D double
+ * F float
+ * I int32_t 
+ * J int64_t 
+ * S int16_t 
+ * V void
+ * Z boolean
+ * //Extended
+ * b unsigned char
+ * i uint32_t
+ * j uint62_t
+ * s uint64_t
+ * P untyped pointer (void *)
+ * t char* string
+ * N native int
+ *
+ * ComplexTypes (Struct)
+ * {[Type]+ [(Name)(SPACE)]+}
+ *
+ * ReferenceByValue
+ * l(name);
+ *
+ * PointerReference -> note shortcut for *l(name);
+ * L(Name);
+ *
+ * TypeDef 
+ * T(Name)=Type;
+ *
+ * SequenceType
+ * [(Type)
+ *
+ * TypedPointer
+ * *(Type)
+ *
+ * MetaInfo TODO
+ * #Name=Value;
+ *
+ *
+ *
+ * examples
+ * "{DDII a b c d}" -> struct { double a; double b; int c; int d; }; 
+ * "{DD{FF c1 c2} a b c}" -> struct { double a; double b; struct c { float c1; float c2; }; }; 
+ *
+ *
+ */
+
+#define DYN_TYPE_INVALID 0
+#define DYN_TYPE_SIMPLE 1
+#define DYN_TYPE_COMPLEX 2
+#define DYN_TYPE_SEQUENCE 3
+#define DYN_TYPE_TYPED_POINTER 4
+#define DYN_TYPE_TEXT 5
+#define DYN_TYPE_REF 6
+
+typedef struct _dyn_type dyn_type;
+
+TAILQ_HEAD(types_head, type_entry);
+struct type_entry {
+    dyn_type *type;
+    TAILQ_ENTRY(type_entry) entries;
+};
+
+TAILQ_HEAD(complex_type_entries_head, complex_type_entry);
+struct complex_type_entry {
+    dyn_type *type;
+    char *name;
+    TAILQ_ENTRY(complex_type_entry) entries;
+};
+
+//logging
+DFI_SETUP_LOG_HEADER(dynType);
+
+//generic
+int dynType_parse(FILE *descriptorStream, const char *name, struct types_head *refTypes, dyn_type **type);
+int dynType_parseWithStr(const char *descriptor, const char *name, struct types_head *refTypes, dyn_type **type);
+void dynType_destroy(dyn_type *type);
+
+int dynType_alloc(dyn_type *type, void **bufLoc);
+void dynType_free(dyn_type *type, void *loc);
+
+void dynType_print(dyn_type *type, FILE *stream);
+size_t dynType_size(dyn_type *type);
+int dynType_type(dyn_type *type);
+int dynType_descriptorType(dyn_type *type);
+ffi_type * dynType_ffiType(dyn_type *type);
+const char * dynType_getMetaInfo(dyn_type *type, const char *name);
+
+//complexType
+int dynType_complex_indexForName(dyn_type *type, const char *name);
+int dynType_complex_dynTypeAt(dyn_type *type, int index, dyn_type **subType);
+int dynType_complex_setValueAt(dyn_type *type, int index, void *inst, void *in);
+int dynType_complex_valLocAt(dyn_type *type, int index, void *inst, void **valLoc);
+int dynType_complex_entries(dyn_type *type, struct complex_type_entries_head **entries);
+
+//sequence
+int dynType_sequence_alloc(dyn_type *type, void *inst, uint32_t cap);
+int dynType_sequence_locForIndex(dyn_type *type, void *seqLoc, int index, void **valLoc);
+int dynType_sequence_increaseLengthAndReturnLastLoc(dyn_type *type, void *seqLoc, void **valLoc);
+dyn_type * dynType_sequence_itemType(dyn_type *type);
+uint32_t dynType_sequence_length(void *seqLoc);
+
+//typed pointer
+int dynType_typedPointer_getTypedType(dyn_type *type, dyn_type **typedType);
+
+//text
+int dynType_text_allocAndInit(dyn_type *type, void *textLoc, const char *value);
+
+//simple
+void dynType_simple_setValue(dyn_type *type, void *inst, void *in);
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/json_rpc.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/json_rpc.h b/dfi/public/include/json_rpc.h
new file mode 100644
index 0000000..1cc1464
--- /dev/null
+++ b/dfi/public/include/json_rpc.h
@@ -0,0 +1,37 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+#ifndef __JSON_RPC_H_
+#define __JSON_RPC_H_
+
+#include <jansson.h>
+#include "dfi_log_util.h"
+#include "dyn_type.h"
+#include "dyn_function.h"
+#include "dyn_interface.h"
+
+//logging
+DFI_SETUP_LOG_HEADER(jsonRpc);
+
+int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, char **out);
+
+
+int jsonRpc_prepareInvokeRequest(dyn_function_type *func, const char *id, void *args[], char **out);
+int jsonRpc_handleReply(dyn_function_type *func, const char *reply, void *args[]);
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/json_serializer.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/json_serializer.h b/dfi/public/include/json_serializer.h
new file mode 100644
index 0000000..c785b01
--- /dev/null
+++ b/dfi/public/include/json_serializer.h
@@ -0,0 +1,37 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements.  See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership.  The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+#ifndef __JSON_SERIALIZER_H_
+#define __JSON_SERIALIZER_H_
+
+#include <jansson.h>
+#include "dfi_log_util.h"
+#include "dyn_type.h"
+#include "dyn_function.h"
+#include "dyn_interface.h"
+
+//logging
+DFI_SETUP_LOG_HEADER(jsonSerializer);
+
+int jsonSerializer_deserialize(dyn_type *type, const char *input, void **result);
+int jsonSerializer_deserializeJson(dyn_type *type, json_t *input, void **result);
+
+int jsonSerializer_serialize(dyn_type *type, void *input, char **output);
+int jsonSerializer_serializeJson(dyn_type *type, void *input, json_t **out);
+
+#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/memstream/README.md
----------------------------------------------------------------------
diff --git a/dfi/public/include/memstream/README.md b/dfi/public/include/memstream/README.md
new file mode 100644
index 0000000..476810e
--- /dev/null
+++ b/dfi/public/include/memstream/README.md
@@ -0,0 +1,49 @@
+fmemopen for Mac OS and iOS
+===========================
+
+Originally ported from [ingenuitas python-tesseract](https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c). Ported by Jeff Verkoeyen under the Apache 2.0 License.
+
+From the fmemopen man page:
+
+> FILE *fmemopen(void *buf, size_t size, const char *mode);
+>
+> The fmemopen() function opens a stream that permits the access specified by mode. The stream
+> allows I/O to be performed on the string or memory buffer pointed to by buf. This buffer must be
+> at least size bytes long.
+
+Alas, this method does not exist on BSD operating systems (specifically Mac OS X and iOS). It is
+possible to recreate this functionality using a BSD-specific method called `funopen`.
+
+From the funopen man page:
+
+> FILE * funopen(const void *cookie, int (*readfn)(void *, char *, int),
+>                int (*writefn)(void *, const char *, int), fpos_t (*seekfn)(void *, fpos_t, int),
+>                int (*closefn)(void *));
+>
+> The funopen() function associates a stream with up to four ``I/O functions''.  Either readfn or
+> writefn must be specified; the others can be given as an appropriately-typed NULL pointer.  These
+> I/O functions will be used to read, write, seek and close the new stream.
+
+fmemopen.c provides a simple implementation of fmemopen using funopen so that you can create FILE
+pointers to blocks of memory.
+
+Adding it to your Project
+=========================
+
+Drag fmemopen.h and fmemopen.c to your project and add them to your target. `#include "fmemopen.h"`
+wherever you need to use `fmemopen`.
+
+Examples
+========
+
+```obj-c
+#import "fmemopen.h"
+
+NSString* string = @"fmemopen in Objective-C";
+const char* cstr = [string UTF8String];
+FILE* file = fmemopen((void *)cstr, sizeof(char) * (string.length + 1), "r");
+
+// fread on file will now read the contents of the NSString
+
+fclose(file);
+```

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/memstream/fmemopen.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/memstream/fmemopen.h b/dfi/public/include/memstream/fmemopen.h
new file mode 100644
index 0000000..3d06b20
--- /dev/null
+++ b/dfi/public/include/memstream/fmemopen.h
@@ -0,0 +1,52 @@
+//
+// Copyright 2012 Jeff Verkoeyen
+// Originally ported from https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef FMEMOPEN_H_
+#define FMEMOPEN_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+ * A BSD port of the fmemopen Linux method using funopen.
+ *
+ * man docs for fmemopen:
+ * http://linux.die.net/man/3/fmemopen
+ *
+ * man docs for funopen:
+ * https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/funopen.3.html
+ *
+ * This method is ported from ingenuitas' python-tesseract project.
+ *
+ * You must call fclose on the returned file pointer or memory will be leaked.
+ *
+ *      @param buf The data that will be used to back the FILE* methods. Must be at least
+ *                 @c size bytes.
+ *      @param size The size of the @c buf data.
+ *      @param mode The permitted stream operation modes.
+ *      @returns A pointer that can be used in the fread/fwrite/fseek/fclose family of methods.
+ *               If a failure occurred NULL will be returned.
+ */
+FILE *fmemopen(void *buf, size_t size, const char *mode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef FMEMOPEN_H_

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/dfi/public/include/memstream/open_memstream.h
----------------------------------------------------------------------
diff --git a/dfi/public/include/memstream/open_memstream.h b/dfi/public/include/memstream/open_memstream.h
new file mode 100644
index 0000000..e87bb0a
--- /dev/null
+++ b/dfi/public/include/memstream/open_memstream.h
@@ -0,0 +1,15 @@
+#ifndef OPEN_MEMSTREAM_H_
+#define OPEN_MEMSTREAM_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+FILE *open_memstream(char **cp, size_t *lenp);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef FMEMOPEN_H_

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/remote_services/remote_service_admin_dfi/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/CMakeLists.txt b/remote_services/remote_service_admin_dfi/CMakeLists.txt
index b25909d..c3b3449 100644
--- a/remote_services/remote_service_admin_dfi/CMakeLists.txt
+++ b/remote_services/remote_service_admin_dfi/CMakeLists.txt
@@ -22,25 +22,21 @@ if (RSA_REMOTE_SERVICE_ADMIN_DFI)
 
     find_package(CURL REQUIRED)
     find_package(Jansson REQUIRED)
-    find_package(FFI REQUIRED)
 
     include_directories(
         ${CURL_INCLUDE_DIRS}
         ${JANSSON_INCLUDE_DIRS}
-        ${FFI_INCLUDE_DIRS}
     )
 
     if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
         include_directories(dynamic_function_interface/memstream)
     endif()
 
-    add_subdirectory(dynamic_function_interface)
     add_subdirectory(rsa)
 
     if (ENABLE_TESTING)
         find_package(CppUTest REQUIRED)
         include_directories(${CPPUTEST_INCLUDE_DIR})
-        add_subdirectory(dynamic_function_interface_tst)
         add_subdirectory(rsa_tst)
     endif()
 

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/remote_services/remote_service_admin_dfi/dynamic_function_interface/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/CMakeLists.txt b/remote_services/remote_service_admin_dfi/dynamic_function_interface/CMakeLists.txt
deleted file mode 100644
index db9ed65..0000000
--- a/remote_services/remote_service_admin_dfi/dynamic_function_interface/CMakeLists.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-include_directories(
-	.
-)
-
-set(MEMSTREAM_SOURCES "")
-if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") 
-	set(MEMSTREAM_SOURCES memstream/open_memstream.c memstream/fmemopen.c)
-endif()
-
-add_library(dfi SHARED
-    dyn_common.c
-    dyn_type.c
-    dyn_function.c
-    dyn_interface.c
-    dyn_message.c
-    json_serializer.c
-    json_rpc.c
-    ${MEMSTREAM_SOURCES}
-)
-target_link_libraries(dfi ${FFI_LIBRARIES} ${JANSSON_LIBRARY})
-
-install(TARGETS dfi DESTINATION lib COMPONENT framework)
-FILE(GLOB files "*.h")
-INSTALL(FILES ${files} DESTINATION include/celix/dfi)

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/remote_services/remote_service_admin_dfi/dynamic_function_interface/dfi_log_util.h
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dfi_log_util.h b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dfi_log_util.h
deleted file mode 100644
index 2bcd8fa..0000000
--- a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dfi_log_util.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-#ifndef _DFI_LOG_UTIL_H_
-#define _DFI_LOG_UTIL_H_
-
-typedef void (*logf_ft)(void *handle, int level, const char *file, int line, const char *format, ...); 
-
-#define DFI_SETUP_LOG_HEADER(cmp) \
-    void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel);
-
-#define DFI_SETUP_LOG(cmp) \
-    static logf_ft g_logf = NULL; \
-    static void *g_logHandle = NULL; \
-    static int g_currentLogLevel = 1; \
-    \
-    void cmp ## _logSetup(logf_ft logf, void *handle, int currentLogLevel) { \
-        g_currentLogLevel = currentLogLevel; \
-        g_logHandle = handle; \
-        g_logf = logf; \
-    }  
-
-#define LOG_LVL_ERROR    1
-#define LOG_LVL_WARNING  2
-#define LOG_LVL_INFO     3
-#define LOG_LVL_DEBUG    4
-
-#define LOG_ERROR(msg, ...) \
-    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_ERROR) { \
-        g_logf(g_logHandle, LOG_LVL_ERROR, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
-    } 
-
-#define LOG_WARNING(msg, ...) \
-    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_WARNING) { \
-        g_logf(g_logHandle, LOG_LVL_WARNING, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
-    } 
-
-#define LOG_INFO(msg, ...) \
-    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_INFO) { \
-        g_logf(g_logHandle, LOG_LVL_INFO, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
-    } 
-
-#define LOG_DEBUG(msg, ...) \
-    if (g_logf != NULL && g_currentLogLevel >= LOG_LVL_DEBUG) { \
-        g_logf(g_logHandle, LOG_LVL_DEBUG, __FILE__, __LINE__, (msg), ##__VA_ARGS__); \
-    } 
-
-#endif

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_common.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_common.c b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_common.c
deleted file mode 100644
index 6934e17..0000000
--- a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_common.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-#include "dyn_common.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <stdbool.h>
-
-#if defined(BSD) || defined(__APPLE__) 
-#include "open_memstream.h"
-#include "fmemopen.h"
-#endif
-
-static const int OK = 0;
-static const int ERROR = 1;
-
-DFI_SETUP_LOG(dynCommon)
-
-static bool dynCommon_charIn(int c, const char *acceptedChars);
-
-int dynCommon_parseName(FILE *stream, char **result) {
-    return dynCommon_parseNameAlsoAccept(stream, NULL, result);
-}
-
-int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result) {
-    int status = OK;
-
-    char *buf = NULL;
-    size_t size = 0;
-    int strLen = 0;
-    FILE *name = open_memstream(&buf, &size);
-
-    if (name != NULL) { 
-        int c = getc(stream);
-        while (isalnum(c) || c == '_' || dynCommon_charIn(c, acceptedChars)) {
-            fputc(c, name); 
-            c = getc(stream);
-            strLen += 1;
-        }
-        fflush(name);
-        fclose(name);
-        ungetc(c, stream);
-    } else {
-        status = ERROR;
-        LOG_ERROR("Error creating mem stream for name. %s", strerror(errno));
-    }
-
-    if (status == OK) {
-        if (strLen == 0) {
-            status = ERROR;
-            LOG_ERROR("Parsed empty name");
-        }
-    }
-
-    if (status == OK) {
-       LOG_DEBUG("Parsed name '%s'", buf);
-       *result = buf;
-    } else if (buf != NULL) {
-        free(buf);
-    }
-
-    return status;
-}
-
-int dynCommon_parseNameValue(FILE *stream, char **outName, char **outValue) {
-    int status = OK;
-    char *name = NULL;
-    char *value = NULL;
-    const char *valueAcceptedChars = ".<>{}[]?;:~!@#$%^&*()_+-=,./\\'\"";
-
-    status = dynCommon_parseName(stream, &name);
-    if (status == OK) {
-        status = dynCommon_eatChar(stream, '=');
-    }
-    if (status == OK) {
-        status = dynCommon_parseNameAlsoAccept(stream, valueAcceptedChars, &value); //NOTE use different more lenient function e.g. only stop at '\n' ?
-    }
-
-    if (status == OK) {
-        *outName = name;
-        *outValue = value;
-    } else {
-        if (name != NULL) {
-            free(name);
-        }
-        if (value != NULL) {
-            free(value);
-        }
-    }
-    return status;
-}
-
-int dynCommon_eatChar(FILE *stream, int expected) {
-    int status = OK;
-    long loc = ftell(stream);
-    int c = fgetc(stream);
-    if (c != expected) {
-        status = ERROR;
-        LOG_ERROR("Error parsing, expected token '%c' got '%c' at position %li", expected, loc);
-    }
-    return status;
-}
-
-static bool dynCommon_charIn(int c, const char *acceptedChars) {
-    bool status = false;
-    if (acceptedChars != NULL) {
-        int i;
-        for (i = 0; acceptedChars[i] != '\0'; i += 1) {
-            if (c == acceptedChars[i]) {
-                status = true;
-                break;
-            }
-        }
-    }
-
-    return status;
-}
-
-void dynCommon_clearNamValHead(struct namvals_head *head) {
-    struct namval_entry *tmp = NULL;
-    struct namval_entry *entry = TAILQ_FIRST(head);
-    while (entry != NULL) {
-        tmp = entry;
-
-        if (entry->name != NULL) {
-            free(entry->name);
-        }
-        if (entry->value != NULL) {
-            free(entry->value);
-        }
-        entry = TAILQ_NEXT(entry, entries);
-        free(tmp);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_common.h
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_common.h b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_common.h
deleted file mode 100644
index 6ec236f..0000000
--- a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_common.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-#ifndef _DYN_COMMON_H_
-#define _DYN_COMMON_H_
-
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/queue.h>
-
-#include "dfi_log_util.h"
-
-//logging
-DFI_SETUP_LOG_HEADER(dynCommon);
-
-TAILQ_HEAD(namvals_head, namval_entry);
-
-struct namval_entry {
-    char *name;
-    char *value;
-    TAILQ_ENTRY(namval_entry) entries;
-};
-
-int dynCommon_parseName(FILE *stream, char **result);
-int dynCommon_parseNameAlsoAccept(FILE *stream, const char *acceptedChars, char **result);
-int dynCommon_parseNameValue(FILE *stream, char **name, char **value);
-int dynCommon_eatChar(FILE *stream, int c);
-
-void dynCommon_clearNamValHead(struct namvals_head *head);
-
-#endif 

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_function.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_function.c b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_function.c
deleted file mode 100644
index 9ef7aa0..0000000
--- a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_function.c
+++ /dev/null
@@ -1,335 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-#include "dyn_function.h"
-
-#include <strings.h>
-#include <stdlib.h>
-
-#include "dyn_common.h"
-
-struct _dyn_function_type {
-    char *name;
-    struct types_head *refTypes; //NOTE not owned
-    TAILQ_HEAD(,_dyn_function_argument_type) arguments;
-    ffi_type **ffiArguments;
-    dyn_type *funcReturn;
-    ffi_cif cif;
-
-    //closure part
-    ffi_closure *ffiClosure;
-    void (*fn)(void);
-    void *userData;
-    void (*bind)(void *userData, void *args[], void *ret);
-};
-
-typedef struct _dyn_function_argument_type dyn_function_argument_type;
-struct _dyn_function_argument_type {
-    int index;
-    char *name;
-    enum dyn_function_argument_meta argumentMeta;
-    dyn_type *type;
-    TAILQ_ENTRY(_dyn_function_argument_type) entries;
-};
-
-static const int OK = 0;
-static const int MEM_ERROR = 1;
-static const int PARSE_ERROR = 2;
-static const int ERROR = 2;
-
-DFI_SETUP_LOG(dynFunction)
-
-static int dynFunction_initCif(dyn_function_type *dynFunc);
-static int dynFunction_parseDescriptor(dyn_function_type *dynFunc, FILE *descriptor);
-static void dynFunction_ffiBind(ffi_cif *cif, void *ret, void *args[], void *userData);
-
-int dynFunction_parse(FILE *descriptor, struct types_head *refTypes, dyn_function_type **out) {
-    int status = OK;
-    dyn_function_type *dynFunc = NULL;
-    LOG_DEBUG("Creating dyn function", descriptor);
-    
-    dynFunc = calloc(1, sizeof(*dynFunc));
-
-    if (dynFunc != NULL) {
-        TAILQ_INIT(&dynFunc->arguments);
-        dynFunc->refTypes = refTypes;
-        status = dynFunction_parseDescriptor(dynFunc, descriptor);
-        if (status == 0) {
-            int rc = dynFunction_initCif(dynFunc);
-            if (rc != 0) {
-                LOG_ERROR("Error initializing cif");
-                status = ERROR;
-            }
-        }
-    } else {
-        LOG_ERROR("Error allocationg memory for dyn functipn\n");
-        status = MEM_ERROR;
-    }
-
-    if (status == OK) {
-        dyn_function_argument_type *arg = NULL;
-        TAILQ_FOREACH(arg, &dynFunc->arguments, entries) {
-            const char *meta = dynType_getMetaInfo(arg->type, "am");
-            if (meta == NULL) {
-                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__STD;
-            } else if (strcmp(meta, "handle") == 0) {
-                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__HANDLE;
-            } else if (strcmp(meta, "pre") == 0) {
-                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT;
-            } else if (strcmp(meta, "out") == 0) {
-                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__OUTPUT;
-            } else {
-                LOG_WARNING("unknown argument meta '%s' encountered", meta);
-                arg->argumentMeta = DYN_FUNCTION_ARGUMENT_META__STD;
-            }
-        }
-    }
-    
-    if (status == OK) {
-        *out = dynFunc;
-    }    else {
-        if (dynFunc != NULL) {
-            dynFunction_destroy(dynFunc);
-        }
-
-    }
-    
-    return status;
-}
-
-int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **out)  {
-    int status = OK;
-    FILE *stream = fmemopen((char *)descriptor, strlen(descriptor), "r");
-    if (stream != NULL) {
-        status = dynFunction_parse(stream, refTypes, out);
-        fclose(stream);
-    } else {
-        status = MEM_ERROR;
-        LOG_ERROR("Error creating mem stream for descriptor string. %s", strerror(errno)); 
-    }
-    return status;
-}
-
-static int dynFunction_parseDescriptor(dyn_function_type *dynFunc, FILE *descriptor) {
-    int status = OK;
-    char *name = NULL;
-
-    status = dynCommon_parseName(descriptor, &name);
-
-    if (status == OK) {
-        dynFunc->name = name;
-    }
-
-    if (status == OK) {
-        int c = fgetc(descriptor);
-        if ( c != '(') {
-            status = PARSE_ERROR;
-            LOG_ERROR("Expected '(' token got '%c'", c);
-        }
-    }
-
-    int nextChar = fgetc(descriptor);
-    int index = 0;
-    dyn_type *type = NULL;
-    char argName[32];
-    while (nextChar != ')' && status == 0)  {
-        ungetc(nextChar, descriptor);
-        type = NULL;
-
-        dyn_function_argument_type *arg = NULL;
-
-        status = dynType_parse(descriptor, NULL, dynFunc->refTypes, &type);
-        if (status == 0) {
-            arg = calloc(1, sizeof(*arg));
-            if (arg != NULL) {
-                arg->index = index;
-                arg->type = type;
-                snprintf(argName, 32, "arg%04i", index);
-                arg->name = strdup(argName);
-
-                index += 1;
-            } else {
-                LOG_ERROR("Error allocating memory");
-                status = MEM_ERROR;
-            }
-        }
-
-        if (status == OK) {
-            TAILQ_INSERT_TAIL(&dynFunc->arguments, arg, entries);
-        } else {
-            if (arg != NULL) {
-                free(arg->name);
-                if (arg->type != NULL) {
-                    dynType_destroy(arg->type);
-                }
-                free(arg);
-            }
-        }
-        nextChar = fgetc(descriptor);
-    }
-
-    if (status == 0) {
-        status = dynType_parse(descriptor, NULL, dynFunc->refTypes, &dynFunc->funcReturn); 
-    }
-    
-    return status;
-}
-
-enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr) {
-    enum dyn_function_argument_meta result = 0;
-    dyn_function_argument_type *arg = NULL;
-    int index = 0;
-    TAILQ_FOREACH(arg, &dynFunc->arguments, entries) {
-        if (index == argumentNr) {
-            result = arg->argumentMeta;
-            break;
-        }
-        index += 1;
-    }
-    return result;
-}
-
-
-static int dynFunction_initCif(dyn_function_type *dynFunc) {
-    int status = 0;
-
-    int count = 0;
-    dyn_function_argument_type *entry = NULL;
-    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
-        count +=1;
-    }
-
-    dynFunc->ffiArguments = calloc(count, sizeof(ffi_type));
-
-    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
-        dynFunc->ffiArguments[entry->index] = dynType_ffiType(entry->type);
-    }
-    
-    ffi_type **args = dynFunc->ffiArguments;
-    ffi_type *returnType = dynType_ffiType(dynFunc->funcReturn);
-
-    int ffiResult = ffi_prep_cif(&dynFunc->cif, FFI_DEFAULT_ABI, count, returnType, args);
-    if (ffiResult != FFI_OK) {
-        status = 1;
-    }
-
-    return status;
-}
-
-void dynFunction_destroy(dyn_function_type *dynFunc) {
-    if (dynFunc != NULL) {
-        if (dynFunc->funcReturn != NULL) {
-            dynType_destroy(dynFunc->funcReturn);
-        }
-        if (dynFunc->ffiClosure != NULL) {
-            ffi_closure_free(dynFunc->ffiClosure);
-        }
-        if (dynFunc->name != NULL) {
-            free(dynFunc->name);
-        }
-        if (dynFunc->ffiArguments != NULL) {
-            free(dynFunc->ffiArguments);
-        }
-        
-        dyn_function_argument_type *entry = NULL;
-        dyn_function_argument_type *tmp = NULL;
-        entry = TAILQ_FIRST(&dynFunc->arguments); 
-        while (entry != NULL) {
-            if (entry->name != NULL) {
-                free(entry->name);
-            }
-            dynType_destroy(entry->type);
-            tmp = entry;
-            entry = TAILQ_NEXT(entry, entries);
-            free(tmp);
-        }
-
-        free(dynFunc);
-    }
-}
-
-int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues) {
-    ffi_call(&dynFunc->cif, fn, returnValue, argValues);
-    return 0;
-}
-
-static void dynFunction_ffiBind(ffi_cif *cif, void *ret, void *args[], void *userData) {
-    dyn_function_type *dynFunc = userData;
-    dynFunc->bind(dynFunc->userData, args, ret);
-}
-
-int dynFunction_createClosure(dyn_function_type *dynFunc, void (*bind)(void *, void **, void*), void *userData, void(**out)(void)) {
-    int status = 0;
-    void (*fn)(void);
-    dynFunc->ffiClosure = ffi_closure_alloc(sizeof(ffi_closure), (void **)&fn);
-    if (dynFunc->ffiClosure != NULL) {
-        int rc = ffi_prep_closure_loc(dynFunc->ffiClosure, &dynFunc->cif, dynFunction_ffiBind, dynFunc, fn);
-        if (rc != FFI_OK) {
-            status = 1;
-        }
-    } else {
-        status = 2;
-    }
-
-    if (status == 0) {
-        dynFunc->userData = userData;
-        dynFunc->bind = bind;
-        dynFunc->fn = fn;
-        *out =fn;
-    }
-
-    return status;
-}
-
-int dynFunction_getFnPointer(dyn_function_type *dynFunc, void (**fn)(void)) {
-    int status = 0;
-    if (dynFunc != NULL && dynFunc->fn != NULL) {
-        (*fn) = dynFunc->fn;
-    } else {
-        status = 1;
-    }
-    return status;
-}
-
-int dynFunction_nrOfArguments(dyn_function_type *dynFunc) {
-    int count = 0;
-    dyn_function_argument_type *entry = NULL;
-    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
-        count += 1;
-    }
-    return count;
-}
-
-dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr) {
-    dyn_type *result = NULL;
-    int index = 0;
-    dyn_function_argument_type *entry = NULL;
-    TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
-        if (index == argumentNr) {
-            result = entry->type;
-            break;
-        }
-        index +=1;
-    }
-    return result;
-}
-
-dyn_type * dynFunction_returnType(dyn_function_type *dynFunction) {
-    return dynFunction->funcReturn;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/18a5bf74/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_function.h
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_function.h b/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_function.h
deleted file mode 100644
index 792691e..0000000
--- a/remote_services/remote_service_admin_dfi/dynamic_function_interface/dyn_function.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements.  See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership.  The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-#ifndef __DYN_FUNCTION_H_
-#define __DYN_FUNCTION_H_
-
-#include <ffi.h>
-#include "dyn_type.h"
-#include "dfi_log_util.h"
-
-/**
- * Uses the following schema
- * (Name)([Type]*)Type
- *
- * Dyn fynction argument meta (am) as meta info, with the following possible values
- * am=handle #void pointer for the handle
- * am=pre #output pointer with memory preallocated
- * am=out #output pointer
- */
-
-typedef struct _dyn_function_type dyn_function_type;
-
-DFI_SETUP_LOG_HEADER(dynFunction);
-
-enum dyn_function_argument_meta {
-    DYN_FUNCTION_ARGUMENT_META__STD = 0,
-    DYN_FUNCTION_ARGUMENT_META__HANDLE = 1,
-    DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT = 2,
-    DYN_FUNCTION_ARGUMENT_META__OUTPUT = 3
-};
-
-int dynFunction_parse(FILE *descriptorStream, struct types_head *refTypes, dyn_function_type **dynFunc);
-int dynFunction_parseWithStr(const char *descriptor, struct types_head *refTypes, dyn_function_type **dynFunc);
-
-int dynFunction_nrOfArguments(dyn_function_type *dynFunc);
-dyn_type *dynFunction_argumentTypeForIndex(dyn_function_type *dynFunc, int argumentNr);
-enum dyn_function_argument_meta dynFunction_argumentMetaForIndex(dyn_function_type *dynFunc, int argumentNr);
-dyn_type * dynFunction_returnType(dyn_function_type *dynFunction);
-
-void dynFunction_destroy(dyn_function_type *dynFunc);
-int dynFunction_call(dyn_function_type *dynFunc, void(*fn)(void), void *returnValue, void **argValues);
-
-int dynFunction_createClosure(dyn_function_type *func, void (*bind)(void *, void **, void*), void *userData, void(**fn)(void));
-int dynFunction_getFnPointer(dyn_function_type *func, void (**fn)(void));
-
-#endif


Mime
View raw message