-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Possible to avoid code generation when involved type is missing? #1296
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
Comments
I had an idea to use something like:
This allows me to latch on to visibility of If you think a proper solution would be good for swig then maybe we should still explore this topic. If you think that there is no point in adding feature like this to swig then please feel free to close the issue 👍 |
Instead of parsing the .h files for identifiers, use There is the %attribute family of macros in attribute.i for turning get/set methods into properties a.k.a attributes. See attribute.swg for more on this. Here is an example that might work for you: %include "attribute.i"
// uncomment next line to ignore the added attribute/property that comes from %attibute2 below
// %ignore Urho3D::Object::Tasks;
%attribute2(Urho3D::Object, Urho3D::Tasks, Tasks, GetTasks);
%inline %{
namespace Urho3D {
struct Tasks {
int Number;
};
struct Object {
private:
Tasks m_t;
public:
const Tasks& GetTasks() {
return m_t;
}
Object() : m_t() {
m_t.Number = 123;
}
};
}
%} If you look at %attribute2, you'll see that it is simply a combination of %ignore and %extend. It might be easier to use |
Ah this module is very interesting! As i understand to ignore attribute i would have to do Looks like swig has support for just about every usecase 👍 I guess nothing to do here then, ill close the issue. P.S. Whats the best way to ask random questions about swig? I tried mailing list but it appears to be dead. At least you are looking at github issues though, but it feels wrong to spam issue tracker with questions that arent exactly swig issues. |
Mailing list is usually better. |
I am using swig to wrap a pretty big library and one of requirements is to expose API that follows target language naming conventions and idioms. I am approaching problem by using a external python script (using pyclang) to generate interface files for renaming identifiers and generating C# properties from getters/setters.
The Problem
Since external tool is used it is not aware of types that are ignored in manually written interface files. This causes code unwanted code generation for ignored types.
As python script walks all the headers it generates interface like this:
However main interface file ignores
Urho3D::Object::GetTasks
as it should not be wrapped. This causes swig to createSWIGTYPE_p_Urho3D__Tasks
and reference missing methodGetTasks()
as it was ignored.The Question
Would it be possible to somehow remedy such situations by preventing
%typemap(cscode)
emitting any code if type used by$typemap
macro is not wrapped? I am not sure what approach would work best here. I do not expect this to be automatic either, although it would be nice.I have not seen anything that would allow this in documentation so i suspect this is a new feature request. In this case i have no problem implementing this myself, however some guidance would be extremely useful both in deciding how to approach this problem and how/where to implement it as swig's codebase is completely unknown to me.
Thanks!
The text was updated successfully, but these errors were encountered: