From caffff26a0f84aefeeaca6f6fe7fd9f38819a158 Mon Sep 17 00:00:00 2001 From: Arnaud Loonstra Date: Wed, 19 Jun 2024 14:13:57 +0200 Subject: [PATCH] regen from zproject --- api/python_cffi.slurp | 9 +++++++++ .../src/main/c/org_zeromq_czmq_Zosc.c | 18 +++++++++++++++++ .../src/main/java/org/zeromq/czmq/Zosc.java | 15 ++++++++++++++ bindings/lua_ffi/czmq_ffi.lua | 9 +++++++++ bindings/nodejs/README.md | 6 ++++++ bindings/nodejs/binding.cc | 7 +++++++ bindings/nodejs/binding.h | 1 + bindings/python/czmq/_czmq_ctypes.py | 18 +++++++++++++++++ bindings/python_cffi/czmq_cffi/Zosc.py | 14 +++++++++++++ bindings/python_cffi/czmq_cffi/cdefs.py | 9 +++++++++ bindings/qml/src/QmlZosc.cpp | 18 +++++++++++++++++ bindings/qml/src/QmlZosc.h | 7 +++++++ bindings/qt/src/qzosc.cpp | 18 +++++++++++++++++ bindings/qt/src/qzosc.h | 7 +++++++ bindings/ruby/lib/czmq/ffi.rb | 2 ++ bindings/ruby/lib/czmq/ffi/zosc.rb | 20 +++++++++++++++++++ doc/Makefile.am | 2 +- include/zosc.h | 2 +- 18 files changed, 180 insertions(+), 2 deletions(-) diff --git a/api/python_cffi.slurp b/api/python_cffi.slurp index e888e469e..6f2532a65 100644 --- a/api/python_cffi.slurp +++ b/api/python_cffi.slurp @@ -4647,6 +4647,11 @@ zosc_t * zosc_t * zosc_frommem (char *data, size_t size); +// Create a new zosc message from a string. This the same syntax as +// zosc_create but written as a single line string. +zosc_t * + zosc_fromstring (const char *oscstring); + // Create a new zosc message from the given format and arguments. // The format type tags are as follows: // i - 32bit integer @@ -4750,6 +4755,10 @@ zframe_t * zosc_t * zosc_unpack (zframe_t *frame); +// Return a string describing the the OSC message. The returned string must be freed by the caller. +char * + zosc_dump (zosc_t *self); + // Dump OSC message to stdout, for debugging and tracing. void zosc_print (zosc_t *self); diff --git a/bindings/jni/czmq-jni/src/main/c/org_zeromq_czmq_Zosc.c b/bindings/jni/czmq-jni/src/main/c/org_zeromq_czmq_Zosc.c index febfb3fde..e3ae54ab1 100644 --- a/bindings/jni/czmq-jni/src/main/c/org_zeromq_czmq_Zosc.c +++ b/bindings/jni/czmq-jni/src/main/c/org_zeromq_czmq_Zosc.c @@ -37,6 +37,15 @@ Java_org_zeromq_czmq_Zosc__1_1frommem (JNIEnv *env, jclass c, jbyteArray data, j return frommem_; } +JNIEXPORT jlong JNICALL +Java_org_zeromq_czmq_Zosc__1_1fromstring (JNIEnv *env, jclass c, jstring oscstring) +{ + char *oscstring_ = (char *) (*env)->GetStringUTFChars (env, oscstring, NULL); + jlong fromstring_ = (jlong) (intptr_t) zosc_fromstring (oscstring_); + (*env)->ReleaseStringUTFChars (env, oscstring, oscstring_); + return fromstring_; +} + JNIEXPORT jlong JNICALL Java_org_zeromq_czmq_Zosc__1_1create (JNIEnv *env, jclass c, jstring address, jstring format) { @@ -133,6 +142,15 @@ Java_org_zeromq_czmq_Zosc__1_1unpack (JNIEnv *env, jclass c, jlong frame) return unpack_; } +JNIEXPORT jstring JNICALL +Java_org_zeromq_czmq_Zosc__1_1dump (JNIEnv *env, jclass c, jlong self) +{ + char *dump_ = (char *) zosc_dump ((zosc_t *) (intptr_t) self); + jstring return_string_ = (*env)->NewStringUTF (env, dump_); + zstr_free (&dump_); + return return_string_; +} + JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zosc__1_1print (JNIEnv *env, jclass c, jlong self) { diff --git a/bindings/jni/czmq-jni/src/main/java/org/zeromq/czmq/Zosc.java b/bindings/jni/czmq-jni/src/main/java/org/zeromq/czmq/Zosc.java index b1e3ac588..72383f9f2 100644 --- a/bindings/jni/czmq-jni/src/main/java/org/zeromq/czmq/Zosc.java +++ b/bindings/jni/czmq-jni/src/main/java/org/zeromq/czmq/Zosc.java @@ -54,6 +54,14 @@ public static Zosc frommem (byte [] data, long size) { return new Zosc (__frommem (data, size)); } /* + Create a new zosc message from a string. This the same syntax as + zosc_create but written as a single line string. + */ + native static long __fromstring (String oscstring); + public static Zosc fromstring (String oscstring) { + return new Zosc (__fromstring (oscstring)); + } + /* Create a new zosc message from the given format and arguments. The format type tags are as follows: i - 32bit integer @@ -195,6 +203,13 @@ public static Zosc unpack (Zframe frame) { return new Zosc (__unpack (frame.self)); } /* + Return a string describing the the OSC message. The returned string must be freed by the caller. + */ + native static String __dump (long self); + public String dump () { + return __dump (self); + } + /* Dump OSC message to stdout, for debugging and tracing. */ native static void __print (long self); diff --git a/bindings/lua_ffi/czmq_ffi.lua b/bindings/lua_ffi/czmq_ffi.lua index af688b481..8025e3466 100644 --- a/bindings/lua_ffi/czmq_ffi.lua +++ b/bindings/lua_ffi/czmq_ffi.lua @@ -4642,6 +4642,11 @@ zosc_t * zosc_t * zosc_frommem (char *data, size_t size); +// Create a new zosc message from a string. This the same syntax as +// zosc_create but written as a single line string. +zosc_t * + zosc_fromstring (const char *oscstring); + // Create a new zosc message from the given format and arguments. // The format type tags are as follows: // i - 32bit integer @@ -4745,6 +4750,10 @@ zframe_t * zosc_t * zosc_unpack (zframe_t *frame); +// Return a string describing the the OSC message. The returned string must be freed by the caller. +char * + zosc_dump (zosc_t *self); + // Dump OSC message to stdout, for debugging and tracing. void zosc_print (zosc_t *self); diff --git a/bindings/nodejs/README.md b/bindings/nodejs/README.md index cb5523e5b..2e2368e86 100644 --- a/bindings/nodejs/README.md +++ b/bindings/nodejs/README.md @@ -5208,6 +5208,12 @@ zosc my_zosc.unpack (Zframe) Transform a zframe into a zosc. +``` +string my_zosc.dump () +``` + +Return a string describing the the OSC message. The returned string must be freed by the caller. + ``` nothing my_zosc.print () ``` diff --git a/bindings/nodejs/binding.cc b/bindings/nodejs/binding.cc index 25f212c71..eb9c426e7 100644 --- a/bindings/nodejs/binding.cc +++ b/bindings/nodejs/binding.cc @@ -9679,6 +9679,7 @@ NAN_MODULE_INIT (Zosc::Init) { Nan::SetPrototypeMethod (tpl, "pack", _pack); Nan::SetPrototypeMethod (tpl, "packx", _packx); Nan::SetPrototypeMethod (tpl, "unpack", _unpack); + Nan::SetPrototypeMethod (tpl, "dump", _dump); Nan::SetPrototypeMethod (tpl, "print", _print); Nan::SetPrototypeMethod (tpl, "popInt32", _pop_int32); Nan::SetPrototypeMethod (tpl, "popInt64", _pop_int64); @@ -9840,6 +9841,12 @@ NAN_METHOD (Zosc::_unpack) { } } +NAN_METHOD (Zosc::_dump) { + Zosc *zosc = Nan::ObjectWrap::Unwrap (info.Holder ()); + char *result = (char *) zosc_dump (zosc->self); + info.GetReturnValue ().Set (Nan::New (result).ToLocalChecked ()); +} + NAN_METHOD (Zosc::_print) { Zosc *zosc = Nan::ObjectWrap::Unwrap (info.Holder ()); zosc_print (zosc->self); diff --git a/bindings/nodejs/binding.h b/bindings/nodejs/binding.h index 6c02146fa..82aa43a73 100644 --- a/bindings/nodejs/binding.h +++ b/bindings/nodejs/binding.h @@ -1130,6 +1130,7 @@ class Zosc: public Nan::ObjectWrap { static NAN_METHOD (_pack); static NAN_METHOD (_packx); static NAN_METHOD (_unpack); + static NAN_METHOD (_dump); static NAN_METHOD (_print); static NAN_METHOD (_pop_int32); static NAN_METHOD (_pop_int64); diff --git a/bindings/python/czmq/_czmq_ctypes.py b/bindings/python/czmq/_czmq_ctypes.py index 03cd8413f..3aea44304 100644 --- a/bindings/python/czmq/_czmq_ctypes.py +++ b/bindings/python/czmq/_czmq_ctypes.py @@ -9559,6 +9559,8 @@ def test(verbose): lib.zosc_fromframe.argtypes = [zframe_p] lib.zosc_frommem.restype = zosc_p lib.zosc_frommem.argtypes = [c_void_p, c_size_t] +lib.zosc_fromstring.restype = zosc_p +lib.zosc_fromstring.argtypes = [c_char_p] lib.zosc_create.restype = zosc_p lib.zosc_create.argtypes = [c_char_p, c_char_p] lib.zosc_size.restype = c_size_t @@ -9581,6 +9583,8 @@ def test(verbose): lib.zosc_packx.argtypes = [POINTER(zosc_p)] lib.zosc_unpack.restype = zosc_p lib.zosc_unpack.argtypes = [zframe_p] +lib.zosc_dump.restype = POINTER(c_char) +lib.zosc_dump.argtypes = [zosc_p] lib.zosc_print.restype = None lib.zosc_print.argtypes = [zosc_p] lib.zosc_is.restype = c_bool @@ -9695,6 +9699,14 @@ def frommem(data, size): """ return Zosc(lib.zosc_frommem(data, size), True) + @staticmethod + def fromstring(oscstring): + """ + Create a new zosc message from a string. This the same syntax as +zosc_create but written as a single line string. + """ + return Zosc(lib.zosc_fromstring(oscstring), True) + @staticmethod def create(address, format, *args): """ @@ -9819,6 +9831,12 @@ def unpack(frame): """ return Zosc(lib.zosc_unpack(frame), True) + def dump(self): + """ + Return a string describing the the OSC message. The returned string must be freed by the caller. + """ + return return_fresh_string(lib.zosc_dump(self._as_parameter_)) + def print(self): """ Dump OSC message to stdout, for debugging and tracing. diff --git a/bindings/python_cffi/czmq_cffi/Zosc.py b/bindings/python_cffi/czmq_cffi/Zosc.py index 7eed6f8af..d733e6f38 100644 --- a/bindings/python_cffi/czmq_cffi/Zosc.py +++ b/bindings/python_cffi/czmq_cffi/Zosc.py @@ -61,6 +61,14 @@ def frommem(data, size): """ return utils.lib.zosc_frommem(data, size) + @staticmethod + def fromstring(oscstring): + """ + Create a new zosc message from a string. This the same syntax as + zosc_create but written as a single line string. + """ + return utils.lib.zosc_fromstring(utils.to_bytes(oscstring)) + @staticmethod def create(address, format, *format_args): """ @@ -185,6 +193,12 @@ def unpack(frame): """ return utils.lib.zosc_unpack(frame._p) + def dump(self): + """ + Return a string describing the the OSC message. The returned string must be freed by the caller. + """ + return utils.lib.zosc_dump(self._p) + def print_py(self): """ Dump OSC message to stdout, for debugging and tracing. diff --git a/bindings/python_cffi/czmq_cffi/cdefs.py b/bindings/python_cffi/czmq_cffi/cdefs.py index 7ee491dc4..a87b7e5e0 100644 --- a/bindings/python_cffi/czmq_cffi/cdefs.py +++ b/bindings/python_cffi/czmq_cffi/cdefs.py @@ -4649,6 +4649,11 @@ zosc_t * zosc_frommem (char *data, size_t size); +// Create a new zosc message from a string. This the same syntax as +// zosc_create but written as a single line string. +zosc_t * + zosc_fromstring (const char *oscstring); + // Create a new zosc message from the given format and arguments. // The format type tags are as follows: // i - 32bit integer @@ -4752,6 +4757,10 @@ zosc_t * zosc_unpack (zframe_t *frame); +// Return a string describing the the OSC message. The returned string must be freed by the caller. +char * + zosc_dump (zosc_t *self); + // Dump OSC message to stdout, for debugging and tracing. void zosc_print (zosc_t *self); diff --git a/bindings/qml/src/QmlZosc.cpp b/bindings/qml/src/QmlZosc.cpp index d8e5aa158..7830a8344 100644 --- a/bindings/qml/src/QmlZosc.cpp +++ b/bindings/qml/src/QmlZosc.cpp @@ -99,6 +99,15 @@ QmlZframe *QmlZosc::pack () { return retQ_; }; +/// +// Return a string describing the the OSC message. The returned string must be freed by the caller. +QString QmlZosc::dump () { + char *retStr_ = zosc_dump (self); + QString retQStr_ = QString (retStr_); + free (retStr_); + return retQStr_; +}; + /// // Dump OSC message to stdout, for debugging and tracing. void QmlZosc::print () { @@ -254,6 +263,15 @@ QmlZosc *QmlZoscAttached::frommem (char *data, size_t size) { return qmlSelf; }; +/// +// Create a new zosc message from a string. This the same syntax as +// zosc_create but written as a single line string. +QmlZosc *QmlZoscAttached::fromstring (const QString &oscstring) { + QmlZosc *qmlSelf = new QmlZosc (); + qmlSelf->self = zosc_fromstring (oscstring.toUtf8().data()); + return qmlSelf; +}; + /// // Create a new zosc message from the given format and arguments. // The format type tags are as follows: diff --git a/bindings/qml/src/QmlZosc.h b/bindings/qml/src/QmlZosc.h index 4dcd33c21..8842ccfb2 100644 --- a/bindings/qml/src/QmlZosc.h +++ b/bindings/qml/src/QmlZosc.h @@ -91,6 +91,9 @@ public slots: // Transform zosc into a zframe that can be sent in a message. QmlZframe *pack (); + // Return a string describing the the OSC message. The returned string must be freed by the caller. + QString dump (); + // Dump OSC message to stdout, for debugging and tracing. void print (); @@ -185,6 +188,10 @@ public slots: // and calling free on the data after construction. QmlZosc *frommem (char *data, size_t size); + // Create a new zosc message from a string. This the same syntax as + // zosc_create but written as a single line string. + QmlZosc *fromstring (const QString &oscstring); + // Create a new zosc message from the given format and arguments. // The format type tags are as follows: // i - 32bit integer diff --git a/bindings/qt/src/qzosc.cpp b/bindings/qt/src/qzosc.cpp index 54f57add6..025eef292 100644 --- a/bindings/qt/src/qzosc.cpp +++ b/bindings/qt/src/qzosc.cpp @@ -38,6 +38,14 @@ QZosc* QZosc::frommem (char *data, size_t size, QObject *qObjParent) return new QZosc (zosc_frommem (data, size), qObjParent); } +/// +// Create a new zosc message from a string. This the same syntax as +// zosc_create but written as a single line string. +QZosc* QZosc::fromstring (const QString &oscstring, QObject *qObjParent) +{ + return new QZosc (zosc_fromstring (oscstring.toUtf8().data()), qObjParent); +} + /// // Destroy an OSC message QZosc::~QZosc () @@ -126,6 +134,16 @@ QZosc * QZosc::unpack (QZframe *frame) return rv; } +/// +// Return a string describing the the OSC message. The returned string must be freed by the caller. +QString QZosc::dump () +{ + char *retStr_ = zosc_dump (self); + QString rv = QString (retStr_); + zstr_free (&retStr_); + return rv; +} + /// // Dump OSC message to stdout, for debugging and tracing. void QZosc::print () diff --git a/bindings/qt/src/qzosc.h b/bindings/qt/src/qzosc.h index ffcc79a20..f62f7ac65 100644 --- a/bindings/qt/src/qzosc.h +++ b/bindings/qt/src/qzosc.h @@ -28,6 +28,10 @@ class QT_CZMQ_EXPORT QZosc : public QObject // and calling free on the data after construction. static QZosc* frommem (char *data, size_t size, QObject *qObjParent = 0); + // Create a new zosc message from a string. This the same syntax as + // zosc_create but written as a single line string. + static QZosc* fromstring (const QString &oscstring, QObject *qObjParent = 0); + // Destroy an OSC message ~QZosc (); @@ -72,6 +76,9 @@ class QT_CZMQ_EXPORT QZosc : public QObject // Transform a zframe into a zosc. static QZosc * unpack (QZframe *frame); + // Return a string describing the the OSC message. The returned string must be freed by the caller. + QString dump (); + // Dump OSC message to stdout, for debugging and tracing. void print (); diff --git a/bindings/ruby/lib/czmq/ffi.rb b/bindings/ruby/lib/czmq/ffi.rb index b978063de..54d927ef1 100644 --- a/bindings/ruby/lib/czmq/ffi.rb +++ b/bindings/ruby/lib/czmq/ffi.rb @@ -989,6 +989,7 @@ def self.attach_function(name, *rest) attach_function :zosc_new, [:string], :pointer, **opts attach_function :zosc_fromframe, [:pointer], :pointer, **opts attach_function :zosc_frommem, [:pointer, :size_t], :pointer, **opts + attach_function :zosc_fromstring, [:string], :pointer, **opts attach_function :zosc_create, [:string, :string, :varargs], :pointer, **opts attach_function :zosc_destroy, [:pointer], :void, **opts attach_function :zosc_size, [:pointer], :size_t, **opts @@ -1001,6 +1002,7 @@ def self.attach_function(name, *rest) attach_function :zosc_pack, [:pointer], :pointer, **opts attach_function :zosc_packx, [:pointer], :pointer, **opts attach_function :zosc_unpack, [:pointer], :pointer, **opts + attach_function :zosc_dump, [:pointer], :pointer, **opts attach_function :zosc_print, [:pointer], :void, **opts attach_function :zosc_is, [:pointer], :bool, **opts attach_function :zosc_first, [:pointer, :pointer], :pointer, **opts diff --git a/bindings/ruby/lib/czmq/ffi/zosc.rb b/bindings/ruby/lib/czmq/ffi/zosc.rb index d0fcb0cba..b7d04d202 100644 --- a/bindings/ruby/lib/czmq/ffi/zosc.rb +++ b/bindings/ruby/lib/czmq/ffi/zosc.rb @@ -124,6 +124,15 @@ def self.frommem(data, size) __new ptr end + # Create a new zosc message from a string. This the same syntax as + # zosc_create but written as a single line string. + # @param oscstring [String, #to_s, nil] + # @return [CZMQ::Zosc] + def self.fromstring(oscstring) + ptr = ::CZMQ::FFI.zosc_fromstring(oscstring) + __new ptr + end + # Create a new zosc message from the given format and arguments. # The format type tags are as follows: # i - 32bit integer @@ -307,6 +316,17 @@ def self.unpack(frame) result end + # Return a string describing the the OSC message. The returned string must be freed by the caller. + # + # @return [::FFI::AutoPointer] + def dump() + raise DestroyedError unless @ptr + self_p = @ptr + result = ::CZMQ::FFI.zosc_dump(self_p) + result = ::FFI::AutoPointer.new(result, LibC.method(:free)) + result + end + # Dump OSC message to stdout, for debugging and tracing. # # @return [void] diff --git a/doc/Makefile.am b/doc/Makefile.am index a236b11d2..64b574722 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -11,7 +11,7 @@ MAN1 = zmakecert.1 MAN3 = zactor.3 zargs.3 zarmour.3 zcert.3 zcertstore.3 zchunk.3 zclock.3 zconfig.3 zdigest.3 zdir.3 zdir_patch.3 zfile.3 zframe.3 zhash.3 zhashx.3 ziflist.3 zlist.3 zlistx.3 zloop.3 zmsg.3 zpoller.3 zproc.3 zsock.3 zstr.3 zsys.3 ztimerset.3 ztrie.3 zuuid.3 zhttp_client.3 zhttp_server.3 zhttp_server_options.3 zhttp_request.3 zhttp_response.3 zosc.3 zauth.3 zbeacon.3 zgossip.3 zmonitor.3 zproxy.3 zrex.3 # Project overview, written by a human after initial skeleton: # NOTE: stub doc/czmq.adoc is generated by GSL from project.xml -# and then committed to SCM and maintained manually to describe the +# and then comitted to SCM and maintained manually to describe the # project (section 7 = Overview, conventions, and miscellaneous). MAN7 = czmq.7 MAN_DOC = $(MAN1) $(MAN3) $(MAN7) diff --git a/include/zosc.h b/include/zosc.h index d00f9968f..22500efa4 100644 --- a/include/zosc.h +++ b/include/zosc.h @@ -168,7 +168,7 @@ CZMQ_EXPORT zosc_t * zosc_unpack (zframe_t *frame); // *** Draft method, for development use, may change without warning *** -// Return a string describing the the OSC message. +// Return a string describing the the OSC message. The returned string must be freed by the caller. // Caller owns return value and must destroy it when done. CZMQ_EXPORT char * zosc_dump (zosc_t *self);