Re: Make SWIG generated Java interface file not visible outside package
lille stor via Swig-user <[email protected]> Tue, 25 Jun 2024 08:09:58 +0200
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <trinity-cddae9cf-4a9d-46f8-b825-611b55190adf-1719295798819@3c-app-mailcom-bs03> |
--===============4009639688266349590== Content-Type: text/html; charset=UTF-8 <html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div> <div>Hi William,<br/> <br/> Thanks for the info!<br/> <br/> I'm a bit confused now... I though that the sole purpose of typemap "javainterfacemodifiers" was to actually change, e.g., the visibility of the generated Java interface class. See this commit: <a href="https://deref-gmx.com/mail/client/gVi7LFeAy8M/dereferrer/?redirectUrl=https%3A%2F%2Fgithub.com%2Fswig%2Fswig%2Fcommit%2Fc1b004f4fa62b1b15e047fd9462ddf3b46e55357" target="_blank">https://github.com/swig/swig/commit/c1b004f4fa62b1b15e047fd9462ddf3b46e55357</a>. Also, when looking at this line <a href="https://deref-gmx.com/mail/client/8i3vhEUjpo0/dereferrer/?redirectUrl=https%3A%2F%2Fgithub.com%2Fswig%2Fswig%2Fblob%2Fce2bb71a486bd575afb3c19ef98aae5f5e147905%2FSource%2FModules%2Fjava.cxx%23L2098" target="_blank">https://github.com/swig/swig/blob/ce2bb71a486bd575afb3c19ef98aae5f5e 147905/Source/Modules/java.cxx#L2098</a> (in java.cxx), it seems to indicate that.<br/> <br/> Not sure how to proceed from here... thanks for the clarification!</div> <div> </div> <div> </div> <div> <div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"> <div style="margin:0 0 10px 0;"><b>Sent:</b> Friday, June 21, 2024 at 4:05 PM<br/> <b>From:</b> "William S Fulton" <[email protected]><br/> <b>To:</b> "lille stor" <[email protected]><br/> <b>Cc:</b> [email protected]<br/> <b>Subject:</b> Re: [Swig-user] Make SWIG generated Java interface file not visible outside package</div> <div name="quoted-content"> <div> <div> </div> <div>This is not possible as it is hard coded to 'public'. We could add in some pragmas similar to the Java module class pragmas <a href="https://swig.org/Doc4.2/Java.html#Java_module_class_pragmas" target="_blank">https://swig.org/Doc4.2/Java.html#Java_module_class_pragmas</a> to provide this flexibility. I suggest adding in a Github issue for this.</div> <div> </div> <div>William</div> </div> <div class="gmail_quote"> <div class="gmail_attr">On Thu, 20 Jun 2024 at 10:21, lille stor via Swig-user <<a href="mailto:[email protected]" onclick="" target="_blank">[email protected]</a>> wrote:</div> <blockquote class="gmail_quote" style="margin: 0.0px 0.0px 0.0px 0.8ex;border-left: 1.0px solid rgb(204,204,204);padding-left: 1.0ex;"> <div> <div style="font-family: Verdana;font-size: 12.0px;"> <div>I am using SWIG (version 4.2.1) to generate a Java wrapper for some C code. This C code has some constants that SWIG represents with the Java interface file below. As it stands, this interface can be accessed by classes outside the "abc" package because it is declared as "public".</div> <div> </div> <div> <div> /* ----------------------------------------------------------------------------<br/> * This file was automatically generated by SWIG (<a href="http://www.swig.org" target="_blank">http://www.swig.org</a>).<br/> * Version 4.2.1<br/> *<br/> * Do not make changes to this file unless you know what you are doing--modify<br/> * the SWIG interface file instead.<br/> * ----------------------------------------------------------------------------- */</div> <div> package abc;</div> <div> public interface TestConstants {<br/> public final static int YES = TestJNI.YES_get();<br/> public final static int NO = TestJNI.NO_get();<br/> public final static int ENABLED = TestJNI.ENABLED_get();<br/> public final static int DISABLED = TestJNI.DISABLED_get();<br/> }</div> <div> </div> </div> <div> </div> <div>How can I make this interface visible only to classes within the same package (i.e., change "public interface TestConstants" to just "interface TestConstants")? I have tried:</div> <div> </div> <div> %typemap(javainterfacemodifiers) SWIGTYPE "interface"</div> <div> </div> <div>... but it did not work. How can I achieve this using SWIG?</div> <div> </div> </div> </div> _______________________________________________<br/> Swig-user mailing list<br/> <a href="mailto:[email protected]" onclick="" target="_blank">[email protected]</a><br/> <a href="https://lists.sourceforge.net/lists/listinfo/swig-user" target="_blank">https://lists.sourceforge.net/lists/listinfo/swig-user</a></blockquote> </div> </div> </div> </div> </div></div></body></html> --===============4009639688266349590== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============4009639688266349590== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Swig-user mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/swig-user --===============4009639688266349590==--