-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: type mismatch: got 'seq[string]' for 'getDatas()' but expected 'SeqString = ref SeqString:ObjectType'` #36
Comments
Thanks for the report. I've confirmed the issue and am working on this. |
Thank you for your issue! I think we have fixed it. Please pull head and try it again. Feel free to reopen if you still have issues. |
yes it compiles now, thank you! I unfortunately still cannot use it. It excepts on field access. I compile the above testfile with:
Then load it in ipython: In [2]: import ttt
In [3]: d = ttt.get_datas()
In [4]: len(d)
Out[4]: 3
In [5]: print(d[0])
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Input In [5], in <module>
----> 1 print(d[0])
File ~\projects\gennyt\bindings\ttt.py:35, in SeqString.__getitem__(self, index)
34 def __getitem__(self, index):
---> 35 return dll.ttt_seq_string_get(self, index)
OSError: exception: access violation reading 0x0000000000000000 Nim version:
Out of curiosity i also tried it with a seq[cstring], this fails in a different way: import genny
proc getDatas*(): seq[string] =
result = @["a", "b", "c"]
exportSeq seq[string]:
discard
proc getDatas2*(): seq[cstring] =
result = @["a".cstring, "b", "c"]
exportSeq seq[cstring]:
discard
exportProcs:
getDatas
getDatas2
writeFiles("bindings", "ttt")
include bindings/internal
In [1]: import ttt
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [1], in <module>
----> 1 import ttt
File ~\projects\gennyt\bindings\ttt.py:124, in <module>
121 dll.ttt_seq_cstring_len.restype = c_longlong
123 dll.ttt_seq_cstring_get.argtypes = [SeqCstring, c_longlong]
--> 124 dll.ttt_seq_cstring_get.restype = cstring
126 dll.ttt_seq_cstring_set.argtypes = [SeqCstring, c_longlong, cstring]
127 dll.ttt_seq_cstring_set.restype = None
NameError: name 'cstring' is not defined |
if you like i can put this into a new issue. |
We do not support exporting cstring directly from Nim right now. It can be added but I'm not going to right now. Looking into at the access violation. |
I see the issue. Seqs were not checking to see if they needed to do type conversions for import/export of the type they hold, like procs were already in genny. Unfortunately for your testing, string is one of the few cases that need conversion so I've got that fixed now in a PR. |
One small thing, I suggest using |
thank you @guzba this works! There is just one little thing, if i loop through the seq, i receive a NoneType error after the last element:
i think this is not such a big issue since one can use this construct:
|
For some reason |
Ok, figured out the issue. We need a custom Iterator + override |
thank you @guzba it works fine now! |
If
seq[string]
is returned by a proc,genny emits invalid code.
from generated internal.nim:
C:\Users\david\projects\gennyt\bindings\internal.nim(32, 11) Error: type mismatch: got 'seq[string]' for 'getDatas()' but expected 'SeqString = ref SeqString:ObjectType'
what works for me if i manual patch internal.nim
Edit: Fixed import, removed nimja
The text was updated successfully, but these errors were encountered: