diff --git a/CMakeLists.txt b/CMakeLists.txt index 04e422f..8f8812e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,3 +107,36 @@ configure_file( add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) + +SET(MAJOR_VERSION 1) +SET(MINOR_VERSION 0) +SET(PATCH_VERSION 1) +IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") + +INCLUDE (InstallRequiredSystemLibraries) + +SET (CPACK_SET_DESTDIR "on") +SET (CPACK_PACKAGING_INSTALL_PREFIX "/tmp") +SET (CPACK_GENERATOR "DEB") + +SET (CPACK_DEBIAN_PACKAGE_PRIORITY "extra") +SET (CPACK_DEBIAN_PACKAGE_SECTION "libs") +SET (CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) +# autogenerate dependency information +set (CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) + +SET (CPACK_PACKAGE_DESCRIPTION "Short description") +SET (CPACK_PACKAGE_DESCRIPTION_SUMMARY "Long description") +SET (CPACK_PACKAGE_VENDOR "Titan Lien (digbil)") +SET (CPACK_PACKAGE_CONTACT "titan@digbil.com") +SET (CPACK_PACKAGE_VERSION_MAJOR "${MAJOR_VERSION}") +SET (CPACK_PACKAGE_VERSION_MINOR "${MINOR_VERSION}") +SET (CPACK_PACKAGE_VERSION_PATCH "${PATCH_VERSION}") + +SET (CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}") +SET (CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${MAJOR_VERSION}.${MINOR_VERSION}.${CPACK_PACKAGE_VERSION_PATCH}") + +SET (CPACK_COMPONENTS_ALL Libraries ApplicationData) +INCLUDE (CPack) +ENDIF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake") + diff --git a/example/Makefile b/example/Makefile new file mode 100644 index 0000000..766d301 --- /dev/null +++ b/example/Makefile @@ -0,0 +1,9 @@ +TARGET=validate +TARGET2=example + +all: + gcc -o ${TARGET} ${TARGET}.c -lwjelement -lwjreader + gcc -o ${TARGET2} ${TARGET2}.c -lwjelement -lwjreader + +clean: + rm ${TARGET} ${TARGET2} diff --git a/example/example.c b/example/example.c index c0397e7..56a1484 100644 --- a/example/example.c +++ b/example/example.c @@ -64,6 +64,11 @@ console.log(JSON.stringify(doc)); #include #include +WJRType +WJE_GET_TYPE(WJElement parent) +{ + return parent->child->next->type; +} int main(int argc, char **argv) { WJElement doc = NULL; @@ -102,10 +107,7 @@ int main(int argc, char **argv) { WJECloseDocument(WJEGet(doc, "shiny", NULL)); while((person = _WJEObject(doc, "crew[]", WJE_GET, &person))) { - printf("%s (%s) is %"PRId64"\n", - WJEString(person, "name", WJE_GET, ""), - WJEString(person, "job", WJE_GET, ""), - (2517 - WJEInt64(person, "born", WJE_GET, 0))); + printf("person Type is %c\n", WJE_GET_TYPE(person)); } while((cameo = WJEGet(doc, "cameo[]", cameo))) { printf("Cameo: %s\n", WJEString(cameo, NULL, WJE_GET, "")); diff --git a/example/layout.json b/example/layout.json new file mode 100644 index 0000000..c724d27 --- /dev/null +++ b/example/layout.json @@ -0,0 +1,12 @@ +{ + "type": "layout", + "headers": { + "msg_id": "DSCS1385112923586" + }, + "obj": { + "name": "test", + "status": "draft", + "orientation": "landscape", + "widget": [] + } +} diff --git a/example/layout.schema b/example/layout.schema new file mode 100644 index 0000000..dd11130 --- /dev/null +++ b/example/layout.schema @@ -0,0 +1,103 @@ +{ + "name": "layout schema check", + "type": "object", + "properties": { + "_id": { + "type": "string", + "required": true + }, + "name": { + "type": "string", + "required": true + }, + "template": { + "type": "string", + }, + "orientation": { + "type": "string", + "enum": [ + "portrait", + "landscape" + ], + "required": true + }, + "status": { + "type": "string", + "enum": [ + "draft", + "ready" + ], + "default": "ready", + "required": true + }, + "ts": { + "type": "string", + "required": true + }, + "widgets": { + "type": "array", + "required": true, + "items": { + "name": "widget setting", + "type": "object", + "additionalProperties": false, + "properties": { + "widget": { + "type": "string", + "required": true + }, + "name": { + "type": "string", + "description": "Must be the widget name( package name )", + "required": true + }, + "h": { + "type": "number", + "description": " 0.0 ~ 1.0", + "required": true + }, + "w": { + "type": "number", + "description": " 0.0 ~ 1.0", + "required": true + }, + "top": { + "type": "number", + "description": " 0.0 ~ 1.0", + "required": true + }, + "left": { + "type": "number", + "description": " 0.0 ~ 1.0", + "required": true + }, + "_id": { + "type": "string", + "required": true + }, + "param": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "required": true + }, + "val": { + "required": true + }, + + "_id": { + "type": "string", + "required": true + } + } + } + } + } + } + } + } +} diff --git a/example/validate.c b/example/validate.c index 5bf131d..8e8dab0 100644 --- a/example/validate.c +++ b/example/validate.c @@ -46,7 +46,7 @@ static WJElement schema_load(const char *name, void *client, } free(path); } - + WJEDump(schema); return schema; } diff --git a/include/xpl.h b/include/xpl.h index fd2cc17..81f4071 100644 --- a/include/xpl.h +++ b/include/xpl.h @@ -69,7 +69,7 @@ typedef int XplBool; #ifndef WIN32 -typedef unsigned long LONG; +typedef long LONG; #endif #ifndef FALSE