symmetryinvestments / autowrap

Wrap existing D code for use in Python, Excel, C#
BSD 3-Clause "New" or "Revised" License
80 stars 16 forks source link

Q: how to directly access class field? #297

Closed mw66 closed 3 years ago

mw66 commented 3 years ago

I just tried, but cannot get access to class field:

I build this example:

https://github.com/symmetryinvestments/autowrap/tree/master/examples/pyd

and test this:

https://github.com/symmetryinvestments/autowrap/blob/master/examples/pyd/source/class_wrap.d

class Bizzy {
    int _m;
    ...
}
$ dub build --config=python36

$ ln -s lib/pyd/libpydtests.so pyd.so

$ python3
>>> import pyd
>>> b = pyd.Bizzy(0)
>>> b
bye(0)
>>> b._m = 3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'pyd.Bizzy' object has no attribute '_m'

Add public does not work either:

class Bizzy {
    public int _m;
    ...
}

Any hints?

atilaneves commented 3 years ago

You can't using the pyd backend because of #54.

I recommend using the pynih one instead.

mw66 commented 3 years ago

@atilaneves FYI, it's just fixed:

https://github.com/ariovistus/pyd/issues/152

https://github.com/ariovistus/pyd/pull/153

atilaneves commented 3 years ago

I can't do anything until there's a new dub version of it.

mw66 commented 3 years ago

pyd 0.14.1 is out

mw66 commented 3 years ago

@atilaneves

pyd 0.14.1 is on dub now: https://code.dlang.org/packages/pyd

atilaneves commented 3 years ago

This has a exposed a bug in a dependency. A fix is coming.

mw66 commented 3 years ago

@atilaneves can you make a new release? the version on dub still is v0.6.3

atilaneves commented 3 years ago

Done.