Re: [zeromq-dev] zproject api design and binding question

2019-05-09 Thread Arnaud Loonstra
I've been testing the cffi binding but it's missing some features. I've 
already added one for handling double pointers.

For the record I've been fixing variadics here:

https://github.com/sphaero/zproject/tree/fix_cffi

Still needs testing and fixing destroying

Test file here:
https://gist.github.com/sphaero/f5b2c89a52a1cd3c55bccd61b0ae7ff8

erroring on:

Traceback (most recent call last):
  File "test.py", line 66, in 
input.recv(input, b"m", copy._p)
AttributeError: cdata 'struct _zmsg_t *' points to an opaque type: 
cannot read fields

python3: src/zmsg.c:64: zmsg_destroy: Assertion `zmsg_is (self)' failed.

Rg,

Arnaud

On 5/7/19 4:51 PM, Arnaud Loonstra wrote:
This indeed seems to a problem with at least Python's ctypes binding. 
Perhaps we could mention this somewhere?


I'm now trying the cffi binding. However you'd need to be some wizard to 
get this working without prior knowledge.


I got the binding to build and install. Now trying a simple test to get 
started:


```
from czmq_cffi import *

Zactor.test(True)

output = Zsock(0) # 0 == PAIR
output.connect(b"@inproc://zmsg.test")
assert(output)

input = Zsock(0) # 0 == PAIR
input.bind(b">inproc://zmsg.test")
assert (input);

msg = Zmsg()
assert (msg);
frame = Zframe(b"Hello", 5)
assert (frame);
msg.prepend(frame)
assert (msg.size() == 1)
assert (msg.content_size () == 5);
rc = msg.send(output)
assert (rc == 0)

msg = input.recv(input);
assert (msg)
assert (msg.size() == 1)
assert (msg.content_size() == 5)
```

However it fails:
```
Traceback (most recent call last):
   File "test.py", line 20, in 
     msg.prepend(frame);
   File 
"/home/arnaud/src/libsphactor/bindings/py3test/lib/python3.7/site-packages/czmq_cffi-4.2.1-py3.7-linux-x86_64.egg/czmq_cffi/Zmsg.py", 
line 80, in prepend

     return utils.lib.zmsg_prepend(self._p, frame_p._p)
TypeError: initializer for ctype 'struct _zframe_t * *' must be a 
pointer to same type, not cdata 'struct _zframe_t *'

```
So how to do that? How to get the pointer from Zrame object?

@Kevin, you here? You wrote the cffi binding generator, not?
I think it would be helpful for others if we create a unittest.

Rg,

Arnaud




On 5/2/19 4:20 PM, Arnaud Loonstra wrote:

Hey all,

I'm using zproject to design and build a library to extend zactor a 
bit. However I'm now running into a design issue when using callbacks.


For example I have in my api:
https://github.com/sphaero/libsphactor/blob/master/api/sphactor.api

 
 Callback function for socket activity
 
 
 
 

So a callback which accepts a zmsg and returns a zmsg.

Works perfectly in C. However when I bind to Python it doesn't work. 
It seems Python(ctypes) only handles returning simple types from 
callbacks:


https://bugs.python.org/issue5710

I can see this doesn't apply to any api's I've found so for in czmq or 
zyre.


My question is whether it is bad api design from my side? Or are there 
any workarounds or better approaches for this?


Rg,

Arnaud
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev

___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev


[zeromq-dev] Travis defaults to xenial

2019-05-09 Thread Arnaud Loonstra

Hey all,

It seems travis is switching the default to xenial.

https://blog.travis-ci.com/2019-04-15-xenial-default-build-environment

I'm already seeing errors in Travis in the zproject test:

$ sudo -E apt-get -yq --no-install-suggests --no-install-recommends 
$(travis_apt_get_options) install openjdk-7-jre imagemagick 
generator-scripting-language time

Reading package lists...
Building dependency tree...
Reading state information...
Package openjdk-7-jre is not available, but is referred to by another 
package.

This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'openjdk-7-jre' has no installation candidate

Rg,

Arnaud
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev


[zeromq-dev] gsl/zproject tracing & debugging

2019-05-09 Thread Arnaud Loonstra

Hi all,

I'm currently looking into adding some features to the python_cffi 
binding. I already know how to do it in python but I need the gsl 
generator to do it.


What are best practices for tracing and debugging? I already know 'echo' 
but what is harder is to know what vars are available.


For example I'm now trying to debug the following line:

https://github.com/zeromq/zproject/blob/master/zproject_python_cffi.gsl#L151

which is a for loop:
for my.method.argument by argument.order
...
echo argument
...
endfor

So how to tarce what's available in the argument variable? At first I 
thought these are the argument options from the api xml file. However 
only variadic is available but by_reference not.


Rg,

Arnaud
___
zeromq-dev mailing list
zeromq-dev@lists.zeromq.org
https://lists.zeromq.org/mailman/listinfo/zeromq-dev