Skip to content

Commit

Permalink
Updating lib.zmq: Backwards compatability for libzmq v3
Browse files Browse the repository at this point in the history
  • Loading branch information
metadings committed Dec 14, 2016
1 parent 7e80b67 commit 1ae92f8
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions lib/zmq.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,30 @@ static zmq()
sizeof_zmq_msg_t = sizeof_zmq_msg_t_v3;
}
}
else // if (major >= 3)
else if (major >= 3)
{
// TODO: Backwards compatability for v3

throw VersionNotSupported(null, ">= 4");
// Backwards compatability for v3

zmq.ctx_shutdown = (ctxPtr) => { throw VersionNotSupported("zmq_ctx_shutdown", "v4"); };
zmq.msg_gets = (msgPtr, propertyPtr) => { throw VersionNotSupported("zmq_msg_gets", "v4"); };
zmq.has = (capabilityPtr) => { throw VersionNotSupported("zmq_has", "v4"); };
zmq.proxy_steerable = (frontendPtr, backendPtr, capturePtr, controlPtr)
=> { throw VersionNotSupported("zmq_proxy_steerable", "v4"); };
zmq.curve_keypair = (z85_public_key, z85_secret_key) => { throw VersionNotSupported("zmq_curve_keypair", "v4"); };
zmq.z85_encode = (dest, data, size) => { throw VersionNotSupported("zmq_z85_encode", "v4"); };
zmq.z85_decode = (dest, data) => { throw VersionNotSupported("zmq_z85_decode", "v4"); };

if (!Platform.Is__Internal) {
zmq.ctx_term = zmq.zmq_term;
}
else {
zmq.ctx_term = zmq.zmq_term__Internal;
}
}
else
{
throw VersionNotSupported(null, ">= v3");
}
// else { }
}

private static NotSupportedException VersionNotSupported(string methodName, string requiredVersion)
Expand Down Expand Up @@ -136,9 +153,11 @@ private static NotSupportedException VersionNotSupported(string methodName, stri
[DllImport(LibraryName, CallingConvention = CCCdecl)]
private static extern Int32 zmq_term(IntPtr context); /**/

/* Deprecated. Use zmq_ctx_term instead.
[DllImport(LibraryName, CallingConvention = CCCdecl)]
private static extern Int32 zmq_ctx_destroy(IntPtr context); /**/
/* Deprecated. Use zmq_ctx_term instead. */
[DllImport(LibraryName, EntryPoint = "zmq_term", CallingConvention = CCCdecl)]
private static extern Int32 zmq_term(IntPtr context);
[DllImport(__Internal, EntryPoint = "zmq_term", CallingConvention = CCCdecl)]
private static extern Int32 zmq_term__Internal(IntPtr context);

[DllImport(LibraryName, EntryPoint = "zmq_ctx_term", CallingConvention = CCCdecl)]
private static extern Int32 zmq_ctx_term(IntPtr context);
Expand Down Expand Up @@ -278,9 +297,9 @@ private static NotSupportedException VersionNotSupported(string methodName, stri
public delegate Int32 zmq_setsockopt_delegate(IntPtr socket, Int32 option_name, IntPtr option_value, Int32 option_len);
public static readonly zmq_setsockopt_delegate setsockopt = zmq_setsockopt;

[DllImport(LibraryName, EntryPoint = "zmq_bind", /*CharSet = CharSet.Ansi,*/ CallingConvention = CCCdecl)]
[DllImport(LibraryName, EntryPoint = "zmq_bind", CallingConvention = CCCdecl)]
private static extern Int32 zmq_bind(IntPtr socket, IntPtr endpoint);
[DllImport(__Internal, EntryPoint = "zmq_bind", /*CharSet = CharSet.Ansi,*/ CallingConvention = CCCdecl)]
[DllImport(__Internal, EntryPoint = "zmq_bind", CallingConvention = CCCdecl)]
private static extern Int32 zmq_bind__Internal(IntPtr socket, IntPtr endpoint);
public delegate Int32 zmq_bind_delegate(IntPtr socket, IntPtr endpoint);
public static readonly zmq_bind_delegate bind = zmq_bind;
Expand Down

0 comments on commit 1ae92f8

Please sign in to comment.