You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by fa...@apache.org on 2013/12/31 18:38:13 UTC
svn commit: r1554561 - in /qpid/proton/branches/fadams-javascript-binding:
examples/messenger/c/ proton-c/ proton-c/bindings/javascript/
proton-c/bindings/javascript/uuid/
Author: fadams
Date: Tue Dec 31 17:38:12 2013
New Revision: 1554561
URL: http://svn.apache.org/r1554561
Log:
added uuid library to emscripten proper and removed from bindings/javascript subdirectory
Removed:
qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/uuid/
Modified:
qpid/proton/branches/fadams-javascript-binding/examples/messenger/c/recv-async.c
qpid/proton/branches/fadams-javascript-binding/examples/messenger/c/send-async.c
qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt
qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/CMakeLists.txt
qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/my-library.js
Modified: qpid/proton/branches/fadams-javascript-binding/examples/messenger/c/recv-async.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/c/recv-async.c?rev=1554561&r1=1554560&r2=1554561&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/c/recv-async.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/c/recv-async.c Tue Dec 31 17:38:12 2013
@@ -58,12 +58,9 @@ void usage()
exit(0);
}
-void process(void *arg) {
+void process() {
//printf(" *** process ***\n");
- //int err = pn_messenger_work(messenger, 0); // Sends any outstanding messages queued for messenger.
- //printf("err = %d\n", err);
-
// Process incoming messages
while(pn_messenger_incoming(messenger))
@@ -92,6 +89,18 @@ printf("err = %d\n", err);
}
}
+// Callback used by emscripten to ensure pn_messenger_work gets called.
+void work() {
+//printf(" *** work ***\n");
+
+ int err = pn_messenger_work(messenger, 0); // Sends any outstanding messages queued for messenger.
+//printf("err = %d\n", err);
+
+ if (err >= 0) {
+ process();
+ }
+}
+
int main(int argc, char** argv)
{
char* certificate = NULL;
@@ -147,8 +156,8 @@ int main(int argc, char** argv)
pn_messenger_set_blocking(messenger, false); // FA Addition.
-//pn_messenger_set_outgoing_window(messenger, 1024); // FA Addition.
-pn_messenger_set_incoming_window(messenger, 1024); // FA Addition.
+
+//pn_messenger_set_incoming_window(messenger, 1024); // FA Addition.
@@ -177,12 +186,11 @@ pn_messenger_set_incoming_window(messeng
pn_messenger_recv(messenger, -1); // Receive as many messages as messenger can buffer
#if EMSCRIPTEN
- emscripten_set_main_loop(process, 0, 0);
+ emscripten_set_main_loop(work, 0, 0);
#else
while (1) {
- //pn_messenger_wait(messenger, -1); // Block indefinitely until there has been socket activity.
pn_messenger_work(messenger, -1); // Block indefinitely until there has been socket activity.
- process(NULL);
+ process();
}
#endif
Modified: qpid/proton/branches/fadams-javascript-binding/examples/messenger/c/send-async.c
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/c/send-async.c?rev=1554561&r1=1554560&r2=1554561&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/c/send-async.c (original)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/c/send-async.c Tue Dec 31 17:38:12 2013
@@ -62,53 +62,40 @@ void usage()
exit(0);
}
-/*
-void process(void *arg) {
-printf(" *** process ***\n");
+void process() {
+//printf(" *** process ***\n");
- //int err = pn_messenger_work(messenger, 0); // Sends any outstanding messages queued for messenger.
- int pending = pn_messenger_outgoing(messenger); // Get the number of pending messages in the outgoing message queue.
+ // Process outgoing messages
-//printf("err = %d\n", err);
-printf("pending = %d\n", pending);
+ pn_status_t status = pn_messenger_status(messenger, tracker);
+//printf("status = %d\n", status);
+
+ if (status != PN_STATUS_PENDING) {
+printf("status = %d\n", status);
+
+ //pn_messenger_settle(messenger, tracker, 0);
+ //tracked--;
- if (state == SENT_MESSAGE && !pending) {
-printf("calling stop\n");
+printf("exiting\n");
pn_message_free(message); // Release message.
pn_messenger_stop(messenger);
- state = STOPPING;
- } else if (state == STOPPING && !err) {
-printf("exiting\n");
pn_messenger_free(messenger);
exit(0);
}
}
-*/
-
-void process(void *arg) {
-printf(" *** process ***\n");
+// Callback used by emscripten to ensure pn_messenger_work gets called.
+void work() {
+//printf(" *** work ***\n");
- // Process outgoing messages
-
- pn_status_t status = pn_messenger_status(messenger, tracker);
-printf("status = %d\n", status);
-
-/*
- if (status != PN_STATUS_PENDING) {
-printf("status = %d\n", status);
+ int err = pn_messenger_work(messenger, 0); // Sends any outstanding messages queued for messenger.
+//printf("err = %d\n", err);
- pn_messenger_settle(messenger, tracker, 0);
- tracked--;
+ if (err >= 0) {
+ process();
}
-*/
-
-
-
}
-
-
int main(int argc, char** argv)
{
int c;
@@ -151,8 +138,9 @@ int main(int argc, char** argv)
messenger = pn_messenger(NULL);
pn_messenger_set_blocking(messenger, false); // Put messenger into non-blocking mode.
-pn_messenger_set_outgoing_window(messenger, 1024); // FA Addition.
-//pn_messenger_set_incoming_window(messenger, 1024); // FA Addition.
+
+ pn_messenger_set_outgoing_window(messenger, 1024); // FA Addition.
+
@@ -170,12 +158,11 @@ pn_messenger_set_outgoing_window(messeng
#if EMSCRIPTEN
- emscripten_set_main_loop(process, 0, 0);
+ emscripten_set_main_loop(work, 0, 0);
#else
while (1) {
- //pn_messenger_wait(messenger, -1); // Block indefinitely until there has been socket activity.
pn_messenger_work(messenger, -1); // Block indefinitely until there has been socket activity.
- process(NULL);
+ process();
}
#endif
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt?rev=1554561&r1=1554560&r2=1554561&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt Tue Dec 31 17:38:12 2013
@@ -221,6 +221,10 @@ if (SWIG_FOUND)
endif (SWIG_FOUND)
# TODO Make these tests more idiomatic cmake as per comments by Andrew Stitcher.
+# The idiomatic approach involves writing smaller FindXXX.cmake files
+# which return a fixed set of variables and using find_package(XXX...) in
+# the main cmake file.
+#
# Build the JavaScript language binding.
# This is somewhat different to the other language bindings in that it does not use swig. It uses a C/C++ to
# JavaScript cross-compiler called emscripten (https://github.com/kripken/emscripten). Emscripten takes C/C++
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/CMakeLists.txt?rev=1554561&r1=1554560&r2=1554561&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/CMakeLists.txt Tue Dec 31 17:38:12 2013
@@ -28,26 +28,26 @@ message(STATUS "Found emscripten, using
set(CMAKE_C_COMPILER "${EMCC}")
# Specify the archiver to use for cross-compilation.
-find_program(EMAR emar)
-set(CMAKE_AR "${EMAR}")
+#find_program(EMAR emar)
+#set(CMAKE_AR "${EMAR}")
# Specify the ranlib to use for cross-compilation.
-find_program(EMRANLIB emranlib)
-set(CMAKE_RANLIB "${EMRANLIB}")
+#find_program(EMRANLIB emranlib)
+#set(CMAKE_RANLIB "${EMRANLIB}")
# Don't do compiler autodetection, since we are cross-compiling.
include(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER("${CMAKE_C_COMPILER}" Clang)
# Specify the program to use when building static libraries. Force Emscripten-related command line options to clang.
-set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_AR} rc <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
+#set(CMAKE_C_ARCHIVE_CREATE "${CMAKE_AR} rc <TARGET> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <OBJECTS>${CMAKE_END_TEMP_FILE}")
# From this point we should be using emscripten compilation tools rather than default ones
message(STATUS "emscripten compilation environment:")
message(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
-message(STATUS "CMAKE_AR: ${CMAKE_AR}")
-message(STATUS "CMAKE_RANLIB: ${CMAKE_RANLIB}")
-message(STATUS "CMAKE_C_ARCHIVE_CREATE: ${CMAKE_C_ARCHIVE_CREATE}")
+#message(STATUS "CMAKE_AR: ${CMAKE_AR}")
+#message(STATUS "CMAKE_RANLIB: ${CMAKE_RANLIB}")
+#message(STATUS "CMAKE_C_ARCHIVE_CREATE: ${CMAKE_C_ARCHIVE_CREATE}")
# Set this to the proton-c directory, we're cross-compiling code from there.
set(PN_PATH ${CMAKE_SOURCE_DIR}/proton-c)
@@ -60,21 +60,11 @@ set(PN_PATH ${CMAKE_SOURCE_DIR}/proton-c
# set(pn_driver_ssl_impl src/ssl/openssl.c)
# set(SSL_LIB ${OPENSSL_LIBRARIES})
set(pn_driver_ssl_impl ${PN_PATH}/src/ssl/ssl_stub.c)
-set(SSL_LIB "")
# emscripten is Linux like so use the posix driver.
set(pn_driver_impl ${PN_PATH}/src/posix/driver.c)
-# Use stub UUID library (implemented in JavaScript)
-# TODO push proper libuuid back to emscripten and remove this from here.
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/uuid/include")
-set(UUID_LIB "")
-set(UUID_STUB_LIB ${CMAKE_CURRENT_SOURCE_DIR}/uuid/src/library_uuid.js)
-
-# The time lib is in the standard emscripten libraries.
-set(TIME_LIB "")
-
# Generate encodings.h and protocol.h
# It may be possible to use the ones generated for the main proton-c build but qpid-proton-core has
# a dependency on the generated files so I'm not sure if it'll work without a command that can
@@ -170,8 +160,6 @@ add_library(
${qpid-proton-platform}
)
-target_link_libraries(qpid-proton-js ${UUID_LIB} ${SSL_LIB} ${TIME_LIB} ${PLATFORM_LIBS})
-
set_target_properties(
qpid-proton-js
PROPERTIES
@@ -198,12 +186,12 @@ target_link_libraries(recv-async.js qpid
#add_executable(msgr-recv.js ${PN_PATH}/../tests/tools/apps/c/msgr-common.c ${PN_PATH}/../tests/tools/apps/c/msgr-recv.c)
#target_link_libraries(msgr-recv.js qpid-proton-js)
-# TODO get the uuid library and the patches in my-library.js pushed properly into emscripten ASAP
+# TODO get the patches in my-library.js pushed properly into emscripten ASAP
set_target_properties(
send-async.js recv-async.js
PROPERTIES
COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_PLATFORM_FLAGS}"
- LINK_FLAGS "-s SOCKET_DEBUG=1 --js-library ${UUID_STUB_LIB} --js-library ${CMAKE_CURRENT_SOURCE_DIR}/my-library.js"
+ LINK_FLAGS "-s SOCKET_DEBUG=1 --js-library ${CMAKE_CURRENT_SOURCE_DIR}/my-library.js"
)
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/my-library.js
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/my-library.js?rev=1554561&r1=1554560&r2=1554561&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/my-library.js (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/my-library.js Tue Dec 31 17:38:12 2013
@@ -22,63 +22,6 @@
mergeInto(LibraryManager.library, {
// Add to main emscripten library.js
-/*
- $PROTOCOLS: null,
- __buildProtocols__deps: ['$PROTOCOLS'],
- __buildProtocols: function() {
-
- // Allocate and populate a protoent structure given a name, protocol number and array of aliases
- function allocprotoent(name, proto, aliases) {
- // write name into buffer
- var nameBuf = _malloc(name.length + 1);
- writeAsciiToMemory(name, nameBuf);
-
- // write aliases into buffer
- var j = 0;
- var length = aliases.length;
- var aliasListBuf = _malloc((length + 1) * 4); // Use length + 1 so we have space for the terminating NULL pointer.
-
- for (var i = 0; i < length; i++, j += 4) {
- var alias = aliases[i];
- var aliasBuf = _malloc(alias.length + 1);
- writeAsciiToMemory(alias, aliasBuf);
- {{{ makeSetValue('aliasListBuf', 'j', 'aliasBuf', 'i8*') }}};
- }
- {{{ makeSetValue('aliasListBuf', 'j', '0', 'i8*') }}}; // Terminating NULL pointer.
-
- // generate protoent
- var pe = _malloc({{{ C_STRUCTS.protoent.__size__ }}});
- {{{ makeSetValue('pe', C_STRUCTS.protoent.p_name, 'nameBuf', 'i8*') }}};
- {{{ makeSetValue('pe', C_STRUCTS.protoent.p_aliases, 'aliasListBuf', 'i8**') }}};
- {{{ makeSetValue('pe', C_STRUCTS.protoent.p_proto, 'proto', 'i32') }}};
- return pe;
- };
-
- PROTOCOLS = {};
- PROTOCOLS['tcp'] = PROTOCOLS['6'] = allocprotoent('tcp', 6, ['TCP']);
- PROTOCOLS['udp'] = PROTOCOLS['17'] = allocprotoent('udp', 17, ['UDP']);
- },
-
- getprotobyname__deps: ['__buildProtocols', '$PROTOCOLS'],
- getprotobyname: function(name) {
- // struct protoent *getprotobyname (const char *);
- name = Pointer_stringify(name);
- if (!PROTOCOLS) {
- ___buildProtocols();
- }
-
- var result = PROTOCOLS[name];
- return result;
- },
- getprotobynumber__deps: ['getprotobyname'],
- getprotobynumber: function(number) {
- _getprotobyname(number);
- },
-
-
-*/
-
-
// Hacks below
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org