You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
(11) |
Nov
(184) |
Dec
(182) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
(224) |
Feb
(404) |
Mar
(244) |
Apr
(232) |
May
(162) |
Jun
(193) |
Jul
(174) |
Aug
(161) |
Sep
(170) |
Oct
(283) |
Nov
(310) |
Dec
(130) |
2007 |
Jan
(210) |
Feb
(129) |
Mar
(174) |
Apr
(246) |
May
(269) |
Jun
(212) |
Jul
(229) |
Aug
(202) |
Sep
(190) |
Oct
(194) |
Nov
(172) |
Dec
(128) |
2008 |
Jan
(343) |
Feb
(137) |
Mar
(186) |
Apr
(266) |
May
(156) |
Jun
(147) |
Jul
(140) |
Aug
(78) |
Sep
(128) |
Oct
(126) |
Nov
(100) |
Dec
(106) |
2009 |
Jan
(152) |
Feb
(165) |
Mar
(209) |
Apr
(166) |
May
(97) |
Jun
(152) |
Jul
(159) |
Aug
(196) |
Sep
(151) |
Oct
(107) |
Nov
(128) |
Dec
(64) |
2010 |
Jan
(105) |
Feb
(77) |
Mar
(129) |
Apr
(151) |
May
(126) |
Jun
(97) |
Jul
(86) |
Aug
(99) |
Sep
(64) |
Oct
(88) |
Nov
(59) |
Dec
(91) |
2011 |
Jan
(159) |
Feb
(111) |
Mar
(153) |
Apr
(114) |
May
(88) |
Jun
(201) |
Jul
(158) |
Aug
(124) |
Sep
(101) |
Oct
(149) |
Nov
(160) |
Dec
(68) |
2012 |
Jan
(74) |
Feb
(68) |
Mar
(121) |
Apr
(92) |
May
(172) |
Jun
(100) |
Jul
(85) |
Aug
(65) |
Sep
(74) |
Oct
(105) |
Nov
(76) |
Dec
(21) |
2013 |
Jan
(101) |
Feb
(57) |
Mar
(76) |
Apr
(35) |
May
(43) |
Jun
(50) |
Jul
(32) |
Aug
(50) |
Sep
(33) |
Oct
(58) |
Nov
(26) |
Dec
(49) |
2014 |
Jan
(46) |
Feb
(49) |
Mar
(54) |
Apr
(33) |
May
(46) |
Jun
(57) |
Jul
(34) |
Aug
(36) |
Sep
(69) |
Oct
(37) |
Nov
(27) |
Dec
(57) |
2015 |
Jan
(25) |
Feb
(52) |
Mar
(97) |
Apr
(41) |
May
(44) |
Jun
(36) |
Jul
(27) |
Aug
(33) |
Sep
(29) |
Oct
(45) |
Nov
(23) |
Dec
(23) |
2016 |
Jan
(6) |
Feb
(31) |
Mar
(17) |
Apr
(41) |
May
(31) |
Jun
(51) |
Jul
(20) |
Aug
(36) |
Sep
(69) |
Oct
(55) |
Nov
(29) |
Dec
(17) |
2017 |
Jan
(25) |
Feb
(22) |
Mar
(29) |
Apr
(18) |
May
(30) |
Jun
(13) |
Jul
(22) |
Aug
(12) |
Sep
(20) |
Oct
(60) |
Nov
(36) |
Dec
(20) |
2018 |
Jan
(16) |
Feb
(12) |
Mar
(25) |
Apr
(15) |
May
(32) |
Jun
(28) |
Jul
(8) |
Aug
(20) |
Sep
(6) |
Oct
(40) |
Nov
(18) |
Dec
(56) |
2019 |
Jan
(21) |
Feb
(9) |
Mar
(30) |
Apr
(44) |
May
(18) |
Jun
(17) |
Jul
(12) |
Aug
(14) |
Sep
(17) |
Oct
(12) |
Nov
(19) |
Dec
(13) |
2020 |
Jan
(6) |
Feb
(22) |
Mar
(6) |
Apr
(7) |
May
(3) |
Jun
(32) |
Jul
(35) |
Aug
(11) |
Sep
(22) |
Oct
(9) |
Nov
(9) |
Dec
(14) |
2021 |
Jan
(21) |
Feb
(1) |
Mar
(8) |
Apr
(6) |
May
(2) |
Jun
(11) |
Jul
(5) |
Aug
|
Sep
(15) |
Oct
(18) |
Nov
(3) |
Dec
(18) |
2022 |
Jan
(3) |
Feb
(3) |
Mar
(2) |
Apr
(8) |
May
(5) |
Jun
(6) |
Jul
(7) |
Aug
(5) |
Sep
(12) |
Oct
(9) |
Nov
(4) |
Dec
(3) |
2023 |
Jan
(2) |
Feb
(2) |
Mar
(5) |
Apr
(9) |
May
(8) |
Jun
(10) |
Jul
(1) |
Aug
(5) |
Sep
(1) |
Oct
(2) |
Nov
(6) |
Dec
(2) |
2024 |
Jan
(6) |
Feb
(6) |
Mar
(10) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Duce, R. <ric...@am...> - 2022-09-15 16:50:03
|
[AMD Official Use Only - General] Hi. I am new user to swig. My example is from c++ to perl. I have managed to get a std:vector of std::string returned from c++ to perl , and next up I am attempting to get a std::unordered_map of unordered_map of unordered_map of std::strings returned. On searching for various answers to questions about this I learnt that support for unordered_map has been added 'recently' (wsfulton on Aug 31, 2018 said. swig-3.0.12 does not have support for std::unordered_map, but swig-4.0.0 will. ) I was previously using swig 2.0.10 and so have just downloaded and installed 4.0.2 which I am now attempting to use. My first issue was that although I could see the std_unordered_map.i file in share/swig/4.0.2/std I kept getting messages about the file not being found. Finally I discovered the -I argument to include in the command line. Which I then used as swig =c++ =perl -I/path/to/swigInstall/share/swig/4.0.2/std myFile.i myFile.i contains %module myFile %{ #include "myFile.h" #include <unordered_map> %} using namespace std; %include <std_string.i> %include <std_vector.i> %include <std_unordered_map.i> And I had created some templates like... namespace std { %template(StdStrVector) vector<std::string>; %template(StdStrUnOrdMap) unordered_map<std::string,std::string>; %template(StdStrUnOrdMapL2) unordered_map<std::string,StdStrUnOrdMap>; %template(StdStrUnOrdMapL3) unordered_map<std::string,StdStrUnOrdMapL2>; } Now I managed to get the .i to create the wrap.cxx file and .pm file (In other words, swig now runs to completion.. ) But in attempting to compile the wrap cxx file I get many issues with usr/bin/g++ -fpic -std=c++11 -O2 -g -Wall -c -I/tools/iccad/.packages/x86_64/RHEL7.2/perl/5.20.2-20210630/lib/5.20.2/x86_64-linux-thread-multi-ld/CORE mfile_wrap.cxx -o myfile_wrap.o GVConnectivity_cc_wrap.cxx:1721:25: error: 'traits' is not a class template template <> struct traits< char > { ^ GVConnectivity_cc_wrap.cxx:1721:40: error: explicit specialization of non-template 'swig::traits' template <> struct traits< char > { ^ GVConnectivity_cc_wrap.cxx:1722:15: error: 'pointer_category' does not name a type typedef pointer_category category; ^ GVConnectivity_cc_wrap.cxx:2148:25: error: 'traits' is not a class template template <> struct traits< Verific::Net > { ^ GVConnectivity_cc_wrap.cxx:2148:46: error: 'swig::traits' is not a template type template <> struct traits< Verific::Net > { ^ GVConnectivity_cc_wrap.cxx:2156:22: error: 'traits' is not a class template template <> struct traits<std::vector< Verific::Net*, std::allocator< Verific::Net * > > > { etc... in searching through the .i files in share/swig/4.0.2/std I seem to need std_common.i as well.. but that doesn't seem to help In fact, the swig run gives a bunch of warnings about traits... so its probably not surprising I get compile issues with it /tools/iccad/.packages/x86_64/RHEL6.8/swig/4.0.2/bin/swig -c++ -perl -I/tools/iccad/.packages/x86_64/RHEL6.8/swig/4.0.2/share/swig/4.0.2/std myfile.i /tools/iccad/.packages/x86_64/RHEL6.8/swig/4.0.2/share/swig/4.0.2/std/std_basic_string.i:45: Warning 490: Fragment 'StdTraits' not found. /tools/iccad/.packages/x86_64/RHEL6.8/swig/4.0.2/share/swig/4.0.2/std/std_vector.i:135: Warning 490: Fragment 'StdTraits' not found. /tools/iccad/.packages/x86_64/RHEL6.8/swig/4.0.2/share/swig/4.0.2/std/std_vector.i:135: Warning 490: Fragment 'StdVectorTraits' not found. /tools/iccad/.packages/x86_64/RHEL6.8/swig/4.0.2/share/swig/4.0.2/std/std_vector.i:94: Warning 490: Fragment 'StdTraits' not found. /tools/iccad/.packages/x86_64/RHEL6.8/swig/4.0.2/share/swig/4.0.2/std/std_vector.i:94: Warning 490: Fragment 'StdVectorTraits' not found. /tools/iccad/.packages/x86_64/RHEL6.8/swig/4.0.2/share/swig/4.0.2/std/std_unordered_map.i:119: Warning 490: Fragment 'StdPairTraits' not found. /tools/iccad/.packages/x86_64/RHEL6.8/swig/4.0.2/share/swig/4.0.2/std/std_unordered_map.i:119: Warning 490: Fragment 'StdUnorderedMapTraits' not found. Finally on a whim I found the share/swig/4.0.2/typemaps/ fragments.swg and implicit.swg that seemed to have fragment stuff in.. of course, that didn't help either so any help would be appreciated in getting my wrap file to compile. Thanks in advance Richard Duce |
From: Rob M. <rob...@gm...> - 2022-09-12 17:55:07
|
I have a C++ application with an event driven GUI (using FLTK) that is currently wrapped with Swig for Python. I can make calls (with no GUI loaded) to the exposed API. I can also launch the GUI from Python (and FLTK event loop) and interact with the graphical program for a while -- when satisfied, I can terminate the event loop to return control to Python. I would like to be able to leave the application GUI active (event loop still running) and return control to Python. The Python side might actually be a separate GUI with its own event loop. The two loops will need to communicate occasionally -- I can likely initiate all communication from the Python side. I believe I will need to run Swig with the 'threads' option. I also need to set up some sort of lock so the C++ event loop pauses when the C++ API is responding to a request from the Python side. Can anyone give any pointers on how to achieve this? Are there any examples of this available online? Thanks in advance, Rob |
From: Mario E. <ma...@em...> - 2022-09-12 15:45:49
|
Dear All, I've just started with SWIG and followed the documentation to build a few first examples. Everything works great! Now I have a question: I can not use directly the native C# type in a method signature that expects the generated type. Am I doing some- thing wrong, or is that expected? I'm not too knowledgeable with C# so I have a hard time understanding what is even missing - the assignment operator maybe? The native method expects a `const std::vector<std::string>&`. I name this `StringVector` in the interface. This code illustrates the problem in C#: string[] cData = { "Hello", "World", "äöü", "ß 是" }; IList<string> vStringList = new List<string>(cData); var vInteropTestNativeWrapper = new InteropTestNativeWrapper(); // This does not compile, with error: // Argument 1: cannot convert from 'System.Collections.Generic.IList<string>' to 'StringVector' [InteropTestManaged] //vInteropTestNativeWrapper.setStringVector(vStringList); // This compiles and works, but is a bit more cumbersome: vInteropTestNativeWrapper.setStringVector(new StringVector(vStringList)); Is that to be expected, or is there some way in SWIG to use native types and generated types interchangeable? All the best, Mario Emmenlauer |
From: Prashanth P S <pra...@be...> - 2022-09-01 03:32:49
|
Hi, I am defining a typemap for handling std::string reference args. %typemap(in) std::string & INPUT (std::string str) { STRLEN len; const char * value = SvPV((SV *)$input, len); if (len > 0) { str.assign(value, len); } $1 = &str; } However this results in an error at compile time: test_wrap.cc:2382:11: error: ‘res2’ was not declared in this scope if (SWIG_IsNewObj(res2)) delete arg2; I verified that res2 has not been defined in the wrapper code. Is there something incorrect with the typemap definition ? Please suggest. Perl: v5.8.9 Swig: v3.0.12 Warm Regards, Prashanth PS |
From: Prashanth P S <pra...@be...> - 2022-08-29 06:05:48
|
Dear All, I am working on migrating perl from v5.6.1 to v5.8.9. The swig version being used is v3.0.12. With the new version of perl I see that the swig wrapper compilation throws errors with respect to type mismatch. The errors are with functions that have “char *” or “bool” arguments. For example: CPP code: void setParams(char *id, bool value) { char buf[30]; snprintf(buf, 30, “user_%s”, id); …. } Perl code: my $feature = 3012; my $status = 1; setParams( $feature, $status); I am guessing perl is interpreting the “$feature” as integer and the swig wrapper module which is expecting a “char *” throws argument type mismatch error at run time. However the below line works: setParams( “$feature”, “$status”); Since this code was working with perl 5.6.1. please share any thoughts on switching back to old behaviour (with newer version of perl) since similar issues exist in multiple parts of the legacy code. Warm Regards, Prashanth PS |
From: William S F. <ws...@fu...> - 2022-08-23 19:24:20
|
This doesn't sound familiar. Maybe you have hit a corner case bug or something. Can you post a simple example of this behaviour and the version of SWIG you are using? What you could do to self-diagnose is look at the preprocessed output using swig -E. William On Tue, 23 Aug 2022 at 02:33, Abshire, Ian <ian...@ze...> wrote: > Hello, > > > > I have some question about an issue we have encountered. We use the SWIG > preprocessor definition to exclude functions in the header file that we > don’t want wrapped (e.g. #ifndef SWIG). > > > > The issue we found is when we surround a function we want to exclude with > this block, the functions declared after that will not get called correctly > from Python. Instead, some other unexpected function will get called as if > there is an offset. When we move all exclusion blocks to the end of the > public section of the header, the wrapped functions work as expected. We > also generate a C# interface and have not seen this issue there, only > Python. > > > > Is the way we are excluding functions a good practice? Is it best practice > to put all functions we want excluded at the end of the header? Is this a > bug or a configuration issue? > > > > I’ve searched through the docs, but so far have been unable to discern > answers to these questions. > > > > Thank you in advance for any help or insights! > > > > Ian > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > |
From: Abshire, I. <ian...@ze...> - 2022-08-23 01:32:51
|
Hello, I have some question about an issue we have encountered. We use the SWIG preprocessor definition to exclude functions in the header file that we don't want wrapped (e.g. #ifndef SWIG). The issue we found is when we surround a function we want to exclude with this block, the functions declared after that will not get called correctly from Python. Instead, some other unexpected function will get called as if there is an offset. When we move all exclusion blocks to the end of the public section of the header, the wrapped functions work as expected. We also generate a C# interface and have not seen this issue there, only Python. Is the way we are excluding functions a good practice? Is it best practice to put all functions we want excluded at the end of the header? Is this a bug or a configuration issue? I've searched through the docs, but so far have been unable to discern answers to these questions. Thank you in advance for any help or insights! Ian |
From: William S F. <ws...@fu...> - 2022-08-20 10:26:19
|
I'm trying to keep the release date up to date at https://github.com/swig/swig/milestone/3. It's getting quite close now. Support for Python 3.10 will be included and probably 3.11 as well. William On Thu, 11 Aug 2022 at 02:11, Brian Price <Bri...@re...> wrote: > Hi, > > The last release was in June 2020 Version 4.0.2. > > That version supports Python 3.8 and Python has now had two major releases > since then. > > > > I notice a lot of activity in github on this tool. Can you please give an > indication of when the next release is and when we can expect support for > Python 3.10? > > > > Thanks > ------------------------------ > Warning: Copyright ResMed. Where the contents of this email and/or > attachment includes materials prepared by ResMed, the use of those > materials is subject exclusively to the conditions of engagement between > ResMed and the intended recipient. > > This communication is confidential and may contain legally privileged > information. By the use of email over the Internet or other communication > systems, ResMed is not waiving either confidentiality of, or legal > privilege in, the content of the email and of any attachments. If the > recipient of this message is not the intended addressee, please call ResMed > immediately on +61 2 8884 1000 Sydney, Australia. > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > |
From: Brian P. <Bri...@re...> - 2022-08-11 01:10:42
|
Hi, The last release was in June 2020 Version 4.0.2. That version supports Python 3.8 and Python has now had two major releases since then. I notice a lot of activity in github on this tool. Can you please give an indication of when the next release is and when we can expect support for Python 3.10? Thanks ---------------------------------------------------------------------- Warning: Copyright ResMed. Where the contents of this email and/or attachment includes materials prepared by ResMed, the use of those materials is subject exclusively to the conditions of engagement between ResMed and the intended recipient. This communication is confidential and may contain legally privileged information. By the use of email over the Internet or other communication systems, ResMed is not waiving either confidentiality of, or legal privilege in, the content of the email and of any attachments. If the recipient of this message is not the intended addressee, please call ResMed immediately on +61 2 8884 1000 Sydney, Australia. |
From: William S F. <ws...@fu...> - 2022-07-14 19:17:16
|
On Tue, 28 Jun 2022 at 11:22, Abdullah Mohamed < abd...@co...> wrote: > Hello guys, > > > > Hope this mail finds you well, I am Abdullah Mohamed a software engineer > and I am kind of new to swig and I have some questions and would be > thankful if anyone of you could help me, so my questions are: > > > > 1. Symbols.i -> I can’t convert this file to java format it keeps > telling me that the file is missing %module or -module and when I provide > -module with swig command like this > > swig -c++ - java -module anyname symbols.i (This generates > empty java file) > > 2. Symbols.lst -> I do not know what should I do with that file is > even related to swig or I should just leave it as it is. > > > > > > P.s: I am attaching the files at the mail and I am currently trying to > create these files in java format in order to use pjsip in java and I am > also working on windows 10 with swigwin-4.0.2 > > > Hi Mohamed I ran this as described and get 74 java files generated. None of them are empty. Whatever symbols.lst is, it isn't anything that SWIG can use. William |
From: William S F. <ws...@fu...> - 2022-07-14 18:02:52
|
Put the %extend A { ... } before the %ignore A::get. William On Wed, 6 Jul 2022 at 15:14, <kri...@gm...> wrote: > Hi all > > > > Hi all > > > > William added support for std::unique_ptr a few days ago but I need to > support older SWIG for a while. Therefore I'm trying to work-around it by > creating an equivalent function in the SWIG interface file that returns a > bare pointer that should replace the original. I have to ignore the > original function but would like to give the "replacement" function the > same name. Something like this > > > > // original code has > > std::unique_ptr<B> A::get(); > > > > // ignore to avoid error with unique_ptr > > %ignore A::get; > > %include "A.h" > > > > %newobject A::get; > > %extend A > > { > > // replacement > > B* get() { return self->get().release(); } > > } > > > > This works when my replacement function has a different name. > Unfortunately the %ignore for the original function, means that my > replacement function gets ignored as well. > > > > Any suggestions? > > > > Kris > > > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > |
From: Langer, S. A. (Fed) <ste...@ni...> - 2022-07-08 00:25:52
|
You're right. For some reason it seemed not to work when I first tried it. I must have been doing something wrong. Thanks! -- Steve From: "Cherry, Josh (NIH/NLM/NCBI) [E]" <jc...@nc...> Date: Thursday, July 7, 2022 at 4:25 PM To: "swi...@li..." <swi...@li...>, "Langer, Stephen A. (Fed)" <ste...@ni...> Subject: Re: [Swig-user] %newobject and typemap(out) Might a "newfree" typemap get you what you want? I would think so from the std::string example here: https://www.swig.org/Doc4.0/Typemaps.html#Typemaps_nn34<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.swig.org%2FDoc4.0%2FTypemaps.html%23Typemaps_nn34&data=05%7C01%7Cstephen.langer%40nist.gov%7Cc1ab6dc5460443983e6808da6056caec%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637928223269523285%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HYcjkd33mNtwbGCBc5fuvo0iNSm5xR2vdGlszL%2FBu%2FA%3D&reserved=0> ________________________________ From: Langer, Stephen A. (Fed) via Swig-user <swi...@li...> Sent: Thursday, July 7, 2022 3:14 PM To: swi...@li... <swi...@li...> Subject: [EXTERNAL] Re: [Swig-user] %newobject and typemap(out) I understand why what I expected to happen doesn’t happen, so I'll rephrase the question: Is there a way to write a typemap(out) so that it either deletes its source or doesn't, depending on a flag in the swig file that indicates whether or not the object was newly allocated before being returned? To be specific, I'm trying to do something like this: %typemap(out) MyClass * { $result = some_operations_on($1); if(newly_allocated) // <<-- how??? delete $1; } so that I can do this: MyClass *getOldObject(); %newobject getNewObject; MyClass *getNewObject(); or something along those lines. I know that I can write two typemaps, one for MyClass and one for NewMyClass, put the delete statement only in the NewMyClass typemap, and typedef NewMyClass to MyClass. Is there a better way? Thanks, -- Steve -----Original Message----- From: "Langer, Stephen A. (Fed) via Swig-user" <swi...@li...> Reply-To: "Langer, Stephen A. (Fed)" <ste...@ni...> Date: Thursday, July 7, 2022 at 10:20 AM To: "swi...@li..." <swi...@li...> Subject: [Swig-user] %newobject and typemap(out) Hi -- Is it possible for a typemap to know whether or not it's being invoked in conjunction with %newobject? If %newobject is used on a function where the return value has a typemap(newfree) but no typemap(out), the wrapper will correctly delete the return value. But if there's a typemap(out), newfree doesn't seem to be used. How can a typemap(out) know whether or not it should delete the return value? Thanks. -- Steve _______________________________________________ Swig-user mailing list Swi...@li... https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cjcherry%40ncbi.nlm.nih.gov%7C7a5f2917d893469ddfba08da604d1cb9%7C14b77578977342d58507251ca2dc2b06%7C0%7C0%7C637928181556625188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=yJa82ISBB1VHdL2ivrzKCzC2uYWtCTygDdJ4iQt0SAU%3D&reserved=0<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cstephen.langer%40nist.gov%7Cc1ab6dc5460443983e6808da6056caec%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637928223269523285%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=w1p2lC25JVvpkZ3kGTRt0X4tH8j9dwvxTfqayz%2BPIkM%3D&reserved=0> _______________________________________________ Swig-user mailing list Swi...@li... https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cjcherry%40ncbi.nlm.nih.gov%7C7a5f2917d893469ddfba08da604d1cb9%7C14b77578977342d58507251ca2dc2b06%7C0%7C0%7C637928181556625188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=yJa82ISBB1VHdL2ivrzKCzC2uYWtCTygDdJ4iQt0SAU%3D&reserved=0<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cstephen.langer%40nist.gov%7Cc1ab6dc5460443983e6808da6056caec%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637928223269523285%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=w1p2lC25JVvpkZ3kGTRt0X4tH8j9dwvxTfqayz%2BPIkM%3D&reserved=0> CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and are confident the content is safe. |
From: Cherry, J. (NIH/NLM/N. [E] <jc...@nc...> - 2022-07-07 20:40:58
|
Might a "newfree" typemap get you what you want? I would think so from the std::string example here: https://www.swig.org/Doc4.0/Typemaps.html#Typemaps_nn34 ________________________________ From: Langer, Stephen A. (Fed) via Swig-user <swi...@li...> Sent: Thursday, July 7, 2022 3:14 PM To: swi...@li... <swi...@li...> Subject: [EXTERNAL] Re: [Swig-user] %newobject and typemap(out) I understand why what I expected to happen doesn’t happen, so I'll rephrase the question: Is there a way to write a typemap(out) so that it either deletes its source or doesn't, depending on a flag in the swig file that indicates whether or not the object was newly allocated before being returned? To be specific, I'm trying to do something like this: %typemap(out) MyClass * { $result = some_operations_on($1); if(newly_allocated) // <<-- how??? delete $1; } so that I can do this: MyClass *getOldObject(); %newobject getNewObject; MyClass *getNewObject(); or something along those lines. I know that I can write two typemaps, one for MyClass and one for NewMyClass, put the delete statement only in the NewMyClass typemap, and typedef NewMyClass to MyClass. Is there a better way? Thanks, -- Steve -----Original Message----- From: "Langer, Stephen A. (Fed) via Swig-user" <swi...@li...> Reply-To: "Langer, Stephen A. (Fed)" <ste...@ni...> Date: Thursday, July 7, 2022 at 10:20 AM To: "swi...@li..." <swi...@li...> Subject: [Swig-user] %newobject and typemap(out) Hi -- Is it possible for a typemap to know whether or not it's being invoked in conjunction with %newobject? If %newobject is used on a function where the return value has a typemap(newfree) but no typemap(out), the wrapper will correctly delete the return value. But if there's a typemap(out), newfree doesn't seem to be used. How can a typemap(out) know whether or not it should delete the return value? Thanks. -- Steve _______________________________________________ Swig-user mailing list Swi...@li... https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cjcherry%40ncbi.nlm.nih.gov%7C7a5f2917d893469ddfba08da604d1cb9%7C14b77578977342d58507251ca2dc2b06%7C0%7C0%7C637928181556625188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=yJa82ISBB1VHdL2ivrzKCzC2uYWtCTygDdJ4iQt0SAU%3D&reserved=0 _______________________________________________ Swig-user mailing list Swi...@li... https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cjcherry%40ncbi.nlm.nih.gov%7C7a5f2917d893469ddfba08da604d1cb9%7C14b77578977342d58507251ca2dc2b06%7C0%7C0%7C637928181556625188%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=yJa82ISBB1VHdL2ivrzKCzC2uYWtCTygDdJ4iQt0SAU%3D&reserved=0 CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and are confident the content is safe. |
From: Langer, S. A. (Fed) <ste...@ni...> - 2022-07-07 19:14:41
|
I understand why what I expected to happen doesn’t happen, so I'll rephrase the question: Is there a way to write a typemap(out) so that it either deletes its source or doesn't, depending on a flag in the swig file that indicates whether or not the object was newly allocated before being returned? To be specific, I'm trying to do something like this: %typemap(out) MyClass * { $result = some_operations_on($1); if(newly_allocated) // <<-- how??? delete $1; } so that I can do this: MyClass *getOldObject(); %newobject getNewObject; MyClass *getNewObject(); or something along those lines. I know that I can write two typemaps, one for MyClass and one for NewMyClass, put the delete statement only in the NewMyClass typemap, and typedef NewMyClass to MyClass. Is there a better way? Thanks, -- Steve -----Original Message----- From: "Langer, Stephen A. (Fed) via Swig-user" <swi...@li...> Reply-To: "Langer, Stephen A. (Fed)" <ste...@ni...> Date: Thursday, July 7, 2022 at 10:20 AM To: "swi...@li..." <swi...@li...> Subject: [Swig-user] %newobject and typemap(out) Hi -- Is it possible for a typemap to know whether or not it's being invoked in conjunction with %newobject? If %newobject is used on a function where the return value has a typemap(newfree) but no typemap(out), the wrapper will correctly delete the return value. But if there's a typemap(out), newfree doesn't seem to be used. How can a typemap(out) know whether or not it should delete the return value? Thanks. -- Steve _______________________________________________ Swig-user mailing list Swi...@li... https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cstephen.langer%40nist.gov%7C42c220812e33459a2abd08da6023dd74%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637928004412017784%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=Wj6Eq22wc75kWwgbw0Ed6jSUKVkeRam3g5N78T%2B97v0%3D&reserved=0 |
From: Langer, S. A. (Fed) <ste...@ni...> - 2022-07-07 14:18:38
|
Hi -- Is it possible for a typemap to know whether or not it's being invoked in conjunction with %newobject? If %newobject is used on a function where the return value has a typemap(newfree) but no typemap(out), the wrapper will correctly delete the return value. But if there's a typemap(out), newfree doesn't seem to be used. How can a typemap(out) know whether or not it should delete the return value? Thanks. -- Steve |
From: <kri...@gm...> - 2022-07-06 14:13:51
|
Hi all Hi all William added support for std::unique_ptr a few days ago but I need to support older SWIG for a while. Therefore I'm trying to work-around it by creating an equivalent function in the SWIG interface file that returns a bare pointer that should replace the original. I have to ignore the original function but would like to give the "replacement" function the same name. Something like this // original code has std::unique_ptr<B> A::get(); // ignore to avoid error with unique_ptr %ignore A::get; %include "A.h" %newobject A::get; %extend A { // replacement B* get() { return self->get().release(); } } This works when my replacement function has a different name. Unfortunately the %ignore for the original function, means that my replacement function gets ignored as well. Any suggestions? Kris |
From: Abdullah M. <abd...@co...> - 2022-06-28 10:22:07
|
Hello guys, Hope this mail finds you well, I am Abdullah Mohamed a software engineer and I am kind of new to swig and I have some questions and would be thankful if anyone of you could help me, so my questions are: 1. Symbols.i -> I can't convert this file to java format it keeps telling me that the file is missing %module or -module and when I provide -module with swig command like this swig -c++ - java -module anyname symbols.i (This generates empty java file) 2. Symbols.lst -> I do not know what should I do with that file is even related to swig or I should just leave it as it is. P.s: I am attaching the files at the mail and I am currently trying to create these files in java format in order to use pjsip in java and I am also working on windows 10 with swigwin-4.0.2 Thanks in advance and hope to hear from you soon. Best Regards, Abdullah Mohamed |
From: Rokas K. <ro...@zo...> - 2022-06-14 06:11:10
|
You can do it by tapping into python import mechanism: import os import sys import importlib import importlib.util import __main__ BASE_DIR = os.path.dirname(__main__.__file__) sys.path.append(f'{BASE_DIR}/{__package__}')# Help SWIG bindings to find sibling modules. class SWIGModuleLoader(importlib.abc.Loader): def __init__(self): self._load_modules ='core', 'imgui', 'implot' def find_module(self, fullname, path=None): for modin self._load_modules: if fullname ==f'imgui_py.{mod}._{mod}': return self def load_module(self, fullname): _, mod, _ = fullname.split('.') # TODO: Read it from env variable to support different cmake build configs. build_cache_dir ='cmake-build-debug' native_module_path =f'{BASE_DIR}/{build_cache_dir}/{__package__}/{mod}/_{mod}.so' # TODO: Windows/MacOS spec = importlib.util.spec_from_file_location(fullname, native_module_path) return importlib.util.module_from_spec(spec) sys.meta_path.insert(0, SWIGModuleLoader()) -- Rokas Kupstys On 2022-06-14 07:45, Rob McDonald wrote: > I am wrapping my C++ library (foo) with SWIG. My primary target is > Python, but occasionally use some of the other languages. > > I need a way (from my module in C++) to determine where on the > filesystem the module is located. > > Longer version: > > My module needs to call another binary executable (bar). > > The _foo.so (or _foo.pyd) and foo.py files including the bar (or > bar.exe) binary executable all need to be a part of a Python package > that will be installed via "pip install". > > When I compile foo as a stand-alone executable, I have some code > "PathToExe()" that makes appropriate system calls to determine where > the currently running executable is located. I then search the > location of foo.exe in order to find bar.exe -- and that is the > version I call when needed. > > When the same code runs in Python, PathToExe() finds the path to the > currently running Python interpreter. If you place bar.exe there, it > finds it and everything works. However, I consider it bad form to > require the end user to place some binary files in the same location > as the Python binary. > > Instead, I need to write some functions like... 'RunningAsModule()' > and 'PathToModule()' that I can use to set the path to bar.exe > appropriately. > > If this is impossible, I can probably use Python's 'inspect' to do > something like... > > os.path.dirname( inspect.getfile( foo ) ) > > And then set the path in my module from the Python side. However, it > would be a lot cleaner if the module could take care of this itself on > startup. > > Thanks for any suggestions, > > Rob > > > > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user |
From: Rob M. <rob...@gm...> - 2022-06-14 04:46:00
|
I am wrapping my C++ library (foo) with SWIG. My primary target is Python, but occasionally use some of the other languages. I need a way (from my module in C++) to determine where on the filesystem the module is located. Longer version: My module needs to call another binary executable (bar). The _foo.so (or _foo.pyd) and foo.py files including the bar (or bar.exe) binary executable all need to be a part of a Python package that will be installed via "pip install". When I compile foo as a stand-alone executable, I have some code "PathToExe()" that makes appropriate system calls to determine where the currently running executable is located. I then search the location of foo.exe in order to find bar.exe -- and that is the version I call when needed. When the same code runs in Python, PathToExe() finds the path to the currently running Python interpreter. If you place bar.exe there, it finds it and everything works. However, I consider it bad form to require the end user to place some binary files in the same location as the Python binary. Instead, I need to write some functions like... 'RunningAsModule()' and 'PathToModule()' that I can use to set the path to bar.exe appropriately. If this is impossible, I can probably use Python's 'inspect' to do something like... os.path.dirname( inspect.getfile( foo ) ) And then set the path in my module from the Python side. However, it would be a lot cleaner if the module could take care of this itself on startup. Thanks for any suggestions, Rob |
From: Rokas K. <ro...@zo...> - 2022-06-05 16:27:02
|
Hello, I am wrapping following function: > IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, > void* sdl_gl_context); And i use wrapped function together with PySDL2 package, which returns SDL_Window as ctypes pointer. I am unable to figure out how to pass this pointer as a parameter to wrapped function. I always get following error: > TypeError: in method 'ImGui_ImplSDL2_InitForOpenGL', argument 1 of > type 'SDL_Window *' In my template i have this: > %apply void* { SDL_Window*, SDL_Event* }; Idea is to just wrap these types as void* and that should be enough, but its not. I also tried to pass "window.contents.value" as parameter, which gets a python int with pointer address. That also did not work. Any idea what else i could try? Thanks -- -- Rokas Kupstys |
From: Langer, S. A. (Fed) <ste...@ni...> - 2022-06-01 22:32:22
|
I get the same behavior with the Python provided by Apple, which is 3.8. I didn't try installing from python.org. Since it's only a warning and it goes away if I use Python 3.10 from MacPorts, I'm not going to worry about it. There are more important things to do. Thanks for your advice, though, even if I didn’t take all of it! -- Steve On 6/1/22, 5:10 PM, "William S Fulton" <ws...@fu...<mailto:ws...@fu...>> wrote: Sorry, I don't have access to MacOS. Perhaps there is something odd about the way that MacPorts packages Python. Perhaps try the native versions provided by python.org<https://gcc02.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpython.org%2F&data=05%7C01%7Cstephen.langer%40nist.gov%7C79ad42c2139e433acbf508da4413350f%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637897146531000229%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=pTievTJESnrseNPkCNJ8%2FuF1hXZhPhBWhytSWekzyaM%3D&reserved=0>, they don't have this problem on Windows nor Linux. On Tue, 31 May 2022 at 16:23, Langer, Stephen A. (Fed) <ste...@ni...<mailto:ste...@ni...>> wrote: Hi William -- I'm using an iMac running macOS Big Sur 11.6.6. All dependencies were installed with MacPorts. I just figured out that the problem doesn't occur on Ubuntu 20.04. I don't have access to other OS's. I've attached a swig file and a cmake file, and the output from running cmake and make, with both swig 4.0.2 and 4.1.0 (from github). The swig file just uses %inline to declare a simple function. The same warning appears in both cases. -- Steve On 5/28/22, 4:39 AM, "William S Fulton" <ws...@fu...<mailto:ws...@fu...>> wrote: For the pending 4.1.0 release we do have one change: [Python] Fix "too many initializers for 'PyHeapTypeObject'" errors using PyPy 3.8 and later. but that is for PyPy not CPython. Try out master and if you still see the tp_print warnings, please put together a small testcase to demonstrate. William On Tue, 24 May 2022 at 23:23, Langer, Stephen A. (Fed) <ste...@ni...<mailto:ste...@ni...>> wrote: Thanks for the response. Using the tp_repr slot did just what I needed. I still don't understand what's going on with the tp_print warnings, but I'm content to ignore them if that's what's recommended. I am using swig 4.0.2, so shouldn't it be compatible with python 3.8? -- Steve On 5/20/22, 4:45 PM, "William S Fulton" <ws...@fu...<mailto:ws...@fu...>> wrote: 1. From the CHANGES file for swig-4.0.2: 2020-01-05: jschueller shadchin [Python] #1670 #1696 Add missing field initializers introduced in python 3.8: tp_vectorcall and tp_print. 2. Customise using slots with the "python:tp_repr" feature, see https://www.swig.org/Doc4.0/Python.html#Python_builtin_overloads<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.swig.org%2FDoc4.0%2FPython.html%23Python_builtin_overloads&data=05%7C01%7Cstephen.langer%40nist.gov%7C79ad42c2139e433acbf508da4413350f%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637897146531000229%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=DAaFB2fZ1xdaN9RqZgbN%2BNTl1iPn6vSXFc8ZTzzBquQ%3D&reserved=0>. William On Fri, 29 Apr 2022 at 22:13, Langer, Stephen A. (Fed) via Swig-user <swi...@li...<mailto:swi...@li...>> wrote: Hi -- I'm beginning to use Swig 4 on a project. My previous experience was with Swig 1.1, so I have some catching up to do. I'm generating python3 wrappers for C++. The Swig web site says that Swig 4.0.1 added support for Python 3.8. When I use Python 3.8, I get a lot of warnings that 'tp_print' is deprecated when compiling the _wrap.cxx files (using cmake on a Mac). If I use Python 3.10, I don't get the warnings. As far as I can tell, both versions work, but I'm confused. Is 3.10 supported? It looks like it's supported better than 3.8. Or is the lack of warnings in 3.10 misleading? My second question is how to override the default __repr__ for swigged classes. With Swig 1.1 and Python 2.7, I could just monkey patch a new __repr__ in the python wrapper for the class. With Swig 4, defining __repr__ in C++ or monkey patching it works only if I don't use -builtin. If I do use -builtin, then monkey patching is forbidden and __repr__ defined in C++ is replaced by the generic SwigPyObject_repr. Is it possible to redefine __repr__ for a swigged class when using -builtin? Thanks. -- Steve _______________________________________________ Swig-user mailing list Swi...@li...<mailto:Swi...@li...> https://lists.sourceforge.net/lists/listinfo/swig-user<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cstephen.langer%40nist.gov%7C79ad42c2139e433acbf508da4413350f%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637897146531000229%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HpDmByd5cDk1e7pSjwHG4Es2pLOPcykkKYF1FEAB%2BYM%3D&reserved=0> |
From: William S F. <ws...@fu...> - 2022-06-01 21:09:40
|
Sorry, I don't have access to MacOS. Perhaps there is something odd about the way that MacPorts packages Python. Perhaps try the native versions provided by python.org, they don't have this problem on Windows nor Linux. On Tue, 31 May 2022 at 16:23, Langer, Stephen A. (Fed) < ste...@ni...> wrote: > Hi William -- > > > > I'm using an iMac running macOS Big Sur 11.6.6. All dependencies were > installed with MacPorts. I just figured out that the problem doesn't occur > on Ubuntu 20.04. I don't have access to other OS's. > > > > I've attached a swig file and a cmake file, and the output from running > cmake and make, with both swig 4.0.2 and 4.1.0 (from github). The swig > file just uses %inline to declare a simple function. The same warning > appears in both cases. > > > > -- Steve > > > > On 5/28/22, 4:39 AM, "William S Fulton" <ws...@fu...> wrote: > > > > For the pending 4.1.0 release we do have one change: > > > > [Python] Fix "too many initializers for 'PyHeapTypeObject'" > errors > using PyPy 3.8 and later. > > > > but that is for PyPy not CPython. Try out master and if you still see the > tp_print warnings, please put together a small testcase to demonstrate. > > > > William > > > > On Tue, 24 May 2022 at 23:23, Langer, Stephen A. (Fed) < > ste...@ni...> wrote: > > Thanks for the response. Using the tp_repr slot did just what I needed. > > > > I still don't understand what's going on with the tp_print warnings, but > I'm content to ignore them if that's what's recommended. I am using swig > 4.0.2, so shouldn't it be compatible with python 3.8? > > > > -- Steve > > > > On 5/20/22, 4:45 PM, "William S Fulton" <ws...@fu...> wrote: > > > > 1. From the CHANGES file for swig-4.0.2: > > > > 2020-01-05: jschueller shadchin > [Python] #1670 #1696 Add missing field initializers introduced > in python 3.8: > tp_vectorcall and tp_print. > > > > 2. Customise using slots with the "python:tp_repr" feature, see > https://www.swig.org/Doc4.0/Python.html#Python_builtin_overloads > <https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.swig.org%2FDoc4.0%2FPython.html%23Python_builtin_overloads&data=05%7C01%7Cstephen.langer%40nist.gov%7C20da5d4baa634781d41708da40859886%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637893239791612972%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=EjXKcEltlUqhQfty2sojmo9wrTvfUIEv9cdDcj3BeEA%3D&reserved=0> > . > > > > William > > > > On Fri, 29 Apr 2022 at 22:13, Langer, Stephen A. (Fed) via Swig-user < > swi...@li...> wrote: > > Hi -- > > I'm beginning to use Swig 4 on a project. My previous experience was with > Swig 1.1, so I have some catching up to do. I'm generating python3 > wrappers for C++. > > The Swig web site says that Swig 4.0.1 added support for Python 3.8. When > I use Python 3.8, I get a lot of warnings that 'tp_print' is deprecated > when compiling the _wrap.cxx files (using cmake on a Mac). If I use Python > 3.10, I don't get the warnings. As far as I can tell, both versions work, > but I'm confused. Is 3.10 supported? It looks like it's supported better > than 3.8. Or is the lack of warnings in 3.10 misleading? > > My second question is how to override the default __repr__ for swigged > classes. With Swig 1.1 and Python 2.7, I could just monkey patch a new > __repr__ in the python wrapper for the class. With Swig 4, defining > __repr__ in C++ or monkey patching it works only if I don't use -builtin. > If I do use -builtin, then monkey patching is forbidden and __repr__ > defined in C++ is replaced by the generic SwigPyObject_repr. Is it > possible to redefine __repr__ for a swigged class when using -builtin? > > Thanks. > > -- Steve > > > > > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > <https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cstephen.langer%40nist.gov%7C20da5d4baa634781d41708da40859886%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637893239791612972%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rGX%2Bxyk2zvewkCw9jyTFwIdrpM9g%2B6JwCjjdL77fDKQ%3D&reserved=0> > > |
From: Langer, S. A. (Fed) <ste...@ni...> - 2022-05-31 15:24:02
|
Hi William -- I'm using an iMac running macOS Big Sur 11.6.6. All dependencies were installed with MacPorts. I just figured out that the problem doesn't occur on Ubuntu 20.04. I don't have access to other OS's. I've attached a swig file and a cmake file, and the output from running cmake and make, with both swig 4.0.2 and 4.1.0 (from github). The swig file just uses %inline to declare a simple function. The same warning appears in both cases. -- Steve On 5/28/22, 4:39 AM, "William S Fulton" <ws...@fu...<mailto:ws...@fu...>> wrote: For the pending 4.1.0 release we do have one change: [Python] Fix "too many initializers for 'PyHeapTypeObject'" errors using PyPy 3.8 and later. but that is for PyPy not CPython. Try out master and if you still see the tp_print warnings, please put together a small testcase to demonstrate. William On Tue, 24 May 2022 at 23:23, Langer, Stephen A. (Fed) <ste...@ni...<mailto:ste...@ni...>> wrote: Thanks for the response. Using the tp_repr slot did just what I needed. I still don't understand what's going on with the tp_print warnings, but I'm content to ignore them if that's what's recommended. I am using swig 4.0.2, so shouldn't it be compatible with python 3.8? -- Steve On 5/20/22, 4:45 PM, "William S Fulton" <ws...@fu...<mailto:ws...@fu...>> wrote: 1. From the CHANGES file for swig-4.0.2: 2020-01-05: jschueller shadchin [Python] #1670 #1696 Add missing field initializers introduced in python 3.8: tp_vectorcall and tp_print. 2. Customise using slots with the "python:tp_repr" feature, see https://www.swig.org/Doc4.0/Python.html#Python_builtin_overloads<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.swig.org%2FDoc4.0%2FPython.html%23Python_builtin_overloads&data=05%7C01%7Cstephen.langer%40nist.gov%7C20da5d4baa634781d41708da40859886%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637893239791612972%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=EjXKcEltlUqhQfty2sojmo9wrTvfUIEv9cdDcj3BeEA%3D&reserved=0>. William On Fri, 29 Apr 2022 at 22:13, Langer, Stephen A. (Fed) via Swig-user <swi...@li...<mailto:swi...@li...>> wrote: Hi -- I'm beginning to use Swig 4 on a project. My previous experience was with Swig 1.1, so I have some catching up to do. I'm generating python3 wrappers for C++. The Swig web site says that Swig 4.0.1 added support for Python 3.8. When I use Python 3.8, I get a lot of warnings that 'tp_print' is deprecated when compiling the _wrap.cxx files (using cmake on a Mac). If I use Python 3.10, I don't get the warnings. As far as I can tell, both versions work, but I'm confused. Is 3.10 supported? It looks like it's supported better than 3.8. Or is the lack of warnings in 3.10 misleading? My second question is how to override the default __repr__ for swigged classes. With Swig 1.1 and Python 2.7, I could just monkey patch a new __repr__ in the python wrapper for the class. With Swig 4, defining __repr__ in C++ or monkey patching it works only if I don't use -builtin. If I do use -builtin, then monkey patching is forbidden and __repr__ defined in C++ is replaced by the generic SwigPyObject_repr. Is it possible to redefine __repr__ for a swigged class when using -builtin? Thanks. -- Steve _______________________________________________ Swig-user mailing list Swi...@li...<mailto:Swi...@li...> https://lists.sourceforge.net/lists/listinfo/swig-user<https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cstephen.langer%40nist.gov%7C20da5d4baa634781d41708da40859886%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637893239791612972%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rGX%2Bxyk2zvewkCw9jyTFwIdrpM9g%2B6JwCjjdL77fDKQ%3D&reserved=0> |
From: William S F. <ws...@fu...> - 2022-05-28 09:32:24
|
For the pending 4.1.0 release we do have one change: [Python] Fix "too many initializers for 'PyHeapTypeObject'" errors using PyPy 3.8 and later. but that is for PyPy not CPython. Try out master and if you still see the tp_print warnings, please put together a small testcase to demonstrate. William On Tue, 24 May 2022 at 23:23, Langer, Stephen A. (Fed) < ste...@ni...> wrote: > Thanks for the response. Using the tp_repr slot did just what I needed. > > > > I still don't understand what's going on with the tp_print warnings, but > I'm content to ignore them if that's what's recommended. I am using swig > 4.0.2, so shouldn't it be compatible with python 3.8? > > > > -- Steve > > > > On 5/20/22, 4:45 PM, "William S Fulton" <ws...@fu...> wrote: > > > > 1. From the CHANGES file for swig-4.0.2: > > > > 2020-01-05: jschueller shadchin > [Python] #1670 #1696 Add missing field initializers introduced > in python 3.8: > tp_vectorcall and tp_print. > > > > 2. Customise using slots with the "python:tp_repr" feature, see > https://www.swig.org/Doc4.0/Python.html#Python_builtin_overloads > <https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.swig.org%2FDoc4.0%2FPython.html%23Python_builtin_overloads&data=05%7C01%7Cstephen.langer%40nist.gov%7C60f4a48441764770d09b08da3aa1b981%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637886763524648944%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=dL875F3VMpavP2MjFiObW3BkJwgHxz%2B9tKcncl6eArI%3D&reserved=0> > . > > > > William > > > > On Fri, 29 Apr 2022 at 22:13, Langer, Stephen A. (Fed) via Swig-user < > swi...@li...> wrote: > > Hi -- > > I'm beginning to use Swig 4 on a project. My previous experience was with > Swig 1.1, so I have some catching up to do. I'm generating python3 > wrappers for C++. > > The Swig web site says that Swig 4.0.1 added support for Python 3.8. When > I use Python 3.8, I get a lot of warnings that 'tp_print' is deprecated > when compiling the _wrap.cxx files (using cmake on a Mac). If I use Python > 3.10, I don't get the warnings. As far as I can tell, both versions work, > but I'm confused. Is 3.10 supported? It looks like it's supported better > than 3.8. Or is the lack of warnings in 3.10 misleading? > > My second question is how to override the default __repr__ for swigged > classes. With Swig 1.1 and Python 2.7, I could just monkey patch a new > __repr__ in the python wrapper for the class. With Swig 4, defining > __repr__ in C++ or monkey patching it works only if I don't use -builtin. > If I do use -builtin, then monkey patching is forbidden and __repr__ > defined in C++ is replaced by the generic SwigPyObject_repr. Is it > possible to redefine __repr__ for a swigged class when using -builtin? > > Thanks. > > -- Steve > > > > > _______________________________________________ > Swig-user mailing list > Swi...@li... > https://lists.sourceforge.net/lists/listinfo/swig-user > <https://gcc02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Fswig-user&data=05%7C01%7Cstephen.langer%40nist.gov%7C60f4a48441764770d09b08da3aa1b981%7C2ab5d82fd8fa4797a93e054655c61dec%7C1%7C0%7C637886763524648944%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C2000%7C%7C%7C&sdata=zJvXa0I0lTdzdT%2FUwDpfritk7JKUc7deFjQfrKBRmxY%3D&reserved=0> > > |
From: Langer, S. A. (Fed) <ste...@ni...> - 2022-05-25 21:11:52
|
Hi -- What's the best way to convert a vector of C++ objects to a list of built-in Python objects? When not using -builtin, I've been doing this: %{ typedef std::vector<SomeClass> Vec; %} %typemap(out) Vec* { Vec::size_type sz = $1->size(); $result = PyList_New((Py_ssize_t) sz); for(Vec::size_type i=0; i<sz; i++) { PyObject *tmp = SWIG_NewPointerObj(SWIG_as_voidptr((*$1)[i]), $descriptor(SomeClass*), SWIG_POINTER_OWN); PyList_SET_ITEM($result, (Py_ssize_t) I, tmp); } } That doesn’t work when using -builtin, because then the SWIG_NewPointerObj requires "self" to be defined. Thanks for any suggestions. -- Steve |