Closed EclipsedButter closed 1 month ago
You're attempting to use custom types for certain parameters, e.g.
__DLL_Compress.argtypes = (
Compressor, # compressor
c.POINTER(c.c_char), # rawBuf
c.c_long, # rawLen
c.POINTER(c.c_char), # compBuf
CompressionLevel, # level
[...]
Compressor
and CompressionLevel
as well as c.POINTER(CompressOptions)
. How are those defined?
ctypes
and zugbruecke
can deal with custom, non-C types - if they have certain interfaces, usually prefixed with from_
. Here is a full example of how this may look like.
I'll preface this by saying that this addon and its implementation of ctypes
should work out of the box on windows. I don't know if that means that the module there has less stringent interfaces or not.
Compressor
and CompressionLevel
implement CtypesEnum
:
class CtypesEnum(IntEnum):
"""A ctypes-compatible IntEnum superclass."""
@classmethod
def from_param(cls, obj):
return int(obj)
class Compressor(CtypesEnum):
Invalid = -1
Null = 3
Kraken = 8
Leviathan = 13
Mermaid = 9
Selkie = 11
Hydra = 12
BitKnit = 10
LZB16 = 4
LZNA = 7
LZH = 0
LZHLW = 1
LZNIB = 2
LZBLW = 5
LZA = 6
Count = 14
Force32 = 0x40000000
class CompressionLevel(CtypesEnum):
Null = 0
SuperFast = 1
VeryFast = 2
Fast = 3
Normal = 4
Optimal1 = 5
Optimal2 = 6
Optimal3 = 7
Optimal4 = 8
Optimal5 = 9
HyperFast1 = -1
HyperFast2 = -2
HyperFast3 = -3
HyperFast4 = -4
HyperFast = HyperFast1
Optimal = Optimal2
Max = Optimal5
Min = HyperFast4
Force32 = 0x40000000
Invalid = Force32
CompressOptions
implements c.Structure
class CompressOptions(c.Structure):
_fields_ = [
("verbosity", c.c_uint),
("minMatchLen", c.c_int),
("seekChunkReset", c.c_bool),
("seekChunkLen", c.c_int),
("profile", c.c_int), # `Profile`
("dictionarySize", c.c_int),
("spaceSpeedTradeoffBytes", c.c_int),
("maxHuffmansPerChunk", c.c_int),
("sendQuantumCRCs", c.c_bool),
("maxLocalDictionarySize", c.c_int),
("makeLongRangeMatcher", c.c_int),
("matchTableSizeLog2", c.c_int),
]
Though, I believe decompression is the only operation being called here, and it has far fewer custom types, all subclasses CTypesEnum
:
class Verbosity(CtypesEnum):
Null = 0
Minimal = 1
Some = 2
Lots = 3
Force32 = 0x40000000
class CheckCRC(CtypesEnum):
No = 0
Yes = 1
Force32 = 0x40000000
So if my understanding is correct, all of the custom types implement no more than from_param
.
We're getting closer ;) zugbruecke
does not support Python's enums as transparently as ctypes
does - yet. So yes, from_param
is the one method that you'd need. It's thin ice though because I have not seen this being used in the wild, ever. It's only implemented in zugbruecke
because an example in a classic piece of literature is using it. As long as you are passing a static value, you should be fine. If you want to alter the value, i.e. the DLL wants to write into memory passed as a pointer, you should work around by using integer types directly instead.
Last but not least, you need to make zugbruecke
aware of the custom type (i.e. in your case stuff based on CtypesEnum
) which is something that is not required with ctypes
(on Windows in your case). The example I pointed to you earlier, here, uses a memsync
directive, a feature of zugbruecke
, to tell zugbruecke
's typing system that there is a custom type coming its way.
So I put this after __DLL_Compress.argtypes
__DLL_Decompress.memsync = [
dict(
pointer = [5], # "path" to argument containing the pointer
length = 1, # "path" to argument containing the length
type = c.c_int, # type of argument (optional, default char/byte): sizeof(type) * length == bytes
custom = CheckCRC, # custom datatype
),
dict(
pointer = [6], # "path" to argument containing the pointer
length = 1, # "path" to argument containing the length
type = c.c_int, # type of argument (optional, default char/byte): sizeof(type) * length == bytes
custom = Verbosity, # custom datatype
),
dict(
pointer = [0], # "path" to argument containing the pointer
length = [1], # "path" to argument containing the length
type = c.c_char, # type of argument (optional, default char/byte): sizeof(type) * length == bytes
),
dict(
pointer = [2], # "path" to argument containing the pointer
length = [3], # "path" to argument containing the length
type = c.c_char, # type of argument (optional, default char/byte): sizeof(type) * length == bytes
),
]
Unfortunately, for the two custom types, I really have no idea what to put for length
. argtypes
isn't passed anything for the length of those two. I can get around it for a bit by replacing the custom types with c.c_int
, but eventually the addon tries to write to the Enum and can't. Since it's a pointer to a single integer (e.g. CheckCRC.No
is initialized as 0), I would assume the length would be 1 (and I think int
in python is minimum 28 bytes). I get this traceback:
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/routine_client.py", line 118, in __call__
mempkgs = DefinitionMemsync.pkg_memories(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/definitions/memsync.py", line 626, in pkg_memories
return [memsync.pkg_memory(args) for memsync in memsyncs]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/definitions/memsync.py", line 626, in <listcomp>
return [memsync.pkg_memory(args) for memsync in memsyncs]
^^^^^^^^^^^^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/definitions/memsync.py", line 435, in pkg_memory
ptr = ctypes.pointer(ptr)
^^^^^^^^^^^^^^^^^^^
TypeError: _type_ must have storage info
Which I assume is because I don't have a valid length argument.
You'd need to set the length to literally 1
which really is not supported yet. The other problem is that for custom types, zugbruecke
assumes that they're passed as pointers, which they are not in your case. Hence zugbruecke
tries to "recover" by wrapping them into pointers itself - which crashes. My code has a lovely "TODO" comment there ... I think this is fixable with manageable effort and I have enough information for a test case. Let me come back to you.
There are a number of lovely issues with enums in general such as this, which are hard to abstract away from users. I attempted to add support for them though. It's sitting in branch feature_enum. Please try.
A matching test case based upon your use case can be found here. Note that there is a new argument in memsync
called value
. It's a path similar to pointer
. Setting a static length is achieved by providing an empty tuple for length
and setting a length function simply to lambda: 1
(i.e. length 1). It's not straight forward but required the least changes to an already complicated code path.
The current solution is experimental, by all means. It might change as its design is ... questionable ;) Feedback is highly welcome.
Highly welcome (?) feedback incoming! So, this definitely got a lot closer... sort of :P
So, it successfully configures the decompression routine, and then writes 10,000 lines of bytes for packed_mempkgs.data
(is there a logging level that would not do that?) to stdout, Wine calls the decompression routine, returns done.
, and then after receiving that, UNIX o: [routine-client] ... received feedback from server, unpacking & syncing arguments ...
, and then we get this fun traceback:
oodle.py", line 354, in decompress
actual_raw_buf_size = __DLL_Decompress(
^^^^^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/routine_client.py", line 136, in __call__
self._data.sync_args(
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/data.py", line 212, in sync_args
self._sync_arg(old_arg, new_arg, argtype)
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/data.py", line 398, in _sync_arg
old_arg.value = new_arg.value
^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/enum.py", line 215, in __set__
raise AttributeError(
AttributeError: <enum 'Enum'> cannot set attribute 'value'
As it happens, I've actually gotten a very similar error on the exact same line before! I mentioned earlier that I tried replacing the enums with c_ints, and updating argtypes
appropriately and putting in literals. This gets more or less the exact same log and traceback, but for that last line. In both cases, it looks like something (the routine I think) tries to write to the parameters for CheckCRC
and Verbosity
; when I just use c_int
, it can't because that isn't a pointer, and with your new solution for enums, we get the above. Hope this helps :)
Have a close look at the test case. The error you see is caused by not passing the enum correctly. First, it must neither be configured nor passed as a pointer, though I guess this not the problem that you are seeing. Second, the memsync
directive must be adjusted accordingly - otherwise you end up in the wrong code path with a failed sync like in your traceback. If you are not sure, can you share the configuration of your function (argtypes
, restype
and memsync
) as well as the section of code where the function gets invoked?
Hm, I tried to match the test case as closely as I could. Here's what I have:
class CtypesEnum(IntEnum):
@classmethod
def from_param(cls, obj):
return int(obj)
class CheckCRC(CtypesEnum):
No = 0
Yes = 1
Force32 = 0x40000000
class Verbosity(CtypesEnum):
Null = 0
Minimal = 1
Some = 2
Lots = 3
Force32 = 0x40000000
class DecodeThreadPhase(CtypesEnum):
ThreadPhase1 = 1
ThreadPhase2 = 2
ThreadPhaseAll = 3
Unthreaded = ThreadPhaseAll
__DLL_Decompress = __DLL["OodleLZ_Decompress"]
__DLL_Decompress.argtypes = (
c.POINTER(c.c_char), # compBuf
c.c_long, # compBufSize
c.POINTER(c.c_char), # rawBuf
c.c_long, # rawLen (known uncompressed size)
c.c_int, # fuzzSafe
CheckCRC, # checkCRC
Verbosity, # verbosity
c.c_void_p, # decBufBase
c.c_long, # decBufSize
c.c_void_p, # fpCallback
c.c_void_p, # callbackUserData
c.c_void_p, # decoderMemory
c.c_long, # decoderMemorySize
c.c_int, # threadPhase
)
__DLL_Decompress.restype = c.c_long
__DLL_Decompress.memsync = [
dict(
value = [5],
length = tuple(),
type = c.c_int,
custom = CheckCRC,
func = "lambda: 1",
),
dict(
value = [6],
length = tuple(),
type = c.c_int,
custom = Verbosity,
func = "lambda: 1",
),
dict(
pointer = [0],
length = [1],
type = c.c_char,
),
dict(
pointer = [2],
length = [3],
type = c.c_char,
),
]
actual_raw_buf_size = __DLL_Decompress(
comp_buf_array,
comp_buf_size,
raw_buf_array,
decompressed_size,
FuzzSafe.Yes,
CheckCRC.No,
Verbosity.Null,
c.c_void_p(),
0,
c.c_void_p(),
c.c_void_p(),
c.c_void_p(),
0,
DecodeThreadPhase.Unthreaded,
)
Calling _DLL_Decompress
is where the error occurs, and it specifies an issue with the enums, and since the only other enums, FuzzSafe
and DecodeThreadPhase
are passed by argtypes
as c_int
, I don't think they are causing the problem.
I just built a function with a similar signature and can not reproduce this. Can you activate full logging and post the log section for this function call?
(1726938898.55/46e4aad1)UNIX o: [dll-client] Trying to register routine "OodleLZ_Decompress" in DLL file "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/myAddon/oo2core_6_win64.dll" ...
(1726938898.55/46e4aad1)WINE o: [dll-server] Trying to access "OodleLZ_Decompress" in DLL file "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/myAddon/oo2core_6_win64.dll" ...
(1726938898.55/46e4aad1)WINE o: [dll-server] ... done.
(1726938898.55/46e4aad1)UNIX o: [dll-client] ... registered (unconfigured).
(1726938909.72/46e4aad1)UNIX o: [routine-client] Trying to call routine "OodleLZ_Decompress" in DLL file "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/myAddon/oo2core_6_win64.dll" ...
(1726938909.72/46e4aad1)UNIX o: [routine-client] ... has not been called before. Configuring ...
(1726938909.73/46e4aad1)UNIX o: {'argtypes': [<Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)UNIX o: <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>],
(1726938909.73/46e4aad1)UNIX o: 'argtypes_raw': [<class 'ctypes.LP_c_char'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.LP_c_char'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.c_int'>,
(1726938909.73/46e4aad1)UNIX o: <enum 'CheckCRC'>,
(1726938909.73/46e4aad1)UNIX o: <enum 'Verbosity'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)UNIX o: <class 'ctypes.c_int'>],
(1726938909.73/46e4aad1)UNIX o: 'memsync': [<Memsync type=c_int null=False unic=False func=True>,
(1726938909.73/46e4aad1)UNIX o: <Memsync type=c_int null=False unic=False func=True>,
(1726938909.73/46e4aad1)UNIX o: <Memsync type=c_char null=False unic=False func=False>,
(1726938909.73/46e4aad1)UNIX o: <Memsync type=c_char null=False unic=False func=False>],
(1726938909.73/46e4aad1)UNIX o: 'memsync_raw': [{'custom': <enum 'CheckCRC'>,
(1726938909.73/46e4aad1)UNIX o: 'func': 'lambda: 1',
(1726938909.73/46e4aad1)UNIX o: 'length': (),
(1726938909.73/46e4aad1)UNIX o: 'type': 'c_int',
(1726938909.73/46e4aad1)UNIX o: 'value': [5]},
(1726938909.73/46e4aad1)UNIX o: {'custom': <enum 'Verbosity'>,
(1726938909.73/46e4aad1)UNIX o: 'func': 'lambda: 1',
(1726938909.73/46e4aad1)UNIX o: 'length': (),
(1726938909.73/46e4aad1)UNIX o: 'type': 'c_int',
(1726938909.73/46e4aad1)UNIX o: 'value': [6]},
(1726938909.73/46e4aad1)UNIX o: {'length': [1], 'pointer': [0], 'type': 'c_char'},
(1726938909.73/46e4aad1)UNIX o: {'length': [3], 'pointer': [2], 'type': 'c_char'}],
(1726938909.73/46e4aad1)UNIX o: 'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)UNIX o: 'restype_raw': <class 'ctypes.c_long'>}
(1726938909.73/46e4aad1)WINE o: {'argtypes': [<Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_void_p flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)WINE o: <Definition group=PyCSimpleType field=None type=c_int32 flags=[]>],
(1726938909.73/46e4aad1)WINE o: 'argtypes_raw': [<class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_longlong'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_longlong'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_long'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_longlong'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_void_p'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_longlong'>,
(1726938909.73/46e4aad1)WINE o: <class 'ctypes.c_long'>],
(1726938909.73/46e4aad1)WINE o: 'memsync': [<Memsync type=c_int null=False unic=False func=True>,
(1726938909.73/46e4aad1)WINE o: <Memsync type=c_int null=False unic=False func=True>,
(1726938909.73/46e4aad1)WINE o: <Memsync type=c_char null=False unic=False func=False>,
(1726938909.73/46e4aad1)WINE o: <Memsync type=c_char null=False unic=False func=False>],
(1726938909.73/46e4aad1)WINE o: 'restype': <Definition group=PyCSimpleType field=None type=c_int64 flags=[]>,
(1726938909.73/46e4aad1)WINE o: 'restype_raw': <class 'ctypes.c_longlong'>}
(1726938909.75/46e4aad1)UNIX o: [routine-client] ... configured. Proceeding ...
(1726938909.75/46e4aad1)UNIX o: [routine-client] ... packing and pushing args to server ...
(1726938911.55/46e4aad1)UNIX o: {'args': [<myAddon.oodle.c_char_Array_7110478 object at 0x34dd92150>,
(1726938911.55/46e4aad1)UNIX o: 7110478,
(1726938911.55/46e4aad1)UNIX o: <myAddon.oodle.c_char_Array_15581048 object at 0x34dd915d0>,
(1726938911.55/46e4aad1)UNIX o: 15580792,
(1726938911.55/46e4aad1)UNIX o: <FuzzSafe.Yes: 1>,
(1726938911.55/46e4aad1)UNIX o: <CheckCRC.No: 0>,
(1726938911.55/46e4aad1)UNIX o: <Verbosity.Null: 0>,
(1726938911.55/46e4aad1)UNIX o: c_void_p(None),
(1726938911.55/46e4aad1)UNIX o: 0,
(1726938911.55/46e4aad1)UNIX o: c_void_p(None),
(1726938911.55/46e4aad1)UNIX o: c_void_p(None),
(1726938911.55/46e4aad1)UNIX o: c_void_p(None),
(1726938911.55/46e4aad1)UNIX o: 0,
(1726938911.55/46e4aad1)UNIX o: <DecodeThreadPhase.ThreadPhaseAll: 3>],
(1726938911.55/46e4aad1)UNIX o: 'packed_args': [None,
(1726938911.55/46e4aad1)UNIX o: 7110478,
(1726938911.55/46e4aad1)UNIX o: None,
(1726938911.55/46e4aad1)UNIX o: 15580792,
(1726938911.55/46e4aad1)UNIX o: 1,
(1726938911.55/46e4aad1)UNIX o: 0,
(1726938911.55/46e4aad1)UNIX o: 0,
(1726938911.55/46e4aad1)UNIX o: None,
(1726938911.55/46e4aad1)UNIX o: 0,
(1726938911.55/46e4aad1)UNIX o: None,
(1726938911.55/46e4aad1)UNIX o: None,
(1726938911.55/46e4aad1)UNIX o: None,
(1726938911.55/46e4aad1)UNIX o: 0,
(1726938911.55/46e4aad1)UNIX o: 3],
(1726938911.55/46e4aad1)UNIX o: 'packed_mempkgs': [{'byvalue': True,
(1726938911.55/46e4aad1)UNIX o: 'data': b'\x00\x00\x00\x00',
(1726938911.55/46e4aad1)UNIX o: 'local_addr': 14190979480,
(1726938911.55/46e4aad1)UNIX o: 'remote_addr': None,
(1726938911.55/46e4aad1)UNIX o: 'wchar': None},
(1726938911.55/46e4aad1)UNIX o: {'byvalue': True,
(1726938911.55/46e4aad1)UNIX o: 'data': b'\x00\x00\x00\x00',
(1726938911.55/46e4aad1)UNIX o: 'local_addr': 14190978584,
(1726938911.55/46e4aad1)UNIX o: 'remote_addr': None,
(1726938911.55/46e4aad1)UNIX o: 'wchar': None},
(1726938911.55/46e4aad1)UNIX o: {'byvalue': False,
(1726938911.55/46e4aad1)UNIX o: 'data': <178714 lines>
(1726938911.55/46e4aad1)UNIX o: 'local_addr': 14192115712,
(1726938911.55/46e4aad1)UNIX o: 'remote_addr': None,
(1726938911.55/46e4aad1)UNIX o: 'wchar': None}]}
(1726939091.43/46e4aad1)WINE o: [routine-server] Trying to call routine "OodleLZ_Decompress" in DLL file "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/myAddon/oo2core_6_win64.dll" ...
(1726939091.46/46e4aad1)WINE o: [routine-server] ... done.
(1726939091.51/46e4aad1)UNIX o: [routine-client] ... received feedback from server, unpacking & syncing arguments ...
File "/Users/butter/Library/Application Support/Blender/4.2/scripts/addons/myAddon/oodle.py", line 354, in decompress
actual_raw_buf_size = __DLL_Decompress(
^^^^^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/routine_client.py", line 136, in __call__
self._data.sync_args(
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/data.py", line 212, in sync_args
self._sync_arg(old_arg, new_arg, argtype)
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/site-packages/zugbruecke/core/data.py", line 398, in _sync_arg
old_arg.value = new_arg.value
^^^^^^^^^^^^^
File "/Applications/Blender.app/Contents/Resources/4.2/python/lib/python3.11/enum.py", line 215, in __set__
raise AttributeError(
AttributeError: <enum 'Enum'> cannot set attribute 'value'
Thanks, I made a dumb mistake when trying to reproduce - now I get the same result.
As a temporary fix, in your function call, explicitly convert DecodeThreadPhase.Unthreaded
to int
i.e. pass int(DecodeThreadPhase.Unthreaded)
to your function instead. This should do the trick. The sync code in zugbruecke
needs a rework though to at least throw meaningful errors ...
Alas, same log, same traceback. I even tried replacing it with just a literal (3). At this point, it's probably an issue on my end...
Ahah, never mind :D I did some print debugging and noticed that it was throwing the error when evaluating FuzzSafe.Yes, which is in the same boat as DecodeThreadPhase.Unthreaded. It seems to be working now! I'll do some further testing and let you know if more custom type issues crop up. Thanks again!
It seems as though custom groups haven't been fully implemented. I don't know very much about DLLs, and it's not my addon here, so I'm just going to put this here for recording's sake. I don't mean to code dump, but I intend to be thorough about this. I'm implementing
zugbruecke
in Blender (though I think that part is irrelevant at this point), in an addon that depends on the Oodleoo2core_6_win64.dll
for file compression and decompression, and have encountered this problem. The DLL is loaded with the following:Then attempt decompression of a file using the DLL, where
comp_buf
is the size of the compressed file inbytes
anddecompressed_size
the expected size of the decompressed file according to a header, as anint
.This causes the error with the following traceback:
Accompanied by the log:
I looked into it, and noticed that the
DefinitionCustom
class wasn't referenced inDefinition.from_packed
, so I threw a stone out, imported it, and put downI assume that this definition wasn't implemented here for good reason, given that I got this error next:
with the log:
At this point, this extends well past my understanding of
ctypes
andzugbruecke
, so I can't figure out whyDefinitionCustom
doesn't work nor how to fix it; that, and the problem could be specific to this DLL, or maybe not. Regardless, I'll just leave this here so you know it's out there, and so maybe I can come back to it one day.Credit to Scott Mooney for the Blender addon code displayed here