You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2017/11/20 20:33:30 UTC

[33/46] celix git commit: CELIX-417: Initial refactoring for CMake usage

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/src/dyn_type.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_type.c b/dfi/private/src/dyn_type.c
deleted file mode 100644
index 4fc79ff..0000000
--- a/dfi/private/src/dyn_type.c
+++ /dev/null
@@ -1,1160 +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_type.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <errno.h>
-#include <ffi.h>
-
-#include "dyn_common.h"
-
-DFI_SETUP_LOG(dynType)
-
-static int dynType_parseWithStream(FILE *stream, const char *name, dyn_type *parent, struct types_head *refTypes, dyn_type **result);
-static void dynType_clear(dyn_type *type);
-static void dynType_clearComplex(dyn_type *type);
-static void dynType_clearSequence(dyn_type *type);
-static void dynType_clearTypedPointer(dyn_type *type);
-ffi_type * dynType_ffiType(dyn_type *type);
-
-static struct type_entry *dynType_allocTypeEntry(void);
-
-static ffi_type * dynType_ffiTypeFor(int c);
-static dyn_type * dynType_findType(dyn_type *type, char *name);
-static int dynType_parseAny(FILE *stream, dyn_type *type);
-static int dynType_parseComplex(FILE *stream, dyn_type *type);
-static int dynType_parseNestedType(FILE *stream, dyn_type *type);
-static int dynType_parseReference(FILE *stream, dyn_type *type);
-static int dynType_parseRefByValue(FILE *stream, dyn_type *type);
-static int dynType_parseSequence(FILE *stream, dyn_type *type);
-static int dynType_parseSimple(int c, dyn_type *type);
-static int dynType_parseTypedPointer(FILE *stream, dyn_type *type);
-static void dynType_prepCif(ffi_type *type);
-static unsigned short dynType_getOffset(dyn_type *type, int index);
-
-static void dynType_printAny(char *name, dyn_type *type, int depth, FILE *stream);
-static void dynType_printComplex(char *name, dyn_type *type, int depth, FILE *stream);
-static void dynType_printSequence(char *name, dyn_type *type, int depth, FILE *stream);
-static void dynType_printSimple(char *name, dyn_type *type, int depth, FILE *stream);
-static void dynType_printTypedPointer(char *name, dyn_type *type, int depth, FILE *stream);
-static void dynType_printDepth(int depth, FILE *stream);
-
-static void dynType_printTypes(dyn_type *type, FILE *stream);
-static void dynType_printComplexType(dyn_type *type, FILE *stream);
-static void dynType_printSimpleType(dyn_type *type, FILE *stream);
-
-static int dynType_parseText(FILE *stream, dyn_type *type);
-void dynType_freeComplexType(dyn_type *type, void *loc);
-void dynType_deepFree(dyn_type *type, void *loc, bool alsoDeleteSelf);
-void dynType_freeSequenceType(dyn_type *type, void *seqLoc);
-
-static int dynType_parseMetaInfo(FILE *stream, dyn_type *type);
-
-struct generic_sequence {
-    uint32_t cap;
-    uint32_t len;
-    void *buf;
-};
-
-TAILQ_HEAD(meta_properties_head, meta_entry);
-struct meta_entry {
-    char *name;
-    char *value;
-    TAILQ_ENTRY(meta_entry) entries;
-};
-
-
-struct _dyn_type {
-    char *name;
-    char descriptor;
-    int type;
-    ffi_type *ffiType;
-    dyn_type *parent;
-    struct types_head *referenceTypes; //NOTE: not owned
-    struct types_head nestedTypesHead;
-    struct meta_properties_head metaProperties;
-    union {
-        struct {
-            struct complex_type_entries_head entriesHead;
-            ffi_type structType; //dyn_type.ffiType points to this
-            dyn_type **types; //based on entriesHead for fast access
-        } complex;
-        struct {
-            ffi_type seqType; //dyn_type.ffiType points to this
-            dyn_type *itemType;
-        } sequence;
-        struct {
-            dyn_type *typedType;
-        } typedPointer;
-        struct {
-            dyn_type *ref;
-        } ref;
-    };
-};
-
-static const int OK = 0;
-static const int ERROR = 1;
-static const int MEM_ERROR = 2;
-static const int PARSE_ERROR = 3;
-
-int dynType_parse(FILE *descriptorStream, const char *name, struct types_head *refTypes, dyn_type **type) {
-    return dynType_parseWithStream(descriptorStream, name, NULL, refTypes, type);
-}
-
-int dynType_parseWithStr(const char *descriptor, const char *name, struct types_head *refTypes, dyn_type **type) {
-    int status = OK;
-    FILE *stream = fmemopen((char *)descriptor, strlen(descriptor), "r");
-    if (stream != NULL) {
-        status = dynType_parseWithStream(stream, name, NULL, refTypes, type);
-        if (status == OK) {
-            int c = fgetc(stream);
-            if (c != '\0' && c != EOF) {
-                status = PARSE_ERROR;
-                LOG_ERROR("Expected EOF got %c", c);
-            }
-        } 
-        fclose(stream);
-    } else {
-        status = ERROR;
-        LOG_ERROR("Error creating mem stream for descriptor string. %s", strerror(errno)); 
-    }
-    return status;
-}
-
-static int dynType_parseWithStream(FILE *stream, const char *name, dyn_type *parent, struct types_head *refTypes, dyn_type **result) {
-    int status = OK;
-    dyn_type *type = calloc(1, sizeof(*type));
-    if (type != NULL) {
-        type->parent = parent;
-        type->type = DYN_TYPE_INVALID;
-        type->referenceTypes = refTypes;
-        TAILQ_INIT(&type->nestedTypesHead);
-        TAILQ_INIT(&type->metaProperties);
-        if (name != NULL) {
-            type->name = strdup(name);
-            if (type->name == NULL) {
-                status = MEM_ERROR;
-                LOG_ERROR("Error strdup'ing name '%s'\n", name);			
-            } 
-        }
-        if (status == OK) {
-            status = dynType_parseAny(stream, type);        
-        }
-        if (status == OK) {
-            *result = type;
-        } else {
-            dynType_destroy(type);
-        }
-    } else {
-        status = MEM_ERROR;
-        LOG_ERROR("Error allocating memory for type");
-    }
-    return status;
-}
-
-static int dynType_parseAny(FILE *stream, dyn_type *type) {
-    int status = OK;
-
-    int c = fgetc(stream);
-    switch(c) {
-        case 'T' :
-            status = dynType_parseNestedType(stream, type);
-            if (status == OK) {
-                status = dynType_parseAny(stream, type);
-            } 
-            break;
-        case 'L' :
-            status = dynType_parseReference(stream, type);
-            break;
-        case 'l' :
-            status = dynType_parseRefByValue(stream, type);
-            break;
-        case '{' :
-            status = dynType_parseComplex(stream, type);
-            break;
-        case '[' :
-            status = dynType_parseSequence(stream, type);
-            break;
-        case '*' :
-            status = dynType_parseTypedPointer(stream, type);
-            break;
-        case 't' :
-            status = dynType_parseText(stream, type);
-            break;
-        case '#' :
-            status = dynType_parseMetaInfo(stream, type);
-            if (status == OK) {
-                status = dynType_parseAny(stream, type);
-            }
-            break;
-        default :
-            status = dynType_parseSimple(c, type);
-            break;
-    }
-
-    return status;
-}
-
-static int dynType_parseMetaInfo(FILE *stream, dyn_type *type) {
-    int status = OK;
-    char *name = NULL;
-    char *value = NULL;
-
-    struct meta_entry *entry = calloc(1, sizeof(*entry));
-    if (entry == NULL) {
-        status = ERROR;
-    }
-
-    if (status == OK) {
-        status = dynCommon_parseName(stream, &name);
-    }
-
-    if (status == OK) {
-        status = dynCommon_eatChar(stream, '=');
-    }
-
-    if (status == OK) {
-        status = dynCommon_parseName(stream, &value);
-    }
-
-    if (status == OK) {
-        status = dynCommon_eatChar(stream, ';');
-    }
-
-    if (status == OK) {
-        entry->name = name;
-        entry->value = value;
-        TAILQ_INSERT_TAIL(&type->metaProperties, entry, entries);
-        LOG_DEBUG("Added meta properties '%s':'%s'", name, value)
-    } else {
-        free(name);
-        free(value);
-        free(entry);
-    }
-
-    return status;
-}
-
-static int dynType_parseText(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_TEXT;
-    type->descriptor = 't';
-    type->ffiType = &ffi_type_pointer;
-    return status;
-}
-
-static int dynType_parseComplex(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_COMPLEX;
-    type->descriptor = '{';
-    type->ffiType = &type->complex.structType;
-    TAILQ_INIT(&type->complex.entriesHead);
-
-    int c = fgetc(stream);
-    struct complex_type_entry *entry = NULL;
-    while (c != ' ' && c != '}') {
-        ungetc(c,stream);
-        entry = calloc(1, sizeof(*entry));
-        if (entry != NULL) {
-            entry->type = calloc(1, sizeof(*entry->type));
-        }
-        if (entry != NULL && entry->type != NULL) {
-            entry->type->parent = type;
-            entry->type->type = DYN_TYPE_INVALID;
-            TAILQ_INIT(&entry->type->nestedTypesHead);
-            TAILQ_INIT(&entry->type->metaProperties);
-            TAILQ_INSERT_TAIL(&type->complex.entriesHead, entry, entries);
-            status = dynType_parseAny(stream, entry->type);
-        } else {
-            free(entry);
-            status = MEM_ERROR;
-            LOG_ERROR("Error allocating memory for type");
-        }
-
-        if (status != OK) {
-            break;
-        }
-
-        c = fgetc(stream);
-    }
-
-
-    if (status == OK) {
-        entry = TAILQ_FIRST(&type->complex.entriesHead);
-        char *name = NULL;
-        while (c == ' ' && entry != NULL) {
-            status = dynCommon_parseName(stream, &name);
-            if (status == OK) {
-                entry->name = name;
-                entry = TAILQ_NEXT(entry, entries);
-            } else {
-                break;
-            }
-            c = getc(stream); 
-        }
-    }
-
-    int count = 0;
-    if (status == OK) {
-        TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-            count +=1;
-        }
-    }
-
-    if (status == OK) {
-        type->complex.structType.type =  FFI_TYPE_STRUCT;
-        type->complex.structType.elements = calloc(count + 1, sizeof(ffi_type*));
-        if (type->complex.structType.elements != NULL) {
-            type->complex.structType.elements[count] = NULL;
-            int index = 0;
-            TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-                type->complex.structType.elements[index++] = dynType_ffiType(entry->type);
-            }
-        } else {
-            status = MEM_ERROR;
-            LOG_ERROR("Error allocating memory for elements")
-        }
-    }
-
-    if (status == OK) {
-        type->complex.types = calloc(count, sizeof(dyn_type *));
-        if (type->complex.types != NULL) {
-            int index = 0;
-            TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-                type->complex.types[index++] = entry->type;
-            }
-        } else {
-            status = MEM_ERROR;
-            LOG_ERROR("Error allocating memory for type")
-        }
-    }
-
-    if (status == OK) {
-        dynType_prepCif(type->ffiType);
-    }
-
-
-    return status;
-}
-
-static int dynType_parseNestedType(FILE *stream, dyn_type *type) {
-    int status = OK;
-    char *name = NULL;
-    struct type_entry *entry = NULL;
-
-    entry = dynType_allocTypeEntry();
-    if (entry != NULL) {
-        entry->type->parent = type;
-        entry->type->type = DYN_TYPE_INVALID;
-        TAILQ_INIT(&entry->type->nestedTypesHead);
-        TAILQ_INIT(&entry->type->metaProperties);
-        TAILQ_INSERT_TAIL(&type->nestedTypesHead, entry, entries);
-        status = dynCommon_parseName(stream, &name);
-        entry->type->name = name;
-    } else {
-        status = MEM_ERROR;
-        LOG_ERROR("Error allocating entry");
-    }     
-
-    if (status == OK) {
-        int c = fgetc(stream);
-        if (c != '=') {
-            status = PARSE_ERROR;
-            LOG_ERROR("Error parsing nested type expected '=' got '%c'", c);
-        }
-    }
-
-    if (status == OK) {
-        status = dynType_parseAny(stream, entry->type);
-        int c = fgetc(stream);
-        if (c != ';') {
-            status = PARSE_ERROR;
-            LOG_ERROR("Expected ';' got '%c'\n", c);
-        }
-    }
-
-    return status;
-}
-
-static int dynType_parseReference(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_TYPED_POINTER;
-    type->descriptor = '*';
-
-    type->ffiType = &ffi_type_pointer;
-    type->typedPointer.typedType =  NULL;
-
-    dyn_type *subType = calloc(1, sizeof(*subType));
-
-    if (subType != NULL) {
-        type->typedPointer.typedType = subType;
-        subType->parent = type;
-        subType->type = DYN_TYPE_INVALID;
-        TAILQ_INIT(&subType->nestedTypesHead);
-        TAILQ_INIT(&subType->metaProperties);
-        status = dynType_parseRefByValue(stream, subType);
-    } else {
-        status = MEM_ERROR;
-        LOG_ERROR("Error allocating memory for subtype\n");
-    }
-
-    return status;
-}
-
-static int dynType_parseRefByValue(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_REF;
-    type->descriptor = 'l';
-
-    char *name = NULL;
-    status = dynCommon_parseName(stream, &name);
-    if (status == OK) {
-        dyn_type *ref = dynType_findType(type, name);
-        if (ref != NULL) {
-            type->ref.ref = ref;
-        } else {
-            status = PARSE_ERROR;
-            LOG_ERROR("Error cannot find type '%s'", name);
-        }
-        free(name);
-    } 
-
-    if (status ==OK) {
-        int c = fgetc(stream);
-        if (c != ';') {
-            status = PARSE_ERROR;
-            LOG_ERROR("Error expected ';' got '%c'", c);
-        } 
-    }
-
-    return status;
-}
-
-static struct type_entry *dynType_allocTypeEntry(void) {
-    struct type_entry *entry = calloc(1, sizeof(*entry));
-    if (entry != NULL) {
-        entry->type = calloc(1, sizeof(*entry->type));
-        if (entry->type == NULL) {
-            free(entry);
-            entry = NULL;
-        }
-    }
-    return entry;
-}
-
-static ffi_type *seq_types[] = {&ffi_type_uint32, &ffi_type_uint32, &ffi_type_pointer, NULL};
-
-static int dynType_parseSequence(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_SEQUENCE;
-    type->descriptor = '[';
-
-    type->sequence.seqType.elements = seq_types;
-    type->sequence.seqType.type = FFI_TYPE_STRUCT;
-    type->sequence.seqType.size = 0;
-    type->sequence.seqType.alignment = 0;
-
-    status = dynType_parseWithStream(stream, NULL, type, NULL, &type->sequence.itemType);
-
-    if (status == OK) {
-        type->ffiType = &type->sequence.seqType;
-        dynType_prepCif(&type->sequence.seqType);
-    }
-
-    return status;
-}
-
-static int dynType_parseSimple(int c, dyn_type *type) {
-    int status = OK;
-    ffi_type *ffiType = dynType_ffiTypeFor(c);
-    if (ffiType != NULL) {
-        type->type = DYN_TYPE_SIMPLE;
-        type->descriptor = c;
-        type->ffiType = ffiType;
-    } else {
-        status = PARSE_ERROR;
-        LOG_ERROR("Error unsupported type '%c'", c);
-    }
-
-    return status;
-}
-
-static int dynType_parseTypedPointer(FILE *stream, dyn_type *type) {
-    int status = OK;
-    type->type = DYN_TYPE_TYPED_POINTER;
-    type->descriptor = '*';
-    type->ffiType = &ffi_type_pointer;
-
-    status = dynType_parseWithStream(stream, NULL, type, NULL, &type->typedPointer.typedType);
-
-    return status;
-}
-
-static void dynType_prepCif(ffi_type *type) {
-    ffi_cif cif;
-    ffi_type *args[1];
-    args[0] = type;
-    ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 1, &ffi_type_uint, args);
-}
-
-void dynType_destroy(dyn_type *type) {
-    if (type != NULL) {          
-        dynType_clear(type);
-        free(type);
-    }
-}
-
-static void dynType_clear(dyn_type *type) {
-    struct type_entry *entry = TAILQ_FIRST(&type->nestedTypesHead);
-    struct type_entry *tmp = NULL;
-    while (entry != NULL) {
-        tmp = entry;
-        entry = TAILQ_NEXT(entry, entries);
-        if (tmp->type != NULL) {
-            dynType_destroy(tmp->type);
-            tmp->type = NULL;
-        }
-        free(tmp);
-    }
-
-    struct meta_entry *mEntry = TAILQ_FIRST(&type->metaProperties);;
-    struct meta_entry *next = NULL;
-    while (mEntry != NULL) {
-        next = TAILQ_NEXT(mEntry, entries);
-        if (mEntry != NULL) {
-            free(mEntry->name);
-            free(mEntry->value);
-            free(mEntry);
-        }
-        mEntry = next;
-    }
-
-    switch (type->type) {
-        case DYN_TYPE_COMPLEX :
-            dynType_clearComplex(type);
-            break;
-        case DYN_TYPE_SEQUENCE :
-            dynType_clearSequence(type);
-            break;
-        case DYN_TYPE_TYPED_POINTER :
-            dynType_clearTypedPointer(type);
-            break;
-    } 
-
-    if (type->name != NULL) {
-        free(type->name);
-    }
-}
-
-static void dynType_clearComplex(dyn_type *type) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    struct complex_type_entry *entry = TAILQ_FIRST(&type->complex.entriesHead);
-    struct complex_type_entry *tmp = NULL;
-    while (entry != NULL) {
-        dynType_destroy(entry->type);
-        if (entry->name != NULL) {
-            free(entry->name);
-        }
-        tmp = entry;
-        entry = TAILQ_NEXT(entry, entries);
-        free(tmp);
-    }
-    if (type->complex.types != NULL) {
-        free(type->complex.types);
-    }
-    if (type->complex.structType.elements != NULL) {
-        free(type->complex.structType.elements);
-    }
-}
-
-static void dynType_clearSequence(dyn_type *type) {
-    assert(type->type == DYN_TYPE_SEQUENCE);
-    if (type->sequence.itemType != NULL) {
-        dynType_destroy(type->sequence.itemType);
-    }
-}
-
-static void dynType_clearTypedPointer(dyn_type *type) {
-    assert(type->type == DYN_TYPE_TYPED_POINTER);
-    if (type->typedPointer.typedType != NULL) {
-        dynType_destroy(type->typedPointer.typedType);
-    }
-}
-
-int dynType_alloc(dyn_type *type, void **bufLoc) {
-    assert(type->type != DYN_TYPE_REF);
-    assert(type->ffiType->size != 0);
-    int status = OK;
-
-    void *inst = calloc(1, type->ffiType->size);
-    if (inst != NULL) {
-        if (type->type == DYN_TYPE_TYPED_POINTER) {
-            void *ptr = NULL;
-            dyn_type *sub = NULL;
-            status = dynType_typedPointer_getTypedType(type, &sub);
-            if (status == OK) {
-                status = dynType_alloc(sub, &ptr);
-                if (status == OK) {
-                    *(void **)inst = ptr;
-                }
-            }
-        }
-        *bufLoc = inst;
-    } else {
-        status = MEM_ERROR;
-        LOG_ERROR("Error allocating memory for type '%c'", type->descriptor);
-    }
-
-    return status;
-}
-
-
-int dynType_complex_indexForName(dyn_type *type, const char *name) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    int i = 0;
-    int index = -1;
-    struct complex_type_entry *entry = NULL;
-    TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-        if (strcmp(name, entry->name) == 0) {
-            index = i;
-        }
-        i +=1;
-    }
-    return index;
-}
-
-int dynType_complex_dynTypeAt(dyn_type *type, int index, dyn_type **result) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    assert(index >= 0);
-    dyn_type *sub = type->complex.types[index];
-    if (sub->type == DYN_TYPE_REF) {
-        sub = sub->ref.ref;
-    }
-    *result = sub;
-    return 0;
-}
-
-int dynType_complex_setValueAt(dyn_type *type, int index, void *start, void *in) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    char *loc = ((char *)start) + dynType_getOffset(type, index);
-    size_t size = type->complex.structType.elements[index]->size;
-    memcpy(loc, in, size);
-    return 0;
-}
-
-int dynType_complex_valLocAt(dyn_type *type, int index, void *inst, void **result) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    char *l = (char *)inst;
-    void *loc = (void *)(l + dynType_getOffset(type, index));
-    *result = loc;
-    return OK;
-}
-
-int dynType_complex_entries(dyn_type *type, struct complex_type_entries_head **entries) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    int status = OK;
-    *entries = &type->complex.entriesHead;
-    return status;
-}
-
-//sequence
-int dynType_sequence_alloc(dyn_type *type, void *inst, uint32_t cap) {
-    assert(type->type == DYN_TYPE_SEQUENCE);
-    int status = OK;
-    struct generic_sequence *seq = inst;
-    if (seq != NULL) {
-        size_t size = dynType_size(type->sequence.itemType);
-        seq->buf = calloc(cap, size);
-        if (seq->buf != NULL) {
-            seq->cap = cap;
-            seq->len = 0;;
-        } else {
-            seq->cap = 0;
-            status = MEM_ERROR;
-            LOG_ERROR("Error allocating memory for buf")
-        }
-    } else {
-            status = MEM_ERROR;
-            LOG_ERROR("Error allocating memory for seq")
-    }
-    return status;
-}
-
-void dynType_free(dyn_type *type, void *loc) {
-    dynType_deepFree(type, loc, true);
-}
-
-void dynType_deepFree(dyn_type *type, void *loc, bool alsoDeleteSelf) {
-    if (loc != NULL) {
-        dyn_type *subType = NULL;
-        char *text = NULL;
-        switch (type->type) {
-            case DYN_TYPE_COMPLEX :
-                dynType_freeComplexType(type, loc);
-                break;
-            case DYN_TYPE_SEQUENCE :
-                dynType_freeSequenceType(type, loc);
-                break;
-            case DYN_TYPE_TYPED_POINTER:
-                dynType_typedPointer_getTypedType(type, &subType);
-                dynType_deepFree(subType, *(void **)loc, true);
-                break;
-            case DYN_TYPE_TEXT :
-                text = *(char **)loc;
-                free(text);
-                break;
-        }
-
-        if (alsoDeleteSelf) {
-            free(loc);
-        }
-    }
-}
-
-void dynType_freeSequenceType(dyn_type *type, void *seqLoc) {
-    struct generic_sequence *seq = seqLoc;
-    dyn_type *itemType = dynType_sequence_itemType(type);
-    void *itemLoc = NULL;
-    int i;
-    for (i = 0; i < seq->len; i += 1) {
-        dynType_sequence_locForIndex(type, seqLoc, i, &itemLoc);
-        dynType_deepFree(itemType, itemLoc, false);
-    }
-    free(seq->buf);
-}
-
-void dynType_freeComplexType(dyn_type *type, void *loc) {
-    struct complex_type_entry *entry = NULL;
-    int index = 0;
-    void *entryLoc = NULL;
-    TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-        dynType_complex_valLocAt(type, index++, loc, &entryLoc);
-        dynType_deepFree(entry->type, entryLoc, false);
-    }
-}
-
-
-uint32_t dynType_sequence_length(void *seqLoc) {
-    struct generic_sequence *seq = seqLoc;
-    return seq->len;
-}
-
-int dynType_sequence_locForIndex(dyn_type *type, void *seqLoc, int index, void **out) {
-    assert(type->type == DYN_TYPE_SEQUENCE);
-    int status = OK;
-
-    struct generic_sequence *seq = seqLoc;
-    char *valLoc = seq->buf;
-
-    size_t itemSize = dynType_size(type->sequence.itemType);
-
-    if (index >= seq->cap) {
-        status = ERROR;
-        LOG_ERROR("Requested index (%i) is greater than capacity (%u) of sequence", index, seq->cap);
-    }
-
-    if (index >= seq->len) {
-        LOG_WARNING("Requesting index (%i) outsize defined length (%u) but within capacity", index, seq->len);
-    }
-
-    if (status == OK) { }
-    int i;
-    for (i = 0; i < seq->cap; i += 1) {
-        if (index == i) {
-            break;
-        } else {
-            valLoc += itemSize;
-        }
-    }
-
-    (*out) = valLoc;
-
-    return status;
-}
-
-int dynType_sequence_increaseLengthAndReturnLastLoc(dyn_type *type, void *seqLoc, void **valLoc) {
-    assert(type->type == DYN_TYPE_SEQUENCE);
-    int status = OK;
-    struct generic_sequence *seq = seqLoc;
-
-    int lastIndex = seq->len;
-    if (seq->len < seq->cap) {
-        seq->len += 1;
-    } else {
-        status = ERROR;
-        LOG_ERROR("Cannot increase sequence length beyond capacity (%u)", seq->cap);
-    }
-
-    if (status == OK) {
-        status = dynType_sequence_locForIndex(type, seqLoc, lastIndex, valLoc);
-    }
-
-    return status;
-}
-
-dyn_type * dynType_sequence_itemType(dyn_type *type) {
-    assert(type->type == DYN_TYPE_SEQUENCE);
-    dyn_type *itemType = type->sequence.itemType;
-    if (itemType->type == DYN_TYPE_REF) {
-        itemType = itemType->ref.ref;
-    }
-    return itemType;
-}
-
-void dynType_simple_setValue(dyn_type *type, void *inst, void *in) {
-    size_t size = dynType_size(type);
-    memcpy(inst, in, size);
-}
-
-
-int dynType_descriptorType(dyn_type *type) {
-    return type->descriptor;
-}
-
-const char * dynType_getMetaInfo(dyn_type *type, const char *name) {
-    const char *result = NULL;
-    struct meta_entry *entry = NULL;
-    TAILQ_FOREACH(entry, &type->metaProperties, entries) {
-        LOG_DEBUG("Checking '%s'", entry->name);
-        if (strcmp(entry->name, name) == 0) {
-            result = entry->value;
-            break;
-        }
-    }
-    return result;
-}
-
-ffi_type *dynType_ffiType(dyn_type *type) {
-    if (type->type == DYN_TYPE_REF) {
-        if (type->ref.ref == NULL) {
-            LOG_ERROR("Error. Ref for %s is not (yet) initialized", type->name);
-            return NULL;
-        }
-        return type->ref.ref->ffiType;
-    }
-    return type->ffiType;
-}
-
-static ffi_type * dynType_ffiTypeFor(int c) {
-    ffi_type *type = NULL;
-    switch (c) {
-        case 'Z' :
-            type = &ffi_type_uint8;
-            break;
-        case 'F' :
-            type = &ffi_type_float;
-            break;
-        case 'D' :
-            type = &ffi_type_double;
-            break;
-        case 'B' :
-            type = &ffi_type_sint8;
-            break;
-        case 'b' :
-            type = &ffi_type_uint8;
-            break;
-        case 'S' :
-            type = &ffi_type_sint16;
-            break;
-        case 's' :
-            type = &ffi_type_uint16;
-            break;
-        case 'I' :
-            type = &ffi_type_sint32;
-            break;
-        case 'i' :
-            type = &ffi_type_uint32;
-            break;
-        case 'J' :
-            type = &ffi_type_sint64;
-            break;
-        case 'j' :
-            type = &ffi_type_sint64;
-            break;
-        case 'N' :
-            type = &ffi_type_sint;
-            break;
-        case 'P' :
-            type = &ffi_type_pointer;
-            break;
-        case 'V' :
-            type = &ffi_type_void;
-            break;
-    }
-    return type;
-}
-
-static dyn_type * dynType_findType(dyn_type *type, char *name) {
-    dyn_type *result = NULL;
-
-    struct type_entry *entry = NULL;
-    if (type->referenceTypes != NULL) {
-        TAILQ_FOREACH(entry, type->referenceTypes, entries) {
-            LOG_DEBUG("checking ref type '%s' with name '%s'", entry->type->name, name);
-            if (strcmp(name, entry->type->name) == 0) {
-                result = entry->type;
-                break;
-            }
-        }
-    }
-
-    if (result == NULL) {
-        struct type_entry *nEntry = NULL;
-        TAILQ_FOREACH(nEntry, &type->nestedTypesHead, entries) {
-            LOG_DEBUG("checking nested type '%s' with name '%s'", nEntry->type->name, name);
-            if (strcmp(name, nEntry->type->name) == 0) {
-                result = nEntry->type;
-                break;
-            }
-        }
-    }
-
-    if (result == NULL && type->parent != NULL) {
-        result = dynType_findType(type->parent, name);
-    }
-
-    return result;
-}
-
-static unsigned short dynType_getOffset(dyn_type *type, int index) {
-    assert(type->type == DYN_TYPE_COMPLEX);
-    unsigned short offset = 0;
-
-    ffi_type *ffiType = &type->complex.structType;
-    int i;
-    for (i = 0;  i <= index && ffiType->elements[i] != NULL; i += 1) {
-        size_t size = ffiType->elements[i]->size;
-        unsigned short alignment = ffiType->elements[i]->alignment;
-        int alignment_diff = offset % alignment;
-        if (alignment_diff > 0) {
-            offset += (alignment - alignment_diff);
-        }
-        if (i < index) {
-            offset += size;
-        }
-    }
-
-    return offset;
-}
-
-size_t dynType_size(dyn_type *type) {
-    dyn_type *rType = type;
-    if (type->type == DYN_TYPE_REF) {
-        rType = type->ref.ref;
-    }
-    return rType->ffiType->size;
-}
-
-int dynType_type(dyn_type *type) {
-    return type->type;
-}
-
-
-int dynType_typedPointer_getTypedType(dyn_type *type, dyn_type **out) {
-    assert(type->type == DYN_TYPE_TYPED_POINTER);
-    int status = 0;
-
-    dyn_type *typedType = type->typedPointer.typedType;
-    if (typedType->type == DYN_TYPE_REF) {
-        typedType = typedType->ref.ref;
-    }
-
-    *out = typedType;
-    return status;
-}
-
-
-int dynType_text_allocAndInit(dyn_type *type, void *textLoc, const char *value) {
-    assert(type->type == DYN_TYPE_TEXT);
-    int status = 0;
-    const char *str = strdup(value);
-    char const **loc = textLoc;
-    if (str != NULL) {
-        *loc = str;
-    } else {
-        status = ERROR;
-        LOG_ERROR("Cannot allocate memory for string");
-    }
-    return status;
-}
-
-
-
-
-
-void dynType_print(dyn_type *type, FILE *stream) {
-    if (type != NULL) {
-        dynType_printTypes(type, stream);
-
-        fprintf(stream, "main type:\n");
-        dynType_printAny("root", type, 0, stream);
-    } else {
-        fprintf(stream, "invalid type\n");
-    }
-}
-
-static void dynType_printDepth(int depth, FILE *stream) {
-    int i;
-    for (i = 0; i < depth; i +=1 ) {
-        fprintf(stream, "\t");
-    }
-}
-
-static void dynType_printAny(char *name, dyn_type *type, int depth, FILE *stream) {
-    dyn_type *toPrint = type;
-    if (toPrint->type == DYN_TYPE_REF) {
-        toPrint = toPrint->ref.ref;
-    }
-    switch(toPrint->type) {
-        case DYN_TYPE_COMPLEX :
-            dynType_printComplex(name, toPrint, depth, stream);
-            break;
-        case DYN_TYPE_SIMPLE :
-            dynType_printSimple(name, toPrint, depth, stream);
-            break;
-        case DYN_TYPE_SEQUENCE :
-            dynType_printSequence(name, toPrint, depth, stream);
-            break;
-        case DYN_TYPE_TYPED_POINTER :
-            dynType_printTypedPointer(name, toPrint, depth, stream);
-            break;
-        default :
-            fprintf(stream, "TODO Unsupported type %i\n", toPrint->type);
-            break;
-    }
-}
-
-static void dynType_printComplex(char *name, dyn_type *type, int depth, FILE *stream) {
-    if (type->name == NULL) {
-        dynType_printDepth(depth, stream);
-        fprintf(stream, "%s: complex type (anon), size is %zu, alignment is %i, descriptor is '%c'. fields:\n", name,  type->ffiType->size, type->ffiType->alignment, type->descriptor);
-
-        struct complex_type_entry *entry = NULL;
-        TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-            dynType_printAny(entry->name, entry->type, depth + 1, stream);
-        }
-
-        dynType_printDepth(depth, stream);
-        fprintf(stream, "}\n");
-    } else {
-        dynType_printDepth(depth, stream);
-        fprintf(stream, "%s: complex type ('%s'), size is %zu, alignment is %i, descriptor is '%c'.\n", name, type->name, type->ffiType->size, type->ffiType->alignment, type->descriptor);
-    }
-}
-
-static void dynType_printSequence(char *name, dyn_type *type, int depth, FILE *stream) {
-    dynType_printDepth(depth, stream);
-    fprintf(stream, "sequence, size is %zu, alignment is %i, descriptor is '%c'. fields:\n", type->ffiType->size, type->ffiType->alignment, type->descriptor);
-
-    dynType_printDepth(depth + 1, stream);
-    fprintf(stream, "cap: simple type, size is %zu, alignment is %i.\n", type->sequence.seqType.elements[0]->size, type->sequence.seqType.elements[0]->alignment);
-
-    dynType_printDepth(depth + 1, stream);
-    fprintf(stream, "len: simple type, size is %zu, alignment is %i.\n", type->sequence.seqType.elements[1]->size, type->sequence.seqType.elements[1]->alignment);
-
-    dynType_printDepth(depth + 1, stream);
-    fprintf(stream, "buf: array, size is %zu, alignment is %i. points to ->\n", type->sequence.seqType.elements[2]->size, type->sequence.seqType.elements[2]->alignment);
-    dynType_printAny("element", type->sequence.itemType, depth + 1, stream);
-}
-
-static void dynType_printSimple(char *name, dyn_type *type, int depth, FILE *stream) {
-    dynType_printDepth(depth, stream);
-    fprintf(stream, "%s: simple type, size is %zu, alignment is %i, descriptor is '%c'.\n", name, type->ffiType->size, type->ffiType->alignment, type->descriptor);
-}
-
-static void dynType_printTypedPointer(char *name, dyn_type *type, int depth, FILE *stream) {
-    dynType_printDepth(depth, stream);
-    fprintf(stream, "%s: typed pointer, size is %zu, alignment is %i, points to ->\n", name, type->ffiType->size, type->ffiType->alignment);
-    char *subName = NULL;
-    char buf[128];
-    memset(buf,0,128);
-    if (name != NULL) {
-        snprintf(buf, 128, "*%s", name);
-        subName = buf;
-    }
-    dynType_printAny(subName, type->typedPointer.typedType, depth + 1, stream);
-}
-
-static void dynType_printTypes(dyn_type *type, FILE *stream) {
-
-    dyn_type *parent = type->parent;
-    struct type_entry *pentry = NULL;
-    while (parent != NULL) {
-        TAILQ_FOREACH(pentry, &parent->nestedTypesHead, entries) {
-            if (pentry->type == type) {
-                return;
-            }
-        }
-        parent = parent->parent;
-    }
-
-    struct type_entry *entry = NULL;
-    TAILQ_FOREACH(entry, &type->nestedTypesHead, entries) {
-        dyn_type *toPrint = entry->type;
-        if (toPrint->type == DYN_TYPE_REF) {
-            toPrint = toPrint->ref.ref;
-        }
-
-        switch(toPrint->type) {
-            case DYN_TYPE_COMPLEX :
-                dynType_printComplexType(toPrint, stream);
-                break;
-            case DYN_TYPE_SIMPLE :
-                dynType_printSimpleType(toPrint, stream);
-                break;
-            default :
-                printf("TODO Print Type\n");
-                break;
-        }
-    }
-
-
-    struct complex_type_entry *centry = NULL;
-    switch(type->type) {
-        case DYN_TYPE_COMPLEX :
-            TAILQ_FOREACH(centry, &type->complex.entriesHead, entries) {
-                dynType_printTypes(centry->type, stream);
-            }
-            break;
-        case DYN_TYPE_SEQUENCE :
-            dynType_printTypes(type->sequence.itemType, stream);
-            break;
-        case DYN_TYPE_TYPED_POINTER :
-            dynType_printTypes(type->typedPointer.typedType, stream);
-            break;
-    }
-}
-
-static void dynType_printComplexType(dyn_type *type, FILE *stream) {
-    fprintf(stream, "type '%s': complex type, size is %zu, alignment is %i, descriptor is '%c'. fields:\n", type->name,  type->ffiType->size, type->ffiType->alignment, type->descriptor);
-
-    struct complex_type_entry *entry = NULL;
-    TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
-        dynType_printAny(entry->name, entry->type, 2, stream);
-    }
-
-    fprintf(stream, "}\n");
-}
-
-static void dynType_printSimpleType(dyn_type *type, FILE *stream) {
-    fprintf(stream, "\ttype '%s': simple type, size is %zu, alignment is %i, descriptor is '%c'\n", type->name, type->ffiType->size, type->ffiType->alignment, type->descriptor);
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/src/json_rpc.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/json_rpc.c b/dfi/private/src/json_rpc.c
deleted file mode 100644
index f2b0c56..0000000
--- a/dfi/private/src/json_rpc.c
+++ /dev/null
@@ -1,341 +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 "json_rpc.h"
-#include "json_serializer.h"
-#include "dyn_type.h"
-#include "dyn_interface.h"
-#include <jansson.h>
-#include <assert.h>
-#include <stdint.h>
-#include <string.h>
-#include <ffi.h>
-
-
-static int OK = 0;
-static int ERROR = 1;
-
-DFI_SETUP_LOG(jsonRpc);
-
-typedef void (*gen_func_type)(void);
-
-struct generic_service_layout {
-	void *handle;
-	gen_func_type methods[];
-};
-
-int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, char **out) {
-	int status = OK;
-
-	dyn_type* returnType = NULL;
-
-	LOG_DEBUG("Parsing data: %s\n", request);
-	json_error_t error;
-	json_t *js_request = json_loads(request, 0, &error);
-	json_t *arguments = NULL;
-	const char *sig;
-	if (js_request) {
-		if (json_unpack(js_request, "{s:s}", "m", &sig) != 0) {
-			LOG_ERROR("Got json error '%s'\n", error.text);
-		} else {
-			arguments = json_object_get(js_request, "a");
-		}
-	} else {
-		LOG_ERROR("Got json error '%s' for '%s'\n", error.text, request);
-		return 0;
-	}
-
-	LOG_DEBUG("Looking for method %s\n", sig);
-	struct methods_head *methods = NULL;
-	dynInterface_methods(intf, &methods);
-	struct method_entry *entry = NULL;
-	struct method_entry *method = NULL;
-	TAILQ_FOREACH(entry, methods, entries) {
-		if (strcmp(sig, entry->id) == 0) {
-			method = entry;
-			break;
-		}
-	}
-
-	if (method == NULL) {
-		status = ERROR;
-		LOG_ERROR("Cannot find method with sig '%s'", sig);
-	}
-	else if (status == OK) {
-		LOG_DEBUG("RSA: found method '%s'\n", entry->id);
-		returnType = dynFunction_returnType(method->dynFunc);
-	}
-
-	void (*fp)(void) = NULL;
-	void *handle = NULL;
-	if (status == OK) {
-		struct generic_service_layout *serv = service;
-		handle = serv->handle;
-		fp = serv->methods[method->index];
-	}
-
-	dyn_function_type *func = NULL;
-	int nrOfArgs = 0;
-	if (status == OK) {
-		nrOfArgs = dynFunction_nrOfArguments(entry->dynFunc);
-		func = entry->dynFunc;
-	}
-
-	void *args[nrOfArgs];
-
-	json_t *value = NULL;
-
-	int i;
-	int index = 0;
-
-	void *ptr = NULL;
-	void *ptrToPtr = &ptr;
-
-	for (i = 0; i < nrOfArgs; i += 1) {
-		dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
-			value = json_array_get(arguments, index++);
-			status = jsonSerializer_deserializeJson(argType, value, &(args[i]));
-		} else if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
-			dynType_alloc(argType, &args[i]);
-		} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-			args[i] = &ptrToPtr;
-		} else if (meta == DYN_FUNCTION_ARGUMENT_META__HANDLE) {
-			args[i] = &handle;
-		}
-
-		if (status != OK) {
-			break;
-		}
-	}
-	json_decref(js_request);
-
-	if (status == OK) {
-		if (dynType_descriptorType(returnType) != 'N') {
-			//NOTE To be able to handle exception only N as returnType is supported
-			LOG_ERROR("Only interface methods with a native int are supported. Found type '%c'", (char)dynType_descriptorType(returnType));
-			status = ERROR;
-		}
-	}
-
-	ffi_sarg returnVal = 1;
-
-	if (status == OK) {
-		status = dynFunction_call(func, fp, (void *) &returnVal, args);
-	}
-
-	int funcCallStatus = (int)returnVal;
-	if (funcCallStatus != 0) {
-		LOG_WARNING("Error calling remote endpoint function, got error code %i", funcCallStatus);
-	}
-
-	json_t *jsonResult = NULL;
-	for(i = 0; i < nrOfArgs; i += 1) {
-		dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
-			dynType_free(argType, args[i]);
-		}
-	}
-
-	if (funcCallStatus == 0 && status == OK) {
-		for (i = 0; i < nrOfArgs; i += 1) {
-			dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-			enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-			if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
-				if (status == OK) {
-					status = jsonSerializer_serializeJson(argType, args[i], &jsonResult);
-				}
-				dynType_free(argType, args[i]);
-			} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-				if (ptr != NULL) {
-					dyn_type *typedType = NULL;
-					if (status == OK) {
-						status = dynType_typedPointer_getTypedType(argType, &typedType);
-					}
-					if (dynType_descriptorType(typedType) == 't') {
-						status = jsonSerializer_serializeJson(typedType, (void*) &ptr, &jsonResult);
-						free(ptr);
-					} else {
-						dyn_type *typedTypedType = NULL;
-						if (status == OK) {
-							status = dynType_typedPointer_getTypedType(typedType, &typedTypedType);
-						}
-
-						if(status == OK){
-							status = jsonSerializer_serializeJson(typedTypedType, ptr, &jsonResult);
-						}
-
-						if (status == OK) {
-							dynType_free(typedTypedType, ptr);
-						}
-					}
-
-				} else {
-					LOG_DEBUG("Output ptr is null");
-				}
-			}
-
-			if (status != OK) {
-				break;
-			}
-		}
-	}
-
-	char *response = NULL;
-	if (status == OK) {
-		LOG_DEBUG("creating payload\n");
-		json_t *payload = json_object();
-		if (funcCallStatus == 0) {
-			if (jsonResult == NULL) {
-				//ignore -> no result
-			} else {
-				LOG_DEBUG("Setting result payload");
-				json_object_set_new(payload, "r", jsonResult);
-			}
-		} else {
-			LOG_DEBUG("Setting error payload");
-			json_object_set_new(payload, "e", json_integer(funcCallStatus));
-		}
-		response = json_dumps(payload, JSON_DECODE_ANY);
-		json_decref(payload);
-		LOG_DEBUG("status ptr is %p. response is '%s'\n", status, response);
-	}
-
-	if (status == OK) {
-		*out = response;
-	} else {
-		free(response);
-	}
-
-	return status;
-}
-
-int jsonRpc_prepareInvokeRequest(dyn_function_type *func, const char *id, void *args[], char **out) {
-	int status = OK;
-
-
-	LOG_DEBUG("Calling remote function '%s'\n", id);
-	json_t *invoke = json_object();
-	json_object_set_new(invoke, "m", json_string(id));
-
-	json_t *arguments = json_array();
-	json_object_set_new(invoke, "a", arguments);
-
-	int i;
-	int nrOfArgs = dynFunction_nrOfArguments(func);
-	for (i = 0; i < nrOfArgs; i +=1) {
-		dyn_type *type = dynFunction_argumentTypeForIndex(func, i);
-		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
-			json_t *val = NULL;
-
-			int rc = jsonSerializer_serializeJson(type, args[i], &val);
-			if (rc == 0) {
-				json_array_append_new(arguments, val);
-			} else {
-				status = ERROR;
-				break;
-			}
-		} else {
-			//skip handle / output types
-		}
-	}
-
-	char *invokeStr = json_dumps(invoke, JSON_DECODE_ANY);
-	json_decref(invoke);
-
-	if (status == OK) {
-		*out = invokeStr;
-	}
-
-	return status;
-}
-
-int jsonRpc_handleReply(dyn_function_type *func, const char *reply, void *args[]) {
-	int status = OK;
-
-	json_error_t error;
-	json_t *replyJson = json_loads(reply, JSON_DECODE_ANY, &error);
-	if (replyJson == NULL) {
-		status = ERROR;
-		LOG_ERROR("Error parsing json '%s', got error '%s'", reply, error.text);
-	}
-
-	json_t *result = NULL;
-	if (status == OK) {
-		result = json_object_get(replyJson, "r"); //TODO check
-		if (result == NULL) {
-			status = ERROR;
-			LOG_ERROR("Cannot find r entry in json reply '%s'", reply);
-		}
-	}
-
-	if (status == OK) {
-		int nrOfArgs = dynFunction_nrOfArguments(func);
-		int i;
-		for (i = 0; i < nrOfArgs; i += 1) {
-			dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-			enum dyn_function_argument_meta meta = dynFunction_argumentMetaForIndex(func, i);
-			if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
-				void *tmp = NULL;
-				void **out = (void **) args[i];
-
-				size_t size = 0;
-
-				if (dynType_descriptorType(argType) == 't') {
-					status = jsonSerializer_deserializeJson(argType, result, &tmp);
-					if(tmp!=NULL){
-						size = strnlen(((char *) *(char**) tmp), 1024 * 1024);
-						memcpy(*out, *(void**) tmp, size);
-					}
-				} else {
-					dynType_typedPointer_getTypedType(argType, &argType);
-					status = jsonSerializer_deserializeJson(argType, result, &tmp);
-					if(tmp!=NULL){
-						size = dynType_size(argType);
-						memcpy(*out, tmp, size);
-					}
-				}
-
-				dynType_free(argType, tmp);
-			} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-				dyn_type *subType = NULL;
-
-				dynType_typedPointer_getTypedType(argType, &subType);
-
-				if (dynType_descriptorType(subType) == 't') {
-					void ***out = (void ***) args[i];
-					status = jsonSerializer_deserializeJson(subType, result, *out);
-				} else {
-					dyn_type *subSubType = NULL;
-					dynType_typedPointer_getTypedType(subType, &subSubType);
-					void ***out = (void ***) args[i];
-					status = jsonSerializer_deserializeJson(subSubType, result, *out);
-				}
-			} else {
-				//skip
-			}
-		}
-	}
-
-	json_decref(replyJson);
-
-	return status;
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/src/json_serializer.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/json_serializer.c b/dfi/private/src/json_serializer.c
deleted file mode 100644
index 4b78aeb..0000000
--- a/dfi/private/src/json_serializer.c
+++ /dev/null
@@ -1,484 +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 "json_serializer.h"
-#include "dyn_type.h"
-#include "dyn_interface.h"
-
-#include <jansson.h>
-#include <assert.h>
-#include <stdint.h>
-#include <string.h>
-
-static int jsonSerializer_createType(dyn_type *type, json_t *object, void **result);
-static int jsonSerializer_parseObject(dyn_type *type, json_t *object, void *inst);
-static int jsonSerializer_parseObjectMember(dyn_type *type, const char *name, json_t *val, void *inst);
-static int jsonSerializer_parseSequence(dyn_type *seq, json_t *array, void *seqLoc);
-static int jsonSerializer_parseAny(dyn_type *type, void *input, json_t *val);
-
-static int jsonSerializer_writeAny(dyn_type *type, void *input, json_t **val);
-
-static int jsonSerializer_writeComplex(dyn_type *type, void *input, json_t **val);
-
-static int jsonSerializer_writeSequence(dyn_type *type, void *input, json_t **out);
-
-static int OK = 0;
-static int ERROR = 1;
-
-DFI_SETUP_LOG(jsonSerializer);
-
-int jsonSerializer_deserialize(dyn_type *type, const char *input, void **result) {
-    assert(dynType_type(type) == DYN_TYPE_COMPLEX || dynType_type(type) == DYN_TYPE_SEQUENCE);
-    int status = 0;
-
-    json_error_t error;
-    json_t *root = json_loads(input, JSON_DECODE_ANY, &error);
-
-    if (root != NULL) {
-        status = jsonSerializer_deserializeJson(type, root, result);
-        json_decref(root);
-    } else {
-        status = ERROR;
-        LOG_ERROR("Error parsing json input '%s'. Error is: %s\n", input, error.text);
-    }
-
-    if (status != OK) {
-        LOG_ERROR("Error cannot deserialize json. Input is '%s'\n", input);
-    }
-    return status;
-}
-
-int jsonSerializer_deserializeJson(dyn_type *type, json_t *input, void **out) {
-    return jsonSerializer_createType(type, input, out);
-}
-
-static int jsonSerializer_createType(dyn_type *type, json_t *val, void **result) {
-    assert(val != NULL);
-    int status = OK;
-    void *inst = NULL;
-
-    if (dynType_descriptorType(type) == 't') {
-        if (json_typeof(val) == JSON_STRING) {
-            inst = strdup(json_string_value(val));
-        } else {
-            status = ERROR;
-            LOG_ERROR("Expected json_string type got %i\n", json_typeof(val));
-        }
-    } else {
-        status = dynType_alloc(type, &inst);
-
-        if (status == OK) {
-            assert(inst != NULL);
-            status = jsonSerializer_parseAny(type, inst, val);
-        }
-    }
-
-    if (status == OK) {
-        *result = inst;
-    }
-    else{
-    	dynType_free(type, inst);
-    }
-
-    return status;
-}
-
-static int jsonSerializer_parseObject(dyn_type *type, json_t *object, void *inst) {
-    assert(object != NULL);
-    int status = 0;
-    json_t *value;
-    const char *key;
-
-    json_object_foreach(object, key, value) {
-        status = jsonSerializer_parseObjectMember(type, key, value, inst);
-        if (status != OK) {
-            break;
-        }
-    }
-
-    return status;
-}
-
-static int jsonSerializer_parseObjectMember(dyn_type *type, const char *name, json_t *val, void *inst) {
-    int status = OK;
-    void *valp = NULL;
-    dyn_type *valType = NULL;
-
-    int index = dynType_complex_indexForName(type, name);
-    if (index < 0) {
-        LOG_ERROR("Cannot find index for member '%s'", name);
-        status = ERROR;
-    }
-
-    if (status == OK) {
-        status = dynType_complex_valLocAt(type, index, inst, &valp);
-    }
-
-    if (status == OK ) {
-        status = dynType_complex_dynTypeAt(type, index, &valType);
-    }
-
-    if (status == OK) {
-        status = jsonSerializer_parseAny(valType, valp, val);
-    }
-
-    return status;
-}
-
-static int jsonSerializer_parseAny(dyn_type *type, void *loc, json_t *val) {
-    int status = OK;
-
-    dyn_type *subType = NULL;
-    char c = dynType_descriptorType(type);
-
-    /*
-    printf("parseAny with descriptor '%c' :", c);
-    json_dumpf(val, stdout, 0); //TODO remove
-    printf("\n");
-     */
-
-    bool *z;            //Z
-    float *f;           //F
-    double *d;          //D
-    char *b;            //B
-    int *n;             //N
-    int16_t *s;         //S
-    int32_t *i;         //I
-    int64_t *l;         //J
-    uint8_t   *ub;      //b
-    uint16_t  *us;      //s
-    uint32_t  *ui;      //i
-    uint64_t  *ul;      //j
-
-    switch (c) {
-        case 'Z' :
-            z = loc;
-            *z = (bool) json_is_true(val);
-            break;
-        case 'F' :
-            f = loc;
-            *f = (float) json_real_value(val);
-            break;
-        case 'D' :
-            d = loc;
-            *d = json_real_value(val);
-            break;
-        case 'N' :
-            n = loc;
-            *n = (int) json_integer_value(val);
-            break;
-        case 'B' :
-            b = loc;
-            *b = (char) json_integer_value(val);
-            break;
-        case 'S' :
-            s = loc;
-            *s = (int16_t) json_integer_value(val);
-            break;
-        case 'I' :
-            i = loc;
-            *i = (int32_t) json_integer_value(val);
-            break;
-        case 'J' :
-            l = loc;
-            *l = (int64_t) json_integer_value(val);
-            break;
-        case 'b' :
-            ub = loc;
-            *ub = (uint8_t) json_integer_value(val);
-            break;
-        case 's' :
-            us = loc;
-            *us = (uint16_t) json_integer_value(val);
-            break;
-        case 'i' :
-            ui = loc;
-            *ui = (uint32_t) json_integer_value(val);
-            break;
-        case 'j' :
-            ul = loc;
-            *ul = (uint64_t) json_integer_value(val);
-            break;
-        case 't' :
-            if (json_is_string(val)) {
-                dynType_text_allocAndInit(type, loc, json_string_value(val));
-            } else {
-                status = ERROR;
-                LOG_ERROR("Expected json string type got %i", json_typeof(val));
-            }
-            break;
-        case '[' :
-            if (json_is_array(val)) {
-                status = jsonSerializer_parseSequence(type, val, loc);
-            } else {
-                status = ERROR;
-                LOG_ERROR("Expected json array type got '%i'", json_typeof(val));
-            }
-            break;
-        case '{' :
-            if (status == OK) {
-                status = jsonSerializer_parseObject(type, val, loc);
-            }
-            break;
-        case '*' :
-            status = dynType_typedPointer_getTypedType(type, &subType);
-            if (status == OK) {
-                status = jsonSerializer_createType(subType, val, (void **) loc);
-            }
-            break;
-        case 'P' :
-            status = ERROR;
-            LOG_WARNING("Untyped pointer are not supported for serialization");
-            break;
-        default :
-            status = ERROR;
-            LOG_ERROR("Error provided type '%c' not supported for JSON\n", dynType_descriptorType(type));
-            break;
-    }
-
-    return status;
-}
-
-static int jsonSerializer_parseSequence(dyn_type *seq, json_t *array, void *seqLoc) {
-    assert(dynType_type(seq) == DYN_TYPE_SEQUENCE);
-    int status = OK;
-
-    size_t size = json_array_size(array);
-    //LOG_DEBUG("Allocating sequence with capacity %zu", size);
-    status = dynType_sequence_alloc(seq, seqLoc, (int) size);
-
-    if (status == OK) {
-        dyn_type *itemType = dynType_sequence_itemType(seq);
-        size_t index;
-        json_t *val;
-        json_array_foreach(array, index, val) {
-            void *valLoc = NULL;
-            status = dynType_sequence_increaseLengthAndReturnLastLoc(seq, seqLoc, &valLoc);
-            //LOG_DEBUG("Got sequence loc %p for index %zu", valLoc, index);
-
-            if (status == OK) {
-                status = jsonSerializer_parseAny(itemType, valLoc, val);
-                if (status != OK) {
-                    break;
-                }
-            }
-        }
-    }
-
-    return status;
-}
-
-int jsonSerializer_serialize(dyn_type *type, const void* input, char **output) {
-    int status = OK;
-
-    json_t *root = NULL;
-    status = jsonSerializer_serializeJson(type, input, &root);
-
-    if (status == OK) {
-        *output = json_dumps(root, JSON_COMPACT);
-        json_decref(root);
-    }
-
-    return status;
-}
-
-int jsonSerializer_serializeJson(dyn_type *type, const void* input, json_t **out) {
-    return jsonSerializer_writeAny(type, (void*)input /*TODO update static function to take const void**/, out);
-}
-
-static int jsonSerializer_writeAny(dyn_type *type, void* input, json_t **out) {
-    int status = OK;
-
-    int descriptor = dynType_descriptorType(type);
-    json_t *val = NULL;
-    dyn_type *subType = NULL;
-
-    bool *z;            //Z
-    float *f;           //F
-    double *d;          //D
-    char *b;            //B
-    int *n;             //N
-    int16_t *s;         //S
-    int32_t *i;         //I
-    int64_t *l;         //J
-    uint8_t   *ub;      //b
-    uint16_t  *us;      //s
-    uint32_t  *ui;      //i
-    uint64_t  *ul;      //j
-
-    switch (descriptor) {
-        case 'Z' :
-            z = input;
-            val = json_boolean((bool)*z);
-            break;
-        case 'B' :
-            b = input;
-            val = json_integer((json_int_t)*b);
-            break;
-        case 'S' :
-            s = input;
-            val = json_integer((json_int_t)*s);
-            break;
-        case 'I' :
-            i = input;
-            val = json_integer((json_int_t)*i);
-            break;
-        case 'J' :
-            l = input;
-            val = json_integer((json_int_t)*l);
-            break;
-        case 'b' :
-            ub = input;
-            val = json_integer((json_int_t)*ub);
-            break;
-        case 's' :
-            us = input;
-            val = json_integer((json_int_t)*us);
-            break;
-        case 'i' :
-            ui = input;
-            val = json_integer((json_int_t)*ui);
-            break;
-        case 'j' :
-            ul = input;
-            val = json_integer((json_int_t)*ul);
-            break;
-        case 'N' :
-            n = input;
-            val = json_integer((json_int_t)*n);
-            break;
-        case 'F' :
-            f = input;
-            val = json_real((double) *f);
-            break;
-        case 'D' :
-            d = input;
-            val = json_real(*d);
-            break;
-        case 't' :
-            val = json_string(*(const char **) input);
-            break;
-        case '*' :
-            status = dynType_typedPointer_getTypedType(type, &subType);
-            if (status == OK) {
-                status = jsonSerializer_writeAny(subType, *(void **)input, &val);
-            }
-            break;
-        case '{' :
-            status = jsonSerializer_writeComplex(type, input, &val);
-            break;
-        case '[' :
-            status = jsonSerializer_writeSequence(type, input, &val);
-            break;
-        case 'P' :
-            LOG_WARNING("Untyped pointer not supported for serialization. ignoring");
-            break;
-        default :
-            LOG_ERROR("Unsupported descriptor '%c'", descriptor);
-            status = ERROR;
-            break;
-    }
-
-    if (status == OK && val != NULL) {
-        *out = val;
-    }
-
-    return status;
-}
-
-static int jsonSerializer_writeSequence(dyn_type *type, void *input, json_t **out) {
-    assert(dynType_type(type) == DYN_TYPE_SEQUENCE);
-    int status = OK;
-
-    json_t *array = json_array();
-    dyn_type *itemType = dynType_sequence_itemType(type);
-    uint32_t len = dynType_sequence_length(input);
-
-    int i = 0;
-    void *itemLoc = NULL;
-    json_t *item = NULL;
-    for (i = 0; i < len; i += 1) {
-        item = NULL;
-        status = dynType_sequence_locForIndex(type, input, i, &itemLoc);
-        if (status == OK) {
-            status = jsonSerializer_writeAny(itemType, itemLoc, &item);
-            if (status == OK) {
-                json_array_append(array, item);
-                json_decref(item);
-            }
-        }
-
-        if (status != OK) {
-            break;
-        }
-    }
-
-    if (status == OK && array != NULL) {
-        *out = array;
-    }
-
-    return status;
-}
-
-static int jsonSerializer_writeComplex(dyn_type *type, void *input, json_t **out) {
-    assert(dynType_type(type) == DYN_TYPE_COMPLEX);
-    int status = OK;
-
-    json_t *val = json_object();
-    struct complex_type_entry *entry = NULL;
-    struct complex_type_entries_head *entries = NULL;
-    int index = -1;
-
-    status = dynType_complex_entries(type, &entries);
-    if (status == OK) {
-        TAILQ_FOREACH(entry, entries, entries) {
-            void *subLoc = NULL;
-            json_t *subVal = NULL;
-            dyn_type *subType = NULL;
-            index = dynType_complex_indexForName(type, entry->name);
-            if (index < 0) {
-		LOG_ERROR("Cannot find index for member '%s'", entry->name);
-                status = ERROR;
-            }
-            if(status == OK){
-		status = dynType_complex_valLocAt(type, index, input, &subLoc);
-            }
-            if (status == OK) {
-                status = dynType_complex_dynTypeAt(type, index, &subType);
-            }
-            if (status == OK) {
-                status = jsonSerializer_writeAny(subType, subLoc, &subVal);
-            }
-            if (status == OK) {
-                json_object_set(val, entry->name, subVal);
-                json_decref(subVal);
-            }
-
-            if (status != OK) {
-                break;
-            }
-        }
-    }
-
-    if (status == OK && val != NULL) {
-        *out = val;
-    }
-
-    return status;
-}
-

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/avro_descriptor_translator_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/avro_descriptor_translator_tests.cpp b/dfi/private/test/avro_descriptor_translator_tests.cpp
deleted file mode 100644
index 5bab518..0000000
--- a/dfi/private/test/avro_descriptor_translator_tests.cpp
+++ /dev/null
@@ -1,180 +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 <CppUTest/TestHarness.h>
-#include "CppUTest/CommandLineTestRunner.h"                                                                                                                                                                        
-
-extern "C" {
-
-#include <stdio.h>
-#include <assert.h>
-#include <string.h>
-
-#include "dyn_common.h"
-#include "descriptor_translator.h"
-
-#if defined(BSD) || defined(__APPLE__) 
-#include "open_memstream.h"
-#include "fmemopen.h"
-#endif
-
-    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");
-        va_end(ap);
-    }
-
-
-    static char *readSchema(const char *file) {
-        size_t size = 0;
-        char *ptr = NULL;
-
-        FILE *schema = fopen(file, "r");
-        FILE *stream = open_memstream(&ptr, &size);
-
-        assert(schema != NULL);
-        assert(stream != NULL);
-
-        int c = fgetc(schema);
-        while (c != EOF ) {
-            fputc(c, stream);
-            c = fgetc(schema);
-        }
-        fclose(schema);
-        fclose(stream);
-
-        assert(ptr != NULL);
-        return ptr;
-    }
-
-    static dyn_interface_type *createInterfaceInfo(const char *schemaFile) {
-        char *schema = readSchema(schemaFile);
-        dyn_interface_type *ift= NULL;
-
-        int status = descriptorTranslator_translate(schema, &ift);
-        CHECK_EQUAL(0, status);
-
-        free(schema);
-        return ift;
-    }
-
-    static int countMethodInfos(dyn_interface_type *info) {
-        int count = 0;
-        method_info_type *mInfo = NULL;
-        TAILQ_FOREACH(mInfo, &info->methodInfos, entries) {
-            count +=1;
-        }
-        return count;
-    }
-
-    static int countTypeInfos(dyn_interface_type *info) {
-        int count = 0;
-        type_info_type *tInfo = NULL;
-        TAILQ_FOREACH(tInfo, &info->typeInfos, entries) {
-            count +=1;
-        }
-        return count;
-    }
-
-    static void simple(void) {
-        //first argument void *handle, last argument output pointer for result and return int with status for exception handling
-        //sum(DD)D -> sum(PDD*D)N 
-        //sub(DD)D -> sub(PDD*D)N
-        //sqrt(D)D -> sqrt(PD*D)N
-
-        dyn_interface_type *intf = createInterfaceInfo("schemas/simple.avpr");
-
-        int count = countMethodInfos(intf);
-        CHECK_EQUAL(3, count);
-
-        count = countTypeInfos(intf);
-        CHECK_EQUAL(0, count);
-
-        method_info_type *mInfo = NULL;
-        TAILQ_FOREACH(mInfo, &intf->methodInfos, entries) {
-            if (strcmp("sum", mInfo->name) == 0) {
-                STRCMP_EQUAL("sum(PDD*D)N", mInfo->descriptor);
-            } else if (strcmp("add", mInfo->name) == 0) {
-                STRCMP_EQUAL("add(PDD*D)N", mInfo->descriptor);
-            } else if (strcmp("sqrt", mInfo->name) == 0) {
-                STRCMP_EQUAL("sqrt(PD*D)N", mInfo->descriptor);
-            }
-        }
-
-        dynInterface_destroy(intf);
-    }
-
-    static void complex(void) {
-        dyn_interface_type *intf = createInterfaceInfo("schemas/complex.avpr");
-
-        int count = countMethodInfos(intf);
-        CHECK_EQUAL(1, count);
-
-        method_info_type *mInfo = TAILQ_FIRST(&intf->methodInfos);
-        STRCMP_EQUAL("stats", mInfo->name);
-        STRCMP_EQUAL("stats(P[D*LStatResult;)N", mInfo->descriptor);
-
-        count = countTypeInfos(intf);
-        CHECK_EQUAL(1, count);
-
-        type_info_type *tInfo = TAILQ_FIRST(&intf->typeInfos);
-        STRCMP_EQUAL("StatResult", tInfo->name);
-        STRCMP_EQUAL("{DDD[D sum min max input}", tInfo->descriptor);
-
-        dynInterface_destroy(intf);
-    }
-
-    static void invalid(const char *file) {
-        char *schema = readSchema(file);
-        dyn_interface_type *ift= NULL;
-
-        int status = descriptorTranslator_translate(schema, &ift);
-        CHECK(status != 0);
-        
-        free(schema);
-    }
-}
-
-TEST_GROUP(AvroDescTranslatorTest) {
-    void setup() {
-        descriptorTranslator_logSetup(stdLog, NULL, 3);
-        dynInterface_logSetup(stdLog, NULL, 3);
-        dynType_logSetup(stdLog, NULL, 3);
-        dynCommon_logSetup(stdLog, NULL, 3);
-    }
-};
-
-TEST(AvroDescTranslatorTest, simple) {
-    simple();
-}
-
-TEST(AvroDescTranslatorTest, complex) {
-    complex();
-}
-
-TEST(AvroDescTranslatorTest, invalid1) {
-    invalid("schemas/invalid1.avpr");
-}
-
-TEST(AvroDescTranslatorTest, invalid2) {
-    invalid("schemas/invalid2.avpr");
-}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/example1.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/example1.descriptor b/dfi/private/test/descriptors/example1.descriptor
deleted file mode 100644
index 771dc5e..0000000
--- a/dfi/private/test/descriptors/example1.descriptor
+++ /dev/null
@@ -1,13 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:types
-StatsResult={DDD[D average min max input}
-:methods
-add(DD)D=add(#am=handle;PDD#am=pre;*D)N
-sub(DD)D=sub(#am=handle;PDD*#am=pre;D)N
-sqrt(D)D=sqrt(#am=handle;PD*#am=pre;D)N
-stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/example2.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/example2.descriptor b/dfi/private/test/descriptors/example2.descriptor
deleted file mode 100644
index 38bf442..0000000
--- a/dfi/private/test/descriptors/example2.descriptor
+++ /dev/null
@@ -1,9 +0,0 @@
-:header
-type=interface
-name=example
-version=1.0.0
-:annotations
-:types
-item={DD a b}
-:methods
-example1=items(#am=handle;P#am=out;**[Litem;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/example3.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/example3.descriptor b/dfi/private/test/descriptors/example3.descriptor
deleted file mode 100644
index c89d969..0000000
--- a/dfi/private/test/descriptors/example3.descriptor
+++ /dev/null
@@ -1,11 +0,0 @@
-:header
-type=interface
-name=detection_provider
-version=1.0.0
-:annotations
-:types
-location={DD lat lon}
-target={Jllocation;DDJ id location speed heading lastUpdated}
-detection={Jllocation;Dltarget; id center range simulated}
-:methods
-getDetections()Ljava/util/List;=getDetections(#am=handle;P#am=out;**[Ldetection;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/example4.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/example4.descriptor b/dfi/private/test/descriptors/example4.descriptor
deleted file mode 100644
index 4c959c4..0000000
--- a/dfi/private/test/descriptors/example4.descriptor
+++ /dev/null
@@ -1,8 +0,0 @@
-:header
-type=interface
-name=example4
-version=1.0.0
-:annotations
-:types
-:methods
-getName(V)t=getName(#am=handle;P#am=out;*t)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalid.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalid.descriptor b/dfi/private/test/descriptors/invalids/invalid.descriptor
deleted file mode 100644
index fead964..0000000
--- a/dfi/private/test/descriptors/invalids/invalid.descriptor
+++ /dev/null
@@ -1,13 +0,0 @@
-:header
-type=interface
-name=calculator X
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:types
-StatsResult={DDD[D average min max input}
-:methods
-add(DD)D=add(#am=handle;PDD#am=pre;*D)N
-sub(DD)D=sub(#am=handle;PDD*#am=pre;D)N
-sqrt(D)D=sqrt(#am=handle;PD*#am=pre;D)N
-stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMetaType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMetaType.descriptor b/dfi/private/test/descriptors/invalids/invalidMetaType.descriptor
deleted file mode 100644
index 2d17c47..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMetaType.descriptor
+++ /dev/null
@@ -1,8 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:methods
-add(DD)D=add(#am=invalid;PDD#am=pre;*D)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMethod.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMethod.descriptor b/dfi/private/test/descriptors/invalids/invalidMethod.descriptor
deleted file mode 100644
index eaef7b1..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMethod.descriptor
+++ /dev/null
@@ -1,8 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:methods
-add(DD)D=add(#am=handle;PDD#am=pre;*D)N X

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMethodReturnType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMethodReturnType.descriptor b/dfi/private/test/descriptors/invalids/invalidMethodReturnType.descriptor
deleted file mode 100644
index 26f75f8..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMethodReturnType.descriptor
+++ /dev/null
@@ -1,8 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:methods
-add(DD)D=add(#am=handle;PDD#am=pre;*D)D

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgHdr.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgHdr.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgHdr.descriptor
deleted file mode 100644
index ae9b131..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgHdr.descriptor
+++ /dev/null
@@ -1,9 +0,0 @@
-:header
-type=message
-name=poi
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgInvalidName.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgInvalidName.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgInvalidName.descriptor
deleted file mode 100644
index 787dd4c..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgInvalidName.descriptor
+++ /dev/null
@@ -1,9 +0,0 @@
-:header
-type=message
-name=poi X
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgInvalidSection.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgInvalidSection.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgInvalidSection.descriptor
deleted file mode 100644
index 02a593c..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgInvalidSection.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=message
-name=poi
-version=1.0.0
-:invalid
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgInvalidType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgInvalidType.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgInvalidType.descriptor
deleted file mode 100644
index 5008311..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgInvalidType.descriptor
+++ /dev/null
@@ -1,9 +0,0 @@
-:header
-type=message
-name=poi
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long} X
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor
deleted file mode 100644
index 6cffbdc..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgInvalidVersion.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=message
-name=poi
-version=1.0.f
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidMsgMissingVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidMsgMissingVersion.descriptor b/dfi/private/test/descriptors/invalids/invalidMsgMissingVersion.descriptor
deleted file mode 100644
index 1fd3595..0000000
--- a/dfi/private/test/descriptors/invalids/invalidMsgMissingVersion.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:head
-type=message
-name=poi
-version=1.0.0
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidSection.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidSection.descriptor b/dfi/private/test/descriptors/invalids/invalidSection.descriptor
deleted file mode 100644
index b8a11a6..0000000
--- a/dfi/private/test/descriptors/invalids/invalidSection.descriptor
+++ /dev/null
@@ -1,6 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:invalidSection
-invalidKey=invalidValue
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidType.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidType.descriptor b/dfi/private/test/descriptors/invalids/invalidType.descriptor
deleted file mode 100644
index 7b7ce1c..0000000
--- a/dfi/private/test/descriptors/invalids/invalidType.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=interface
-name=calculator
-version=1.0.0
-:annotations
-classname=org.example.Calculator
-:types
-StatsResult={DDD[D average min max input} X
-:methods
-stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/invalidVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/invalidVersion.descriptor b/dfi/private/test/descriptors/invalids/invalidVersion.descriptor
deleted file mode 100644
index bfe4d38..0000000
--- a/dfi/private/test/descriptors/invalids/invalidVersion.descriptor
+++ /dev/null
@@ -1,9 +0,0 @@
-:header
-type=interface
-name=example
-version=q.0.0
-:annotations
-:types
-item={DD a b}
-:methods
-example1=items(#am=handle;P#am=out;**[Litem;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/invalids/noVersion.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/invalids/noVersion.descriptor b/dfi/private/test/descriptors/invalids/noVersion.descriptor
deleted file mode 100644
index 731a9e6..0000000
--- a/dfi/private/test/descriptors/invalids/noVersion.descriptor
+++ /dev/null
@@ -1,12 +0,0 @@
-:header
-type=interface
-name=calculator
-:annotations
-classname=org.example.Calculator
-:types
-StatsResult={DDD[D average min max input}
-:methods
-add(DD)D=add(#am=handle;PDD#am=pre;*D)N
-sub(DD)D=sub(#am=handle;PDD*#am=pre;D)N
-sqrt(D)D=sqrt(#am=handle;PD*#am=pre;D)N
-stats([D)LStatsResult;=stats(#am=handle;P[D#am=out;*LStatsResult;)N

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/msg_example1.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/msg_example1.descriptor b/dfi/private/test/descriptors/msg_example1.descriptor
deleted file mode 100644
index 576523a..0000000
--- a/dfi/private/test/descriptors/msg_example1.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=message
-name=poi
-version=1.0.0
-:annotations
-classname=org.example.PointOfInterest
-:types
-location={DD lat long}
-:message
-{llocation;tt location name description}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/msg_example2.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/msg_example2.descriptor b/dfi/private/test/descriptors/msg_example2.descriptor
deleted file mode 100644
index 128049d..0000000
--- a/dfi/private/test/descriptors/msg_example2.descriptor
+++ /dev/null
@@ -1,12 +0,0 @@
-:header
-type=message
-name=track
-version=0.0.1
-:annotations
-classname=org.example.Track
-:types
-timestamp={SSSSSSI day month year hour minute second microseconds}
-latlonpos={DD lat lon}
-polarpos={DDD azimuth elevation range}
-:message
-{Iltimestamp;llatlonpos;lpolarpos;SS trackid lastupdate abspos relpos classification identity}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/msg_example3.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/msg_example3.descriptor b/dfi/private/test/descriptors/msg_example3.descriptor
deleted file mode 100644
index 7b69380..0000000
--- a/dfi/private/test/descriptors/msg_example3.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=message
-name=logEntry
-version=1.0.0
-:annotations
-classname=org.example.LogEntry
-:types
-timestamp={SSSSSSI day month year hour minute second microseconds}
-:message
-{ltimestamp;St timestamp severity eventdescription}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/descriptors/msg_example4.descriptor
----------------------------------------------------------------------
diff --git a/dfi/private/test/descriptors/msg_example4.descriptor b/dfi/private/test/descriptors/msg_example4.descriptor
deleted file mode 100644
index e99e443..0000000
--- a/dfi/private/test/descriptors/msg_example4.descriptor
+++ /dev/null
@@ -1,10 +0,0 @@
-:header
-type=message
-name=exmpl4
-version=1.1.0
-:annotations
-:types
-info={Jladditional_info; id info}
-additional_info={Jt; id descr}
-:message
-{Jlinfo; id info}

http://git-wip-us.apache.org/repos/asf/celix/blob/a1c30887/dfi/private/test/dyn_closure_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_closure_tests.cpp b/dfi/private/test/dyn_closure_tests.cpp
deleted file mode 100644
index 9c1abe6..0000000
--- a/dfi/private/test/dyn_closure_tests.cpp
+++ /dev/null
@@ -1,162 +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 <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 "dyn_common.h"
-#include "dyn_function.h"
-
-static int g_count;
-
-static void stdLog(void*, 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");
-    va_end(ap);
-}
-
-#define EXAMPLE1_DESCRIPTOR "example(III)I"
-static void example1_binding(void*, void* args[], void *out) {
-    int32_t a = *((int32_t *)args[0]);
-    int32_t b = *((int32_t *)args[1]);
-    int32_t c = *((int32_t *)args[2]);
-    int32_t *ret = (int32_t *)out;
-    *ret = a + b + c;
-    g_count += 1;
-}
-
-#define EXAMPLE2_DESCRIPTOR "example(I{DDD val1 val2 val3}I)D"
-struct example2_arg2 {
-    double val1;
-    double val2;
-    double val3;
-};
-void example2_binding(void*, void* args[], void *out) {
-    int32_t a = *((int32_t *)args[0]);
-    struct example2_arg2 b =  *((struct example2_arg2 *)args[1]);
-    int32_t c = *((int32_t *)args[2]);
-    double *ret = (double *)out;
-    *ret = a + b.val1 + b.val2 + b.val3 + c;
-    g_count += 1;
-}
-
-
-#define EXAMPLE3_DESCRIPTOR "example(III){III sum max min}"
-struct example3_ret {
-    int32_t sum;
-    int32_t max;
-    int32_t min;
-};
-
-static void example3_binding(void*, void* args[], void *out) {
-    int32_t a = *((int32_t *)args[0]);
-    int32_t b = *((int32_t *)args[1]);
-    int32_t c = *((int32_t *)args[2]);
-    struct example3_ret *result = (struct example3_ret *)calloc(1,sizeof(struct example3_ret));
-    result->sum = a + b + c;
-    result->min = a <= b ? a : b;
-    result->max = a >= b ? a : b;
-    result->min = result->min <= c ? result->min : c;
-    result->max = result->max >= c ? result->max : c;
-
-    struct example3_ret **ret = (struct example3_ret **)out;
-    (*ret) = result;
-    g_count += 1;
-}
-
-static void tests() {
-    dyn_function_type *dynFunction = NULL;
-    int rc = 0;
-
-    {
-        int32_t (*func)(int32_t a, int32_t b, int32_t c) = NULL;
-        rc = dynFunction_parseWithStr(EXAMPLE1_DESCRIPTOR, NULL, &dynFunction);
-        CHECK_EQUAL(0, rc);
-        rc = dynFunction_createClosure(dynFunction, example1_binding, NULL, (void(**)(void))&func);
-        CHECK_EQUAL(0, rc);
-        int32_t ret = func(2,3,4);
-        CHECK_EQUAL(1, g_count);
-        CHECK_EQUAL(9, ret);
-        dynFunction_destroy(dynFunction);
-    }
-
-    {
-        double (*func)(int32_t a, struct example2_arg2 b, int32_t c) = NULL;
-        double (*func2)(int32_t a, struct example2_arg2 b, int32_t c) = NULL;
-        dynFunction = NULL;
-        rc = dynFunction_parseWithStr(EXAMPLE2_DESCRIPTOR, NULL, &dynFunction);
-        CHECK_EQUAL(0, rc);
-        rc = dynFunction_createClosure(dynFunction, example2_binding, NULL, (void(**)(void))&func);
-        CHECK_EQUAL(0, rc);
-        rc = dynFunction_getFnPointer(dynFunction, (void(**)(void))&func2);
-        CHECK_EQUAL(0, rc);
-        CHECK(func == func2);
-        struct example2_arg2 b;
-        b.val1 = 1.0;
-        b.val2 = 1.5;
-        b.val3 = 2.0;
-        double ret = func(2,b,4);
-        CHECK_EQUAL(2, g_count);
-        CHECK_EQUAL(10.5, ret);
-        dynFunction_destroy(dynFunction);
-    }
-
-    {
-        struct example3_ret * (*func)(int32_t a, int32_t b, int32_t c) = NULL;
-        dynFunction = NULL;
-        rc = dynFunction_parseWithStr(EXAMPLE3_DESCRIPTOR, NULL, &dynFunction);
-        CHECK_EQUAL(0, rc);
-        rc = dynFunction_createClosure(dynFunction, example3_binding, NULL, (void(**)(void))&func);
-        CHECK_EQUAL(0, rc);
-        struct example3_ret *ret = func(2,8,4);
-        CHECK_EQUAL(3, g_count);
-        CHECK_EQUAL(14, ret->sum);
-        dynFunction_destroy(dynFunction);
-        free(ret);
-    }
-}
-
-}
-
-
-TEST_GROUP(DynClosureTests) {
-    void setup() {
-        int lvl = 1;
-        dynFunction_logSetup(stdLog, NULL, lvl);
-        dynType_logSetup(stdLog, NULL, lvl);
-        dynCommon_logSetup(stdLog, NULL, lvl);
-        g_count = 0;
-    }
-};
-
-TEST(DynClosureTests, DynCLosureTest1) {
-    //TODO split up
-    tests();
-}