jaeandersson / swig

SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages.
http://www.swig.org
Other
23 stars 19 forks source link

Package name vs. module name #55

Open jaeandersson opened 9 years ago

jaeandersson commented 9 years ago

The proxy classes and functions belonging to a module mymodule are currently placed in a directory +mypackage. Often mymodule and mypackage are the same, but this doesn't need to be the case. You should be able to place wrappers for multiple modules in the same package. This would make sense if you have a large project and you want to decrease the size of the wrapper file, but without changing user syntax.

The ability to have a package name different from the module name does not appear to be supported at the moment.

jaeandersson commented 9 years ago

Note that what the end users sees is the package name, not the module name.

yuriy-kozlov commented 6 years ago

The mypackage.mysubpackage syntax works to create a +mypackage/+mysubpackage folder, but the class names in the generated files end up incorrect. MATLAB expects the full top level package name in every reference, and it doesn't seem to be possible to put an import statement above the class, so this fails in the subpackage .m files:

classdef MyClass < mysubpackage.AbstractClass

with a mysterious sounding error:

The specified superclass 'mysubpackage.AbstractClass' contains a parse error, cannot be found on MATLAB's search path, or is shadowed by another file with the same name.

For classes in mypackage.mysubpackage swig needs to generate: classdef MyClass < mypackage.mysubpackage.AbstractClass See this question: https://stackoverflow.com/questions/29544511/calling-functions-in-a-nested-package

A related question, why don't modules go in a subpackage directory? I expected this to create +mypackage/+mymodule: %module(package="mypackage") mymodule

(accidentally commented on the merge instead of the issue page, so reposting)