jonathf / matlab2cpp

Convertion program from Matlab to C++ using Armadillo
BSD 3-Clause "New" or "Revised" License
181 stars 64 forks source link

Fget error (not implemented?) #109

Closed cmpute closed 5 years ago

cmpute commented 7 years ago

while I'm trying to translate a matlab file, error occurs at the following code: wimgs = [wimgs, param.wimg(:)];, in which param is a struct. the error log writes

Traceback (most recent call last): File "m2cpp.py", line 88, in matlab2cpp.main(args) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/init.py", line 229, in main builder.project.translate(args) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/frontend.py", line 171, in translate backend.translate(self, opt) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/backend.py", line 479, in translate map(translate, node) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/backend.py", line 493, in translate translate_one(node, opt) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/backend.py", line 572, in translate_one (node.cls, node.backend, node.file, node.line)) ValueError: missing return in function Fget in file structs, Matlab: Crash with file: /mnt/d/IVT/runtrackerfunc.m, on line: 78

I found that in _structs.py, the function Fget doesn't do anything, is it not implemented yet?

In addition, error message here should be "missing return in function Fget in file _structs.py".

thanks.

cmpute commented 7 years ago

I manually defined Fget with the same result with Fset, then I get another error occuring at tmpl.basis = tmpl.basis(:,1:opt.maxbasis);, in which opt is also a complicated struct.

error log

Traceback (most recent call last): File "m2cpp.py", line 88, in matlab2cpp.main(args) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/init.py", line 229, in main builder.project.translate(args) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/frontend.py", line 171, in translate backend.translate(self, opt) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/backend.py", line 479, in translate map(translate, node) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/backend.py", line 493, in translate translate_one(node, opt) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/backend.py", line 550, in translate_one (node.cls, node.backend, node.file, node.line)) KeyError: "Expected to find rule for 'Assign' in the file '_structs.py. Crash with file: /mnt/d/IVT/runtrackerfunc.m, on line: 96'"

As well, I de-comment the Assign function in _structs.py, then I get:

Traceback (most recent call last): File "m2cpp.py", line 88, in matlab2cpp.main(args) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/init.py", line 229, in main builder.project.translate(args) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/frontend.py", line 171, in translate backend.translate(self, opt) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/backend.py", line 479, in translate map(translate, node) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/backend.py", line 493, in translate translate_one(node, opt) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/backend.py", line 557, in translate_one value = value(node) File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/rules/variables.py", line 74, in Cget n_fields = node["n_fields"] File "/mnt/d/编程/GitHub/matlab2cpp/matlab2cpp/node/frontend.py", line 404, in __getitem__ raise IndexError("node child \"%s\" not found" % i) IndexError: node child "n_fields" not found

this time I have no idea about how to fix it.

the full code can be found here, I wrapped the script into a function called runtrackerfunc.

I guess there must be some features on struct not implemented, please see into this.

geirpa commented 7 years ago

Yes there are features for struct (and cells) that are not implemented. Don't expect that I will be able to fix this quickly.

cmpute commented 7 years ago

Got it, thanks for replying. Also I'll try to see what I can do to help.