diff --git a/ANNOUNCE b/ANNOUNCE index 9ef41142a..7c0e95e3f 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,11 +1,11 @@ -*** ANNOUNCE: SWIG 1.3.40 (in progress) *** +*** ANNOUNCE: SWIG 1.3.36 (24 June 2008) *** http://www.swig.org -We're pleased to announce SWIG-1.3.40, the latest installment in the -SWIG development effort. SWIG-1.3.40 includes a number of bug fixes -and enhancements. +We're pleased to announce SWIG-1.3.36, the latest installment in the +SWIG development effort. SWIG-1.3.36 includes a number of bug fixes +and large number of enhancements throughout. What is SWIG? ------------- @@ -24,11 +24,21 @@ Availability: ------------- The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-1.3.40.tar.gz + http://prdownloads.sourceforge.net/swig/swig-1.3.36.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-1.3.40.zip + http://prdownloads.sourceforge.net/swig/swigwin-1.3.36.zip + +Release numbers +--------------- +With SWIG-1.3, we are adopting an odd/even version numbering scheme for +SWIG. Odd version numbers (1.3, 1.5, 1.7, etc...) are considered to +be development releases. Even numbers (1.4,1.6,1.8) are stable +releases. The current 1.3 effort is working to produce a stable 2.0 +release. A stable 2.0 release will not be made until it can +accompanied by fully updated documentation. In the meantime, we will +continue to make periodic 1.3.x releases. Please report problems with this release to the swig-dev mailing list, details at http://www.swig.org/mail.html. diff --git a/CCache/COPYING b/CCache/COPYING deleted file mode 100644 index a43ea2126..000000000 --- a/CCache/COPYING +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/CCache/Makefile.in b/CCache/Makefile.in deleted file mode 100644 index ec55ccaf5..000000000 --- a/CCache/Makefile.in +++ /dev/null @@ -1,73 +0,0 @@ -datarootdir = @datarootdir@ -srcdir=@srcdir@ -VPATH=@srcdir@ - -prefix=@prefix@ -exec_prefix=@exec_prefix@ -bindir=@bindir@ -mandir=@mandir@ -INSTALLCMD=@INSTALL@ -PACKAGE_NAME=@PACKAGE_NAME@ -# Soft link test can be skipped on systems that don't support soft linking -NOSOFTLINKSTEST= - -CC=@CC@ -CFLAGS=@CFLAGS@ -I. -SWIG=swig -SWIG_LIB=../../Lib -EXEEXT=@EXEEXT@ - -# Use standard autoconf approach to transform executable name using --program-prefix and --program-suffix -transform = @program_transform_name@ - -LIBS= @LIBS@ -OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \ - cleanup.o snprintf.o unify.o -HEADERS = ccache.h mdfour.h - -all: $(PACKAGE_NAME)$(EXEEXT) - -# Note that HTML documentation is actually generated and used from the main SWIG documentation Makefile -docs: $(PACKAGE_NAME).1 web/ccache-man.html - -$(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS) - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) - -$(PACKAGE_NAME).1: ccache.yo - -yodl2man -o $(PACKAGE_NAME).1 ccache.yo - -web/ccache-man.html: ccache.yo - mkdir -p man - yodl2html -o web/ccache-man.html ccache.yo - -install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1 - ${INSTALLCMD} -d $(DESTDIR)${bindir} - ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) - ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1 - ${INSTALLCMD} -m 644 ${srcdir}/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 - -uninstall: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1 - rm -f $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT) - rm -f $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1 - -clean: - /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT) - -clean-docs: - rm -f $(PACKAGE_NAME).1 web/ccache-man.html - -check : test - -test: test.sh - SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' ./test.sh - -check: test - -distclean: clean - /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h - -# FIXME: To fix this, test.sh needs to be able to take ccache from the -# installed prefix, not from the source dir. -installcheck: - @echo "WARNING! This is not really \"installcheck\" yet." - $(MAKE) check diff --git a/CCache/README b/CCache/README deleted file mode 100644 index 6e68a6eb0..000000000 --- a/CCache/README +++ /dev/null @@ -1,31 +0,0 @@ -This is a re-implementation of "compilercache" in C - -The original compilercache scripts were by Erik Thiele -(erikyyy@erikyyy.de) and I would like to thank him for an excellent -piece of work. See http://www.erikyyy.de/compilercache/ for the -original shell scripts. - -I wrote ccache because I wanted to get a bit more speed out of a -compiler cache and I wanted to remove some of the limitations of the -shell-script version. - -Please see the manual page and documentation at -http://ccache.samba.org/ - -INSTALLATION ------------- - -Please run: - - ./configure - make - make install - -then read the ccache manual page - ------------ - -Andrew Tridgell -http://samba.org/~tridge/ -bugs@ccache.samba.org - diff --git a/CCache/README.swig b/CCache/README.swig deleted file mode 100644 index aea0f3d82..000000000 --- a/CCache/README.swig +++ /dev/null @@ -1,8 +0,0 @@ -This directory contains a version of ccache. The initial version was based on ccache-2.4 plus -debian patches 01-02, 04-14, see the debian/patches subdirectory. The ccache-win32-2.4 modifications -to ccache-2.4 have also been merged in. - -Changes have been made to support cacheing the output from SWIG. The ability to cache c/c++ compiler -output has been retained. - -Additional features added are the CCACHE_VERBOSE and CCACHE_SWIG environment variables, see docs. diff --git a/CCache/args.c b/CCache/args.c deleted file mode 100644 index 31e5471c1..000000000 --- a/CCache/args.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - convenient routines for argument list handling - - Copyright (C) Andrew Tridgell 2002 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "ccache.h" - -ARGS *args_init(int init_argc, char **init_args) -{ - ARGS *args; - int i; - args = (ARGS *)x_malloc(sizeof(ARGS)); - args->argc = 0; - args->argv = (char **)x_malloc(sizeof(char *)); - args->argv[0] = NULL; - for (i=0;iargv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *)); - args->argv[args->argc] = x_strdup(s); - args->argc++; - args->argv[args->argc] = NULL; -} - -/* pop the last element off the args list */ -void args_pop(ARGS *args, int n) -{ - while (n--) { - args->argc--; - free(args->argv[args->argc]); - args->argv[args->argc] = NULL; - } -} - -/* remove the first element of the argument list */ -void args_remove_first(ARGS *args) -{ - free(args->argv[0]); - memmove(&args->argv[0], - &args->argv[1], - args->argc * sizeof(args->argv[0])); - args->argc--; -} - -/* add an argument into the front of the argument list */ -void args_add_prefix(ARGS *args, const char *s) -{ - args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *)); - memmove(&args->argv[1], &args->argv[0], - (args->argc+1) * sizeof(args->argv[0])); - args->argv[0] = x_strdup(s); - args->argc++; -} - -/* strip any arguments beginning with the specified prefix */ -void args_strip(ARGS *args, const char *prefix) -{ - int i; - for (i=0; iargc; ) { - if (strncmp(args->argv[i], prefix, strlen(prefix)) == 0) { - free(args->argv[i]); - memmove(&args->argv[i], - &args->argv[i+1], - args->argc * sizeof(args->argv[i])); - args->argc--; - } else { - i++; - } - } -} diff --git a/CCache/ccache.c b/CCache/ccache.c deleted file mode 100644 index d1696da88..000000000 --- a/CCache/ccache.c +++ /dev/null @@ -1,1388 +0,0 @@ -/* - a re-implementation of the compilercache scripts in C - - The idea is based on the shell-script compilercache by Erik Thiele - - Copyright (C) Andrew Tridgell 2002 - Copyright (C) Martin Pool 2003 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "ccache.h" - -/* verbose mode */ -int ccache_verbose = 0; - -/* the base cache directory */ -char *cache_dir = NULL; - -/* the directory for temporary files */ -static char *temp_dir = NULL; - -/* the debug logfile name, if set */ -char *cache_logfile = NULL; - -/* the argument list after processing */ -static ARGS *stripped_args; - -/* the original argument list */ -static ARGS *orig_args; - -/* the output filename being compiled to */ -static char *output_file; - -/* the source file */ -static char *input_file; - -/* the name of the file containing the cached object code */ -static char *hashname; - -/* the extension of the file after pre-processing */ -static const char *i_extension; - -/* the name of the temporary pre-processor file */ -static char *i_tmpfile; - -/* are we compiling a .i or .ii file directly? */ -static int direct_i_file; - -/* the name of the cpp stderr file */ -static char *cpp_stderr; - -/* the name of the statistics file */ -char *stats_file = NULL; - -/* can we safely use the unification hashing backend? */ -static int enable_unify; - -/* should we strip -c when running the preprocessor only? */ -static int strip_c_option; - -/* customisation for using the SWIG compiler */ -static int swig; - -/* a list of supported file extensions, and the equivalent - extension for code that has been through the pre-processor -*/ -static struct { - char *extension; - char *i_extension; -} extensions[] = { - {"c", "i"}, - {"C", "ii"}, - {"m", "mi"}, - {"cc", "ii"}, - {"CC", "ii"}, - {"cpp", "ii"}, - {"CPP", "ii"}, - {"cxx", "ii"}, - {"CXX", "ii"}, - {"c++", "ii"}, - {"C++", "ii"}, - {"i", "i"}, - {"ii", "ii"}, - {NULL, NULL}}; - -/* - something went badly wrong - just execute the real compiler -*/ -static void failed(void) -{ - char *e; - - /* delete intermediate pre-processor file if needed */ - if (i_tmpfile) { - if (!direct_i_file) { - unlink(i_tmpfile); - } - free(i_tmpfile); - i_tmpfile = NULL; - } - - /* delete the cpp stderr file if necessary */ - if (cpp_stderr) { - unlink(cpp_stderr); - free(cpp_stderr); - cpp_stderr = NULL; - } - - /* strip any local args */ - args_strip(orig_args, "--ccache-"); - - if ((e=getenv("CCACHE_PREFIX"))) { - char *p = find_executable(e, MYNAME); - if (!p) { - cc_log("could not find executable (%s)\n", e); - perror(e); - exit(1); - } - args_add_prefix(orig_args, p); - } - - if (ccache_verbose) { - display_execute_args(orig_args->argv); - } - - if (swig) { - putenv("CCACHE_OUTFILES"); - } - -#ifndef _WIN32 - execv(orig_args->argv[0], orig_args->argv); - cc_log("execv returned (%s)!\n", strerror(errno)); - perror(orig_args->argv[0]); - exit(1); -#else - /* execv on Windows causes the 'non-regular' testcase to fail, so use Win32 API instead */ - { - PROCESS_INFORMATION pinfo; - STARTUPINFO sinfo; - BOOL ret; - DWORD exitcode; - char *args; - - ZeroMemory(&pinfo, sizeof(PROCESS_INFORMATION)); - ZeroMemory(&sinfo, sizeof(STARTUPINFO)); - sinfo.cb = sizeof(STARTUPINFO); - args = argvtos(orig_args->argv); - ret = CreateProcessA(orig_args->argv[0], args, NULL, NULL, TRUE, 0, NULL, NULL, - &sinfo, &pinfo); - if (!ret) { - exitcode = 1; - cc_log("CreateProcessA failed starting %s\n", orig_args->argv[0]); - perror_win32(orig_args->argv[0]); - } else { - WaitForSingleObject(pinfo.hProcess, INFINITE); - GetExitCodeProcess(pinfo.hProcess, &exitcode); - CloseHandle(pinfo.hProcess); - CloseHandle(pinfo.hThread); - } - free(args); - exit(exitcode); - } -#endif -} - - -/* return a string to be used to distinguish temporary files - this also tries to cope with NFS by adding the local hostname -*/ -static const char *tmp_string(void) -{ - static char *ret; - - if (!ret) { - char hostname[200]; - strcpy(hostname, "unknown"); -#if HAVE_GETHOSTNAME - gethostname(hostname, sizeof(hostname)-1); -#endif - hostname[sizeof(hostname)-1] = 0; - if (asprintf(&ret, "%s.%u", hostname, (unsigned)getpid()) == -1) { - fatal("could not allocate tmp_string"); - } - } - - return ret; -} - -/* update cached file sizes and count helper function for to_cache() */ -static void to_cache_stats_helper(struct stat *pstat, char *cached_filename, char *tmp_outfiles, int *files_size, int *cached_files_count) -{ -#if ENABLE_ZLIB - /* do an extra stat on the cache file for the size statistics */ - if (stat(cached_filename, pstat) != 0) { - cc_log("failed to stat cache files - %s\n", strerror(errno)); - stats_update(STATS_ERROR); - if (tmp_outfiles) { - unlink(tmp_outfiles); - } - failed(); - } -#else - (void)cached_filename; - (void)tmp_outfiles; -#endif - (*files_size) += file_size(pstat); - (*cached_files_count)++; -} - -/* run the real compiler and put the result in cache */ -static void to_cache(ARGS *args) -{ - char *path_stderr; - char *tmp_stdout, *tmp_stderr, *tmp_outfiles; - struct stat st1; - int status; - int cached_files_count = 0; - int files_size = 0; - - x_asprintf(&tmp_stdout, "%s/tmp.stdout.%s", temp_dir, tmp_string()); - x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string()); - x_asprintf(&tmp_outfiles, "%s/tmp.outfiles.%s", temp_dir, tmp_string()); - - if (strip_c_option && !swig) { - args_add(stripped_args, "-c"); - } - - if (output_file) { - args_add(args, "-o"); - args_add(args, output_file); - } - - /* Turn off DEPENDENCIES_OUTPUT when running cc1, because - * otherwise it will emit a line like - * - * tmp.stdout.vexed.732.o: /home/mbp/.ccache/tmp.stdout.vexed.732.i - * - * unsetenv() is on BSD and Linux but not portable. */ - putenv("DEPENDENCIES_OUTPUT"); - - /* Give SWIG a filename for it to create and populate with a list of files that it generates */ - if (swig) { - char *ccache_outfiles; - x_asprintf(&ccache_outfiles, "CCACHE_OUTFILES=%s", tmp_outfiles); - unlink(tmp_outfiles); - if (getenv("CCACHE_OUTFILES") || putenv(ccache_outfiles) == -1) { - cc_log("CCACHE_OUTFILES env variable already set or could not be set\n"); - stats_update(STATS_ERROR); - failed(); - } - } - - if (getenv("CCACHE_CPP2")) { - args_add(args, input_file); - } else { - if (swig) { - args_add(args, "-nopreprocess"); - } - args_add(args, i_tmpfile); - } - status = execute(args->argv, tmp_stdout, tmp_stderr); - args_pop(args, 3); - - if (stat(tmp_stdout, &st1) != 0 || st1.st_size != 0) { - cc_log("compiler produced stdout for %s\n", input_file); - stats_update(STATS_STDOUT); - unlink(tmp_stdout); - unlink(tmp_stderr); - unlink(tmp_outfiles); - if (!swig) unlink(output_file); - failed(); - } - unlink(tmp_stdout); - - if (status != 0) { - int fd; - cc_log("compile of %s gave status = %d\n", input_file, status); - stats_update(STATS_STATUS); - - fd = open(tmp_stderr, O_RDONLY | O_BINARY); - if (fd != -1) { - if (cpp_stderr) { - /* we might have some stderr from cpp */ - int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); - if (fd2 != -1) { - copy_fd(fd2, 2); - close(fd2); - unlink(cpp_stderr); - cpp_stderr = NULL; - } - } - - /* we can use a quick method of - getting the failed output */ - copy_fd(fd, 2); - close(fd); - unlink(tmp_stderr); - if (i_tmpfile && !direct_i_file) { - unlink(i_tmpfile); - } - exit(status); - } - - unlink(tmp_stderr); - unlink(tmp_outfiles); - if (!swig) unlink(output_file); - failed(); - } else { - int hardlink = (getenv("CCACHE_NOCOMPRESS") != 0) && (getenv("CCACHE_HARDLINK") != 0); - if (swig) { - /* read the list of generated files and copy each of them into the cache */ - FILE *file; - file = fopen(tmp_outfiles, "r"); - if (file) { - char out_filename[FILENAME_MAX + 1]; - char out_filename_cache[FILENAME_MAX + 1]; - while (fgets(out_filename, FILENAME_MAX, file)) { - char *linefeed = strchr(out_filename, '\n'); - if (linefeed) { - char *potential_cr = linefeed - 1; - if (potential_cr >= out_filename && *potential_cr == '\r') - *potential_cr = 0; - *linefeed = 0; - - if (cached_files_count == 0) { - strcpy(out_filename_cache, hashname); - } else { - sprintf(out_filename_cache, "%s.%d", hashname, cached_files_count); - } - - if (commit_to_cache(out_filename, out_filename_cache, hardlink) != 0) { - fclose(file); - unlink(tmp_outfiles); - failed(); - } - to_cache_stats_helper(&st1, out_filename_cache, tmp_outfiles, &files_size, &cached_files_count); - } else { - cached_files_count = 0; - break; - } - } - fclose(file); - if (cached_files_count == 0) { - cc_log("failed to copy output files to cache - internal error\n"); - stats_update(STATS_ERROR); - unlink(tmp_outfiles); - failed(); - } - - /* also copy the (uncompressed) file containing the list of generated files into the cache */ - sprintf(out_filename_cache, "%s.outfiles", hashname); - if (stat(tmp_outfiles, &st1) != 0 || - safe_rename(tmp_outfiles, out_filename_cache) != 0) { - cc_log("failed to copy outfiles file to cache - %s\n", strerror(errno)); - stats_update(STATS_ERROR); - unlink(tmp_outfiles); - failed(); - } - to_cache_stats_helper(&st1, out_filename_cache, tmp_outfiles, &files_size, &cached_files_count); - unlink(tmp_outfiles); - } else { - cc_log("failed to open temp outfiles file - %s\n", strerror(errno)); - stats_update(STATS_ERROR); - failed(); - } - } else { - if (commit_to_cache(output_file, hashname, hardlink) != 0) { - failed(); - } - to_cache_stats_helper(&st1, hashname, 0, &files_size, &cached_files_count); - } - } - - x_asprintf(&path_stderr, "%s.stderr", hashname); - - if (stat(tmp_stderr, &st1) != 0 || - move_file(tmp_stderr, path_stderr) != 0) { - cc_log("failed to rename tmp files - %s\n", strerror(errno)); - stats_update(STATS_ERROR); - failed(); - } - - to_cache_stats_helper(&st1, path_stderr, 0, &files_size, &cached_files_count); - - cc_log("Placed %d files for %s into cache\n", cached_files_count, input_file); - stats_tocache(files_size, cached_files_count); - - free(tmp_stderr); - free(tmp_stdout); - free(tmp_outfiles); - free(path_stderr); -} - -/* find the hash for a command. The hash includes all argument lists, - plus the output from running the compiler with -E */ -static void find_hash(ARGS *args) -{ - int i; - char *path_stdout, *path_stderr; - char *hash_dir; - char *s; - struct stat st; - int status; - int nlevels = 2; - char *input_base; - char *tmp; - - if ((s = getenv("CCACHE_NLEVELS"))) { - nlevels = atoi(s); - if (nlevels < 1) nlevels = 1; - if (nlevels > 8) nlevels = 8; - } - - hash_start(); - - /* when we are doing the unifying tricks we need to include - the input file name in the hash to get the warnings right */ - if (enable_unify || swig) { - hash_string(input_file); - } - - if (swig) { - if (output_file) { - hash_string(output_file); - } - } else { - /* we have to hash the extension, as a .i file isn't treated the same - by the compiler as a .ii file */ - hash_string(i_extension); - } - - /* first the arguments */ - for (i=1;iargc;i++) { - /* some arguments don't contribute to the hash. The - theory is that these arguments will change the - output of -E if they are going to have any effect - at all, or they only affect linking */ - if (i < args->argc-1) { - if (strcmp(args->argv[i], "-I") == 0 || - strcmp(args->argv[i], "-include") == 0 || - strcmp(args->argv[i], "-L") == 0 || - strcmp(args->argv[i], "-D") == 0 || - strcmp(args->argv[i], "-idirafter") == 0 || - strcmp(args->argv[i], "-isystem") == 0) { - i++; - continue; - } - } - if (strncmp(args->argv[i], "-I", 2) == 0 || - strncmp(args->argv[i], "-L", 2) == 0 || - strncmp(args->argv[i], "-D", 2) == 0 || - strncmp(args->argv[i], "-idirafter", 10) == 0 || - strncmp(args->argv[i], "-isystem", 8) == 0) { - continue; - } - - if (strncmp(args->argv[i], "--specs=", 8) == 0 && - stat(args->argv[i]+8, &st) == 0) { - /* if given a explicit specs file, then hash that file, but - don't include the path to it in the hash */ - hash_file(args->argv[i]+8); - continue; - } - - /* all other arguments are included in the hash */ - hash_string(args->argv[i]); - } - - /* the compiler driver size and date. This is a simple minded way - to try and detect compiler upgrades. It is not 100% reliable */ - if (stat(args->argv[0], &st) != 0) { - cc_log("Couldn't stat the compiler!? (argv[0]='%s')\n", args->argv[0]); - stats_update(STATS_COMPILER); - failed(); - } - - /* also include the hash of the compiler name - as some compilers - use hard links and behave differently depending on the real name */ - if (st.st_nlink > 1) { - hash_string(str_basename(args->argv[0])); - } - - hash_int(st.st_size); - hash_int(st.st_mtime); - - /* possibly hash the current working directory */ - if (getenv("CCACHE_HASHDIR")) { - char *cwd = gnu_getcwd(); - if (cwd) { - hash_string(cwd); - free(cwd); - } - } - - /* ~/hello.c -> tmp.hello.123.i - limit the basename to 10 - characters in order to cope with filesystem with small - maximum filename length limits */ - input_base = str_basename(input_file); - tmp = strchr(input_base, '.'); - if (tmp != NULL) { - *tmp = 0; - } - if (strlen(input_base) > 10) { - input_base[10] = 0; - } - - /* now the run */ - x_asprintf(&path_stdout, "%s/%s.tmp.%s.%s", temp_dir, - input_base, tmp_string(), - i_extension); - x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string()); - - if (!direct_i_file) { - /* run cpp on the input file to obtain the .i */ - args_add(args, "-E"); - args_add(args, input_file); - status = execute(args->argv, path_stdout, path_stderr); - args_pop(args, 2); - } else { - /* we are compiling a .i or .ii file - that means we - can skip the cpp stage and directly form the - correct i_tmpfile */ - path_stdout = x_strdup(input_file); - if (create_empty_file(path_stderr) != 0) { - cc_log("failed to create empty stderr file\n"); - stats_update(STATS_ERROR); - failed(); - } - status = 0; - } - - if (status != 0) { - if (!direct_i_file) { - unlink(path_stdout); - } - unlink(path_stderr); - cc_log("the preprocessor gave %d\n", status); - stats_update(STATS_PREPROCESSOR); - failed(); - } - - /* if the compilation is with -g then we have to include the whole of the - preprocessor output, which means we are sensitive to line number - information. Otherwise we can discard line number info, which makes - us less sensitive to reformatting changes - - Note! I have now disabled the unification code by default - as it gives the wrong line numbers for warnings. Pity. - */ - if (!enable_unify) { - hash_file(path_stdout); - } else { - if (unify_hash(path_stdout) != 0) { - stats_update(STATS_ERROR); - failed(); - } - } - hash_file(path_stderr); - - i_tmpfile = path_stdout; - - if (!getenv("CCACHE_CPP2")) { - /* if we are using the CPP trick then we need to remember this stderr - data and output it just before the main stderr from the compiler - pass */ - cpp_stderr = path_stderr; - } else { - unlink(path_stderr); - free(path_stderr); - } - - /* we use a N level subdir for the cache path to reduce the impact - on filesystems which are slow for large directories - */ - s = hash_result(); - x_asprintf(&hash_dir, "%s/%c", cache_dir, s[0]); - x_asprintf(&stats_file, "%s/stats", hash_dir); - for (i=1; i= out_filename && *potential_cr == '\r') - *potential_cr = 0; - *linefeed = 0; - - if (retrieved_files_count == 0) { - strcpy(out_filename_cache, hashname); - } else { - sprintf(out_filename_cache, "%s.%d", hashname, retrieved_files_count); - } - - passfail = retrieve_from_cache(out_filename_cache, out_filename, hardlink); - if (passfail == -1) { - break; - } - - retrieved_files_count++; - } else { - cc_log("failed to copy output files from cache - internal error\n"); - stats_update(STATS_ERROR); - passfail = -1; - break; - } - } - if (retrieved_files_count == 0) { - cc_log("failed to copy output files from cache - internal error\n"); - stats_update(STATS_ERROR); - passfail = -1; - } - fclose(file); - } else { - cc_log("failed to open cached outfiles file - %s\n", strerror(errno)); - stats_update(STATS_ERROR); - } - } else { - passfail = retrieve_from_cache(hashname, output_file, hardlink); - } - - free(stderr_file); - if (passfail == -1) { - close(fd_stderr); - unlink(stderr_file); - return; - } - } - - /* get rid of the intermediate preprocessor file */ - if (i_tmpfile) { - if (!direct_i_file) { - unlink(i_tmpfile); - } - free(i_tmpfile); - i_tmpfile = NULL; - } - - /* send the cpp stderr, if applicable */ - fd_cpp_stderr = open(cpp_stderr, O_RDONLY | O_BINARY); - if (fd_cpp_stderr != -1) { - copy_fd(fd_cpp_stderr, 2); - close(fd_cpp_stderr); - unlink(cpp_stderr); - free(cpp_stderr); - cpp_stderr = NULL; - } - - /* send the stderr */ - copy_fd(fd_stderr, 2); - close(fd_stderr); - - /* and exit with the right status code */ - if (first) { - cc_log("got cached result for %s\n", input_file); - stats_update(STATS_CACHED); - } - - exit(0); -} - -/* find the real compiler. We just search the PATH to find a executable of the - same name that isn't a link to ourselves */ -static void find_compiler(int argc, char **argv) -{ - char *base; - char *path; - - orig_args = args_init(argc, argv); - - base = str_basename(argv[0]); - - /* we might be being invoked like "ccache gcc -c foo.c" */ - if (strcmp(base, MYNAME) == 0) { - args_remove_first(orig_args); - free(base); - if (strchr(argv[1],'/') -#ifdef _WIN32 - || strchr(argv[1],'\\') -#endif - ) { - /* a full path was given */ - return; - } - base = str_basename(argv[1]); - } - - /* support user override of the compiler */ - if ((path=getenv("CCACHE_CC"))) { - base = x_strdup(path); - } - - orig_args->argv[0] = find_executable(base, MYNAME); - - /* can't find the compiler! */ - if (!orig_args->argv[0]) { - stats_update(STATS_COMPILER); - cc_log("could not find compiler (%s)\n", base); - perror(base); - exit(1); - } -} - - -/* check a filename for C/C++ extension. Return the pre-processor - extension */ -static const char *check_extension(const char *fname, int *direct_i) -{ - int i; - const char *p; - - if (direct_i) { - *direct_i = 0; - } - - if (swig) return "ii"; /* any file extension is acceptable as input for SWIG */ - - p = strrchr(fname, '.'); - if (!p) return NULL; - p++; - for (i=0; extensions[i].extension; i++) { - if (strcmp(p, extensions[i].extension) == 0) { - if (direct_i && strcmp(p, extensions[i].i_extension) == 0) { - *direct_i = 1; - } - p = getenv("CCACHE_EXTENSION"); - if (p) return p; - return extensions[i].i_extension; - } - } - return NULL; -} - - -/* - process the compiler options to form the correct set of options - for obtaining the preprocessor output -*/ -static void process_args(int argc, char **argv) -{ - int i; - int found_c_opt = 0; - int found_S_opt = 0; - struct stat st; - char *e; - /* is gcc being asked to output dependencies? */ - int generating_dependencies = 0; - /* is the dependency makefile name overridden with -MF? */ - int dependency_filename_specified = 0; - /* is the dependency makefile target name specified with -MQ or -MF? */ - int dependency_target_specified = 0; - - - stripped_args = args_init(0, NULL); - - args_add(stripped_args, argv[0]); - - /* -c not required for SWIG */ - if (swig) { - found_c_opt = 1; - } - - for (i=1; iargv[0]); - if (strstr(basename, "swig") || getenv("CCACHE_SWIG")) { - swig = 1; - } - free(basename); -} - -/* the main ccache driver function */ -static void ccache(int argc, char *argv[]) -{ - /* find the real compiler */ - find_compiler(argc, argv); - - /* use the real compiler if HOME is not set */ - if (!cache_dir) { - cc_log("Unable to determine home directory\n"); - cc_log("ccache is disabled\n"); - failed(); - } - - /* we might be disabled */ - if (getenv("CCACHE_DISABLE")) { - cc_log("ccache is disabled\n"); - failed(); - } - - if (getenv("CCACHE_STRIPC")) { - strip_c_option = 1; - } - - if (getenv("CCACHE_UNIFY")) { - enable_unify = 1; - } - - detect_swig(); - - /* process argument list, returning a new set of arguments for pre-processing */ - process_args(orig_args->argc, orig_args->argv); - - /* run with -E to find the hash */ - find_hash(stripped_args); - - /* if we can return from cache at this point then do */ - from_cache(1); - - if (getenv("CCACHE_READONLY")) { - cc_log("read-only set - doing real compile\n"); - failed(); - } - - /* run real compiler, sending output to cache */ - to_cache(stripped_args); - - /* return from cache */ - from_cache(0); - - /* oh oh! */ - cc_log("secondary from_cache failed!\n"); - stats_update(STATS_ERROR); - failed(); -} - - -static void usage(void) -{ - printf("%s, a compiler cache including support for SWIG. Version %s\n", MYNAME, CCACHE_VERSION); - printf("Copyright Andrew Tridgell, 2002\n\n"); - - printf("Usage:\n"); - printf("\t" MYNAME " [options]\n"); - printf("\t" MYNAME " compiler [compile options]\n"); - printf("\tcompiler [compile options] (via symbolic link)\n"); - printf("\nOptions:\n"); - - printf("-s show statistics summary\n"); - printf("-z zero statistics\n"); - printf("-c run a cache cleanup\n"); - printf("-C clear the cache completely\n"); - printf("-F set maximum files in cache\n"); - printf("-M set maximum size of cache (use G, M or K)\n"); - printf("-h this help page\n"); - printf("-V print version number\n"); -} - -static void check_cache_dir(void) -{ - if (!cache_dir) { - fatal("Unable to determine home directory"); - } -} - -/* the main program when not doing a compile */ -static int ccache_main(int argc, char *argv[]) -{ - int c; - size_t v; - - while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) { - switch (c) { - case 'V': - printf("%s version %s\n", MYNAME, CCACHE_VERSION); - printf("Copyright Andrew Tridgell 2002\n"); - printf("Released under the GNU GPL v2 or later\n"); - exit(0); - - case 'h': - usage(); - exit(0); - - case 's': - check_cache_dir(); - stats_summary(); - break; - - case 'c': - check_cache_dir(); - cleanup_all(cache_dir); - printf("Cleaned cache\n"); - break; - - case 'C': - check_cache_dir(); - wipe_all(cache_dir); - printf("Cleared cache\n"); - break; - - case 'z': - check_cache_dir(); - stats_zero(); - printf("Statistics cleared\n"); - break; - - case 'F': - check_cache_dir(); - v = atoi(optarg); - if (stats_set_limits(v, -1) == 0) { - printf("Set cache file limit to %u\n", (unsigned)v); - } else { - printf("Could not set cache file limit.\n"); - exit(1); - } - break; - - case 'M': - check_cache_dir(); - v = value_units(optarg); - if (stats_set_limits(-1, v) == 0) { - printf("Set cache size limit to %uk\n", (unsigned)v); - } else { - printf("Could not set cache size limit.\n"); - exit(1); - } - break; - - default: - usage(); - exit(1); - } - } - - return 0; -} - - -/* Make a copy of stderr that will not be cached, so things like - distcc can send networking errors to it. */ -static void setup_uncached_err(void) -{ - char *buf; - int uncached_fd; - - uncached_fd = dup(2); - if (uncached_fd == -1) { - cc_log("dup(2) failed\n"); - stats_update(STATS_ERROR); - failed(); - } - - /* leak a pointer to the environment */ - x_asprintf(&buf, "UNCACHED_ERR_FD=%d", uncached_fd); - - if (putenv(buf) == -1) { - cc_log("putenv failed\n"); - stats_update(STATS_ERROR); - failed(); - } -} - - -int main(int argc, char *argv[]) -{ - char *p; - - cache_dir = getenv("CCACHE_DIR"); - if (!cache_dir) { - const char *home_directory = get_home_directory(); - if (home_directory) { - x_asprintf(&cache_dir, "%s/.ccache", home_directory); - } - } - - cache_logfile = getenv("CCACHE_LOGFILE"); - - if (getenv("CCACHE_VERBOSE")) { - ccache_verbose = 1; - } - - setup_uncached_err(); - - - /* the user might have set CCACHE_UMASK */ - p = getenv("CCACHE_UMASK"); - if (p) { - mode_t mask; - errno = 0; - mask = strtol(p, NULL, 8); - if (errno == 0) { - umask(mask); - } - } - - - /* check if we are being invoked as "ccache" */ - if (strlen(argv[0]) >= strlen(MYNAME) && - strcmp(argv[0] + strlen(argv[0]) - strlen(MYNAME), MYNAME) == 0) { - if (argc < 2) { - usage(); - exit(1); - } - /* if the first argument isn't an option, then assume we are - being passed a compiler name and options */ - if (argv[1][0] == '-') { - return ccache_main(argc, argv); - } - } - - /* make sure the cache dir exists */ - if (cache_dir && (create_dir(cache_dir) != 0)) { - fprintf(stderr,"ccache: failed to create %s (%s)\n", - cache_dir, strerror(errno)); - exit(1); - } - - temp_dir = getenv("CCACHE_TEMPDIR"); - if (!temp_dir) { - x_asprintf(&temp_dir, "%s/temp", cache_dir); - /* make sure temp dir exists if not supplied by user */ - if (temp_dir && create_dir(temp_dir) != 0) { - fprintf(stderr,"ccache: failed to create %s (%s)\n", - temp_dir, strerror(errno)); - exit(1); - } - } - - if (!getenv("CCACHE_READONLY")) { - if (create_cachedirtag(cache_dir) != 0) { - fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n", - cache_dir, strerror(errno)); - exit(1); - } - } - - ccache(argc, argv); - return 1; -} diff --git a/CCache/ccache.h b/CCache/ccache.h deleted file mode 100644 index 668ce8288..000000000 --- a/CCache/ccache.h +++ /dev/null @@ -1,205 +0,0 @@ -#include "ccache_swig_config.h" - -#define CCACHE_VERSION SWIG_VERSION - -#ifndef _WIN32 -#include "config.h" -#else -#include -#define PACKAGE_NAME "ccache-swig.exe" -#endif - -#include -#include -#include -#include -#include -#include - -#ifndef _WIN32 - #include - #include -#else -#define _WIN32_WINNT 0x0500 - #include - #include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef HAVE_PWD_H -#include -#endif -#ifdef HAVE_SYS_TIME_H -#include -#endif - -#ifdef ENABLE_ZLIB -#include -#endif - -#define STATUS_NOTFOUND 3 -#define STATUS_FATAL 4 -#define STATUS_NOCACHE 5 - -#define MYNAME PACKAGE_NAME - -#define LIMIT_MULTIPLE 0.8 - -/* default maximum cache size */ -#ifndef DEFAULT_MAXSIZE -#define DEFAULT_MAXSIZE (1000*1000) -#endif - -/* file copy mode */ -#ifdef ENABLE_ZLIB -#define COPY_UNCOMPRESSED 0 -#define COPY_FROM_CACHE 1 -#define COPY_TO_CACHE 2 -#endif - -enum stats { - STATS_NONE=0, - STATS_STDOUT, - STATS_STATUS, - STATS_ERROR, - STATS_TOCACHE, - STATS_PREPROCESSOR, - STATS_COMPILER, - STATS_MISSING, - STATS_CACHED, - STATS_ARGS, - STATS_LINK, - STATS_NUMFILES, - STATS_TOTALSIZE, - STATS_MAXFILES, - STATS_MAXSIZE, - STATS_NOTC, - STATS_DEVICE, - STATS_NOINPUT, - STATS_ENVIRONMMENT, - STATS_MULTIPLE, - STATS_CONFTEST, - STATS_UNSUPPORTED, - STATS_OUTSTDOUT, - - STATS_END -}; - -typedef unsigned uint32; - -#include "mdfour.h" - -void hash_start(void); -void hash_string(const char *s); -void hash_int(int x); -void hash_file(const char *fname); -char *hash_result(void); -void hash_buffer(const char *s, int len); - -void cc_log(const char *format, ...); -void fatal(const char *msg); - -void copy_fd(int fd_in, int fd_out); -int safe_rename(const char* oldpath, const char* newpath); -int move_file(const char *src, const char *dest); -int test_if_compressed(const char *filename); - -int commit_to_cache(const char *src, const char *dest, int hardlink); -int retrieve_from_cache(const char *src, const char *dest, int hardlink); - -int create_dir(const char *dir); -int create_cachedirtag(const char *dir); -void x_asprintf(char **ptr, const char *format, ...); -char *x_strdup(const char *s); -void *x_realloc(void *ptr, size_t size); -void *x_malloc(size_t size); -void traverse(const char *dir, void (*fn)(const char *, struct stat *)); -char *str_basename(const char *s); -char *dirname(char *s); -int lock_fd(int fd); -size_t file_size(struct stat *st); -int safe_open(const char *fname); -char *x_realpath(const char *path); -char *gnu_getcwd(void); -int create_empty_file(const char *fname); -const char *get_home_directory(void); -int x_utimes(const char *filename); -#ifdef _WIN32 -void perror_win32(LPTSTR pszFunction); -#endif - -void stats_update(enum stats stat); -void stats_zero(void); -void stats_summary(void); -void stats_tocache(size_t size, size_t numfiles); -void stats_read(const char *stats_file, unsigned counters[STATS_END]); -int stats_set_limits(long maxfiles, long maxsize); -size_t value_units(const char *s); -void display_size(unsigned v); -void stats_set_sizes(const char *dir, size_t num_files, size_t total_size); - -int unify_hash(const char *fname); - -#ifndef HAVE_VASPRINTF -int vasprintf(char **, const char *, va_list ); -#endif -#ifndef HAVE_ASPRINTF -int asprintf(char **ptr, const char *format, ...); -#endif - -#ifndef HAVE_SNPRINTF -int snprintf(char *,size_t ,const char *, ...); -#endif - -void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize); -void cleanup_all(const char *dir); -void wipe_all(const char *dir); - -#ifdef _WIN32 -char *argvtos(char **argv); -#endif -int execute(char **argv, - const char *path_stdout, - const char *path_stderr); -char *find_executable(const char *name, const char *exclude_name); -void display_execute_args(char **argv); - -typedef struct { - char **argv; - int argc; -} ARGS; - - -ARGS *args_init(int , char **); -void args_add(ARGS *args, const char *s); -void args_add_prefix(ARGS *args, const char *s); -void args_pop(ARGS *args, int n); -void args_strip(ARGS *args, const char *prefix); -void args_remove_first(ARGS *args); - -extern int ccache_verbose; - -#if HAVE_COMPAR_FN_T -#define COMPAR_FN_T __compar_fn_t -#else -typedef int (*COMPAR_FN_T)(const void *, const void *); -#endif - -/* work with silly DOS binary open */ -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -/* mkstemp() on some versions of cygwin don't handle binary files, so - override */ -#ifdef __CYGWIN__ -#undef HAVE_MKSTEMP -#endif diff --git a/CCache/ccache.yo b/CCache/ccache.yo deleted file mode 100644 index 2477662dc..000000000 --- a/CCache/ccache.yo +++ /dev/null @@ -1,422 +0,0 @@ -whenman( -COMMENT(html output not great if included when using html2doc) -manpage(ccache-swig)(1)()()() -) - -whenhtml(htmlcommand( - - - - -ccache-swig(1) manpage - - - - -

Using SWIG with ccache - ccache-swig(1) manpage

- -
- - -)) - - -manpagename(ccache-swig)(a fast compiler cache) - -whenhtml(htmlcommand( -ccache-swig - a fast compiler cache -)) - -manpagesynopsis() - -ccache-swig [OPTION] - -ccache-swig [COMPILER OPTIONS] - - [COMPILER OPTIONS] - -manpagedescription() - -ccache-swig is a compiler cache. It speeds up re-compilation of C/C++/SWIG code -by caching previous compiles and detecting when the same compile is -being done again. ccache-swig is ccache plus support for SWIG. ccache -and ccache-swig are used interchangeably in this document. - -manpagesection(OPTIONS SUMMARY) - -Here is a summary of the options to ccache-swig. - -verb( --s show statistics summary --z zero statistics --c run a cache cleanup --C clear the cache completely --F set maximum files in cache --M set maximum size of cache (use G, M or K) --h this help page --V print version number -) - -manpageoptions() - -These options only apply when you invoke ccache as "ccache-swig". When -invoked as a compiler none of these options apply. In that case your -normal compiler options apply and you should refer to your compilers -documentation. - -startdit() -dit(bf(-h)) Print a options summary page - -dit(bf(-s)) Print the current statistics summary for the cache. The -statistics are stored spread across the subdirectories of the -cache. Using "ccache-swig -s" adds up the statistics across all -subdirectories and prints the totals. - -dit(bf(-z)) Zero the cache statistics. - -dit(bf(-V)) Print the ccache version number - -dit(bf(-c)) Clean the cache and re-calculate the cache file count and -size totals. Normally the -c option should not be necessary as ccache -keeps the cache below the specified limits at runtime and keeps -statistics up to date on each compile. This option is mostly useful -if you manually modify the cache contents or believe that the cache -size statistics may be inaccurate. - -dit(bf(-C)) Clear the entire cache, removing all cached files. - -dit(bf(-F )) This sets the maximum number of files allowed in -the cache. The value is stored inside the cache directory and applies -to all future compiles. Due to the way the value is stored the actual -value used is always rounded down to the nearest multiple of 16. - -dit(bf(-M )) This sets the maximum cache size. You can specify -a value in gigabytes, megabytes or kilobytes by appending a G, M or K -to the value. The default is gigabytes. The actual value stored is -rounded down to the nearest multiple of 16 kilobytes. - -enddit() - -manpagesection(INSTALLATION) - -There are two ways to use ccache. You can either prefix your compile -commands with "ccache-swig" or you can create a symbolic link between -ccache-swig and the names of your compilers. The first method is most -convenient if you just want to try out ccache or wish to use it for -some specific projects. The second method is most useful for when you -wish to use ccache for all your compiles. - -To install for usage by the first method just copy ccache-swig to somewhere -in your path. - -To install for the second method do something like this: -verb( - cp ccache-swig /usr/local/bin/ - ln -s /usr/local/bin/ccache-swig /usr/local/bin/gcc - ln -s /usr/local/bin/ccache-swig /usr/local/bin/g++ - ln -s /usr/local/bin/ccache-swig /usr/local/bin/cc - ln -s /usr/local/bin/ccache-swig /usr/local/bin/swig -) -This will work as long as /usr/local/bin comes before the path to gcc -(which is usually in /usr/bin). After installing you may wish to run -"which gcc" to make sure that the correct link is being used. - -Note! Do not use a hard link, use a symbolic link. A hardlink will -cause "interesting" problems. - -manpagesection(EXTRA OPTIONS) - -When run as a compiler front end ccache usually just takes the same -command line options as the compiler you are using. The only exception -to this is the option '--ccache-skip'. That option can be used to tell -ccache that the next option is definitely not a input filename, and -should be passed along to the compiler as-is. - -The reason this can be important is that ccache does need to parse the -command line and determine what is an input filename and what is a -compiler option, as it needs the input filename to determine the name -of the resulting object file (among other things). The heuristic -ccache uses in this parse is that any string on the command line that -exists as a file is treated as an input file name (usually a C -file). By using --ccache-skip you can force an option to not be -treated as an input file name and instead be passed along to the -compiler as a command line option. - -manpagesection(ENVIRONMENT VARIABLES) - -ccache uses a number of environment variables to control operation. In -most cases you won't need any of these as the defaults will be fine. - -startdit() - -dit(bf(CCACHE_DIR)) the CCACHE_DIR environment variable specifies -where ccache will keep its cached compiler output. The default is -"$HOME/.ccache". - -dit(bf(CCACHE_TEMPDIR)) the CCACHE_TEMPDIR environment variable specifies -where ccache will put temporary files. The default is the same as -CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same -filesystem as the CCACHE_DIR path, so that renames of files between -the two directories can work. - -dit(bf(CCACHE_LOGFILE)) If you set the CCACHE_LOGFILE environment -variable then ccache will write some log information on cache hits -and misses in that file. This is useful for tracking down problems. - -dit(bf(CCACHE_VERBOSE)) If you set the CCACHE_VERBOSE environment -variable then ccache will display on stdout all the compiler invocations -that it makes. This can useful for debugging unexpected problems. - -dit(bf(CCACHE_PATH)) You can optionally set CCACHE_PATH to a colon -separated path where ccache will look for the real compilers. If you -don't do this then ccache will look for the first executable matching -the compiler name in the normal PATH that isn't a symbolic link to -ccache itself. - -dit(bf(CCACHE_CC)) You can optionally set CCACHE_CC to force the name -of the compiler to use. If you don't do this then ccache works it out -from the command line. - -dit(bf(CCACHE_PREFIX)) This option adds a prefix to the command line -that ccache runs when invoking the compiler. Also see the section -below on using ccache with distcc. - -dit(bf(CCACHE_DISABLE)) If you set the environment variable -CCACHE_DISABLE then ccache will just call the real compiler, -bypassing the cache completely. - -dit(bf(CCACHE_READONLY)) the CCACHE_READONLY environment variable -tells ccache to attempt to use existing cached object files, but not -to try to add anything new to the cache. If you are using this because -your CCACHE_DIR is read-only, then you may find that you also need to -set CCACHE_TEMPDIR as otherwise ccache will fail to create the -temporary files. - -dit(bf(CCACHE_CPP2)) If you set the environment variable CCACHE_CPP2 -then ccache will not use the optimisation of avoiding the 2nd call to -the pre-processor by compiling the pre-processed output that was used -for finding the hash in the case of a cache miss. This is primarily a -debugging option, although it is possible that some unusual compilers -will have problems with the intermediate filename extensions used in -this optimisation, in which case this option could allow ccache to be -used. - -dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable -CCACHE_NOCOMPRESS then there is no compression used on files that go -into the cache. However, this setting has no effect on how files are -retrieved from the cache, compressed results will still be usable. - -dit(bf(CCACHE_NOSTATS)) If you set the environment variable -CCACHE_NOSTATS then ccache will not update the statistics files on -each compile. - -dit(bf(CCACHE_NLEVELS)) The environment variable CCACHE_NLEVELS allows -you to choose the number of levels of hash in the cache directory. The -default is 2. The minimum is 1 and the maximum is 8. - -dit(bf(CCACHE_HARDLINK)) If you set the environment variable -CCACHE_HARDLINK then ccache will attempt to use hard links from the -cache directory when creating the compiler output rather than using a -file copy. Using hard links is faster, but can confuse programs like -'make' that rely on modification times. Hard links are never made for -compressed cache files. - -dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached -results, even if it finds them. New results are still cached, but -existing cache entries are ignored. - -dit(bf(CCACHE_UMASK)) This sets the umask for ccache and all child -processes (such as the compiler). This is mostly useful when you wish -to share your cache with other users. Note that this also affects the -file permissions set on the object files created from your -compilations. - -dit(bf(CCACHE_HASHDIR)) This tells ccache to hash the current working -directory when calculating the hash that is used to distinguish two -compiles. This prevents a problem with the storage of the current -working directory in the debug info of a object file, which can lead -ccache to give a cached object file that has the working directory in -the debug info set incorrectly. This option is off by default as the -incorrect setting of this debug info rarely causes problems. If you -strike problems with gdb not using the correct directory then enable -this option. - -dit(bf(CCACHE_UNIFY)) If you set the environment variable CCACHE_UNIFY -then ccache will use the C/C++ unifier when hashing the pre-processor -output if -g is not used in the compile. The unifier is slower than a -normal hash, so setting this environment variable loses a little bit -of speed, but it means that ccache can take advantage of not -recompiling when the changes to the source code consist of -reformatting only. Note that using CCACHE_UNIFY changes the hash, so -cached compiles with CCACHE_UNIFY set cannot be used when -CCACHE_UNIFY is not set and vice versa. The reason the unifier is off -by default is that it can give incorrect line number information in -compiler warning messages. - -dit(bf(CCACHE_EXTENSION)) Normally ccache tries to automatically -determine the extension to use for intermediate C pre-processor files -based on the type of file being compiled. Unfortunately this sometimes -doesn't work, for example when using the aCC compiler on HP-UX. On -systems like this you can use the CCACHE_EXTENSION option to override -the default. On HP-UX set this environment variable to "i" if you use -the aCC compiler. - -dit(bf(CCACHE_STRIPC)) If you set the environment variable -CCACHE_STRIPC then ccache will strip the -c option when invoking -the preprocessor. This option is primarily for the Sun Workshop -C++ compiler as without this option an unwarranted warning is displayed: -CC: Warning: "-E" redefines product from "object" to "source (stdout)" -when -E and -c is used together. - -dit(bf(CCACHE_SWIG)) When using SWIG as the compiler and it does not -have 'swig' in the executable name, then the CCACHE_SWIG environment -variable needs to be set in order for ccache to work correctly with -SWIG. The use of CCACHE_CPP2 is also recommended for SWIG due to some -preprocessor quirks, however, use of CCACHE_CPP2 can often be skipped --- check your generated code with and without this option set. Known -problems are using preprocessor directives within %inline blocks and -the use of '#pragma SWIG'. - -enddit() - -manpagesection(CACHE SIZE MANAGEMENT) - -By default ccache has a one gigabyte limit on the cache size and no -maximum number of files. You can set a different limit using the -"ccache -M" and "ccache -F" options, which set the size and number of -files limits. - -When these limits are reached ccache will reduce the cache to 20% -below the numbers you specified in order to avoid doing the cache -clean operation too often. - -manpagesection(CACHE COMPRESSION) - -By default on most platforms ccache will compress all files it puts -into the cache -using the zlib compression. While this involves a negligible -performance slowdown, it significantly increases the number of files -that fit in the cache. You can turn off compression setting the -CCACHE_NOCOMPRESS environment variable. - -manpagesection(HOW IT WORKS) - -The basic idea is to detect when you are compiling exactly the same -code a 2nd time and use the previously compiled output. You detect -that it is the same code by forming a hash of: - -itemization( - it() the pre-processor output from running the compiler with -E - it() the command line options - it() the real compilers size and modification time - it() any stderr output generated by the compiler -) - -These are hashed using md4 (a strong hash) and a cache file is formed -based on that hash result. When the same compilation is done a second -time ccache is able to supply the correct compiler output (including -all warnings etc) from the cache. - -ccache has been carefully written to always produce exactly the same -compiler output that you would get without the cache. If you ever -discover a case where ccache changes the output of your compiler then -please let me know. - -manpagesection(USING CCACHE WITH DISTCC) - -distcc is a very useful program for distributing compilation across a -range of compiler servers. It is often useful to combine distcc with -ccache, so that compiles that are done are sped up by distcc, but that -ccache avoids the compile completely where possible. - -To use distcc with ccache I recommend using the CCACHE_PREFIX -option. You just need to set the environment variable CCACHE_PREFIX to -'distcc' and ccache will prefix the command line used with the -compiler with the command 'distcc'. - -manpagesection(SHARING A CACHE) - -A group of developers can increase the cache hit rate by sharing a -cache directory. The hard links however cause unwanted side effects, -as all links to a cached file share the file's modification timestamp. -This results in false dependencies to be triggered by timestamp-based -build systems whenever another user links to an existing -file. Typically, users will see that their libraries and binaries are -relinked without reason. To share a cache without side effects, the -following conditions need to be met: - -itemization( - it() Use the same bf(CCACHE_DIR) environment variable setting - it() Unset the bf(CCACHE_HARDLINK) environment variable - it() Make sure everyone sets the CCACHE_UMASK environment variable - to 002, this ensures that cached files are accessible to everyone in - the group. - it() Make sure that all users have write permission in the entire - cache directory (and that you trust all users of the shared cache). - it() Make sure that the setgid bit is set on all directories in the - cache. This tells the filesystem to inherit group ownership for new - directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might - be useful for this. - it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with - versions of ccache that do not support compression. -) - -manpagesection(HISTORY) - -ccache was inspired by the compilercache shell script script written -by Erik Thiele and I would like to thank him for an excellent piece of -work. See -url(http://www.erikyyy.de/compilercache/)(http://www.erikyyy.de/compilercache/) -for the Erik's scripts. -ccache-swig is a port of the original ccache with support added for use -with SWIG. - -I wrote ccache because I wanted to get a bit more speed out of a -compiler cache and I wanted to remove some of the limitations of the -shell-script version. - -manpagesection(DIFFERENCES FROM COMPILERCACHE) - -The biggest differences between Erik's compilercache script and ccache -are: -itemization( -it() ccache is written in C, which makes it a bit faster (calling out to - external programs is mostly what slowed down the scripts). -it() ccache can automatically find the real compiler -it() ccache keeps statistics on hits/misses -it() ccache can do automatic cache management -it() ccache can cache compiler output that includes warnings. In many - cases this gives ccache a much higher cache hit rate. -it() ccache can handle a much wider ranger of compiler options -it() ccache avoids a double call to cpp on a cache miss -) - -manpagesection(CREDITS) - -Thanks to the following people for their contributions to ccache -itemization( - it() Erik Thiele for the original compilercache script - it() Luciano Rocha for the idea of compiling the pre-processor output - to avoid a 2nd cpp pass - it() Paul Russell for many suggestions and the debian packaging -) - -manpageauthor() - -ccache was written by Andrew Tridgell -url(http://samba.org/~tridge/)(http://samba.org/~tridge/). -ccache was adapted to create ccache-swig for use with SWIG by William Fulton. - -If you wish to report a problem or make a suggestion then please email -the SWIG developers on the swig-devel mailing list, see -url(http://www.swig.org/mail.html)(http://www.swig.org/mail.html) - -ccache is released under the GNU General Public License version 2 or -later. Please see the file COPYING for license details. - -whenhtml(htmlcommand( - - - - -)) diff --git a/CCache/ccache_swig_config.h.in b/CCache/ccache_swig_config.h.in deleted file mode 100644 index bbb205f77..000000000 --- a/CCache/ccache_swig_config.h.in +++ /dev/null @@ -1 +0,0 @@ -#define SWIG_VERSION "@PACKAGE_VERSION@" diff --git a/CCache/cleanup.c b/CCache/cleanup.c deleted file mode 100644 index 99312283e..000000000 --- a/CCache/cleanup.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - Copyright (C) Andrew Tridgell 2002 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -/* - functions to cleanup the cache directory when it gets too large - */ - -#include "ccache.h" - -static struct files { - char *fname; - time_t mtime; - size_t size; -} **files; -static unsigned allocated; -static unsigned num_files; -static size_t total_size; -static size_t total_files; -static size_t size_threshold; -static size_t files_threshold; - -/* file comparison function to try to delete the oldest files first */ -static int files_compare(struct files **f1, struct files **f2) -{ - if ((*f2)->mtime == (*f1)->mtime) { - return strcmp((*f2)->fname, (*f1)->fname); - } - if ((*f2)->mtime > (*f1)->mtime) { - return -1; - } - return 1; -} - -/* this builds the list of files in the cache */ -static void traverse_fn(const char *fname, struct stat *st) -{ - char *p; - - if (!S_ISREG(st->st_mode)) return; - - p = str_basename(fname); - if (strcmp(p, "stats") == 0) { - free(p); - return; - } - free(p); - - if (num_files == allocated) { - allocated = 10000 + num_files*2; - files = (struct files **)x_realloc(files, - sizeof(struct files *)*allocated); - } - - files[num_files] = (struct files *)x_malloc(sizeof(struct files)); - files[num_files]->fname = x_strdup(fname); - files[num_files]->mtime = st->st_mtime; - files[num_files]->size = file_size(st) / 1024; - total_size += files[num_files]->size; - num_files++; -} - -/* sort the files we've found and delete the oldest ones until we are - below the thresholds */ -static void sort_and_clean(void) -{ - unsigned i; - - if (num_files > 1) { - /* sort in ascending data order */ - qsort(files, num_files, sizeof(struct files *), - (COMPAR_FN_T)files_compare); - } - - /* delete enough files to bring us below the threshold */ - for (i=0;ifname) != 0 && errno != ENOENT) { - fprintf(stderr, "unlink %s - %s\n", - files[i]->fname, strerror(errno)); - continue; - } - - total_size -= files[i]->size; - } - - total_files = num_files - i; -} - -/* cleanup in one cache subdir */ -void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize) -{ - unsigned i; - - size_threshold = maxsize * LIMIT_MULTIPLE; - files_threshold = maxfiles * LIMIT_MULTIPLE; - - num_files = 0; - total_size = 0; - - /* build a list of files */ - traverse(dir, traverse_fn); - - /* clean the cache */ - sort_and_clean(); - - stats_set_sizes(dir, total_files, total_size); - - /* free it up */ - for (i=0;ifname); - free(files[i]); - files[i] = NULL; - } - if (files) free(files); - allocated = 0; - files = NULL; - - num_files = 0; - total_size = 0; -} - -/* cleanup in all cache subdirs */ -void cleanup_all(const char *dir) -{ - unsigned counters[STATS_END]; - char *dname, *sfile; - int i; - - for (i=0;i<=0xF;i++) { - x_asprintf(&dname, "%s/%1x", dir, i); - x_asprintf(&sfile, "%s/%1x/stats", dir, i); - - memset(counters, 0, sizeof(counters)); - stats_read(sfile, counters); - - cleanup_dir(dname, - counters[STATS_MAXFILES], - counters[STATS_MAXSIZE]); - free(dname); - free(sfile); - } -} - - -/* traverse function for wiping files */ -static void wipe_fn(const char *fname, struct stat *st) -{ - char *p; - - if (!S_ISREG(st->st_mode)) return; - - p = str_basename(fname); - if (strcmp(p, "stats") == 0) { - free(p); - return; - } - free(p); - - unlink(fname); -} - - -/* wipe all cached files in all subdirs */ -void wipe_all(const char *dir) -{ - char *dname; - int i; - - for (i=0;i<=0xF;i++) { - x_asprintf(&dname, "%s/%1x", dir, i); - traverse(dir, wipe_fn); - free(dname); - } - - /* and fix the counters */ - cleanup_all(dir); -} diff --git a/CCache/configure.in b/CCache/configure.in deleted file mode 100644 index dfbf86dbc..000000000 --- a/CCache/configure.in +++ /dev/null @@ -1,87 +0,0 @@ -dnl Process this file with autoconf to produce a configure script. - -AC_INIT([ccache-swig], [0.0]) # Get version from SWIG in ccache_swig_config.h.in -AC_PREREQ(2.52) -AC_CONFIG_SRCDIR([ccache.h]) - -AC_MSG_NOTICE([Configuring ccache]) - -AC_CONFIG_HEADER(config.h) - -dnl Checks for programs. -AC_PROG_CC -AC_PROG_CPP -AC_PROG_INSTALL -AC_ARG_PROGRAM # for program_transform_name - -AC_DEFINE([_GNU_SOURCE], 1, - [Define _GNU_SOURCE so that we get all necessary prototypes]) - -# If GCC, turn on warnings. -if test "x$GCC" = "xyes" -then - CFLAGS="$CFLAGS -Wall -W" -else - CFLAGS="$CFLAGS -O" -fi - -AC_HEADER_DIRENT -AC_HEADER_TIME -AC_HEADER_SYS_WAIT - -AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h) - -AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) -AC_CHECK_FUNCS(gethostname getpwuid) -AC_CHECK_FUNCS(utimes) - -AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [ - AC_TRY_COMPILE( -[#include ], -[ -void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); } -], - ccache_cv_COMPAR_FN_T=yes,ccache_cv_COMPAR_FN_T=no)]) -if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then - AC_DEFINE(HAVE_COMPAR_FN_T, 1, [ ]) -fi - -dnl Note: This could be replaced by AC_FUNC_SNPRINTF() in the autoconf macro archive -AC_CACHE_CHECK([for C99 vsnprintf],ccache_cv_HAVE_C99_VSNPRINTF,[ -AC_TRY_RUN([ -#include -#include -void foo(const char *format, ...) { - va_list ap; - int len; - char buf[5]; - - va_start(ap, format); - len = vsnprintf(0, 0, format, ap); - va_end(ap); - if (len != 5) exit(1); - - if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1); - - exit(0); -} -main() { foo("hello"); } -], -ccache_cv_HAVE_C99_VSNPRINTF=yes,ccache_cv_HAVE_C99_VSNPRINTF=no,ccache_cv_HAVE_C99_VSNPRINTF=cross)]) -if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then - AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ]) -fi - -dnl Check for zlib. -dnl Note: This could be replaced by CHECK_ZLIB() in the autoconf macro archive -AC_ARG_ENABLE([zlib], - AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),, - [enable_zlib=yes]) - -if test x"$enable_zlib" = x"yes"; then - AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, [LIBS="-lz $LIBS" - AC_DEFINE([ENABLE_ZLIB], 1, [Define to 1 if you would like to have zlib compression for ccache.]) ] )) -fi - -AC_CONFIG_FILES([Makefile]) -AC_OUTPUT diff --git a/CCache/debian/NEWS b/CCache/debian/NEWS deleted file mode 100644 index be245dc7d..000000000 --- a/CCache/debian/NEWS +++ /dev/null @@ -1,22 +0,0 @@ -ccache (2.4-8) unstable; urgency=high - - zlib compression is now enabled by default in order to increase the amount - of object files that can fit in the cache. - - The impact on performance is supposed to be almost negligible - (see http://www.gustaebel.de/lars/ccache/). If you do want to disable - it however, simply export the CCACHE_NOCOMPRESS environment variable. - - Note that a zlib-enabled ccache will still read your existing - uncompressed cache. If you want to compress/uncompress your cache, - see the manage-cache.sh script under /usr/share/doc/ccache/examples/. - - -- Francois Marier Sun, 20 May 2007 19:45:07 +1200 - -ccache (2.4-1) unstable; urgency=low - - * This release changes the hash input slighly, so you will probably find - that you will not get any hits against your existing cache when you - upgrade. - - -- Francois Marier Sat, 11 Jun 2005 13:54:33 -0400 diff --git a/CCache/debian/README.Debian b/CCache/debian/README.Debian deleted file mode 100644 index 5478bb720..000000000 --- a/CCache/debian/README.Debian +++ /dev/null @@ -1,59 +0,0 @@ -Installing ccache ------------------ - -The recommended way to use this with Debian is to either create "cc" -and "gcc" symlinks to /usr/bin/ccache in your private bin directory -(which must be before the real cc and gcc in your path), or use -CC="ccache gcc" on the make command line. - -Another option is to just prepend /usr/lib/ccache in your PATH -environment variable, like - - export PATH="/usr/lib/ccache:$PATH" - -Note that ccache works with both native and cross compilers. - -Ignoring whitespace -------------------- - -If you wish to set up ccache so that it ignores blank lines, have a -look at the CCACHE_UNIFY option. However, please note that this -option is off by default since the reported line numbers may not -match the source files anymore. - - -NFS Issues ----------- - -(from John Coiner on the ccache mailing list) - -When CCache creates a hardlinked output file, it calls utime() to update -the timestamp on the object, so that Make realizes that the object has -changed. - -On NFS, utime() has no coherency guarantee, AFAIK. When utime() runs on -host A, and our parallel implementation of Make is running on host B, -sometimes Make doesn't see the new timestamp soon enough -- and neglects -to relink the final binary. That's a one-way ticket to Silent Mysterious -Failure Town. - -Instead of relying on the object file timestamp, we create a dummy file -with a reliable timestamp: - -objs/foo.o objs/foo.o.built : - if ( ccache gcc -o foo.o -c foo.c ) ; \ - then touch objs/foo.o.built ; \ - else exit 1; \ - fi - -binary : objs/foo.o.built - gcc -o binary objs/foo.o - -NFS does make a coherency guarantee, that if a file is written and -close()d on host A, and subsequently open()ed on host B, that the second -open() will reflect all modifications and attributes from the close(). -Since Make does open() when checking timestamps, and the dummy file is -close()d when it's created, the binary will always relink after the -object is recompiled. - - -- Francois Marier Sun, 20 May 2007 17:35:36 +1200 diff --git a/CCache/debian/changelog b/CCache/debian/changelog deleted file mode 100644 index 45500d4bd..000000000 --- a/CCache/debian/changelog +++ /dev/null @@ -1,221 +0,0 @@ -ccache (2.4-15) unstable; urgency=low - - * Add a new patch which improve the consistency of timestamps on cached - objects to make sure clean-up is based on least recently used objects. - * Patch the set_limit call so that non-writable cache directories return - an error when attempting to size the max(files|size) (closes: #332527) - - -- Francois Marier Sun, 13 Apr 2008 15:07:05 +1200 - -ccache (2.4-14) unstable; urgency=low - - * Mention the long options everywhere in the manpage - * Merge Gentoo patches: - - respect user's LDFLAGS - - use utimes() for timestamp if possible - - -- Francois Marier Sun, 23 Mar 2008 16:30:11 +1300 - -ccache (2.4-13) unstable; urgency=low - - * Update CACHEDIR.TAG patch to avoid creating the tag file when the - CCACHE_READONLY environment variable is set. (closes: #464356) - * Mention the GNU-style long options in the manpage - - -- Francois Marier Thu, 07 Feb 2008 10:50:42 +1300 - -ccache (2.4-12) unstable; urgency=low - - * Add symlink for gcc 4.3 (closes: #463590) - * Add support for the CACHEDIR.TAG spec, thanks to Karl Chen. - (see http://www.brynosaurus.com/cachedir/) - * Fix hyphens in manpage (lintian notice) - * Bump Standards-Version up to 3.7.3 (no changes) - * Bump debhelper compatibility to 6 - - -- Francois Marier Sat, 02 Feb 2008 10:37:22 +1300 - -ccache (2.4-11) unstable; urgency=low - - * Add the collab-maint repo to debian/control - - -- Francois Marier Tue, 20 Nov 2007 15:26:37 +1300 - -ccache (2.4-10) unstable; urgency=low - - * Document where the patches are from in debian/patches/CREDITS - * debian/rules: - - Fixed "make distclean" lintian warning - - Removed commented-out entries - * Set debhelper compatibility to 5 - * Add homepage field in debian/control - * Add symlinks for MinGW (closes: #445782) - * Bump the version to 5 in the debhelper dependency - - -- Francois Marier Fri, 19 Oct 2007 16:04:37 +1300 - -ccache (2.4-9) unstable; urgency=low - - * Add a symlink for gcc 4.2 (closes: #431007) - * Fix dependencies when using -o (closes: #217713) - - -- Francois Marier Sat, 30 Jun 2007 17:58:44 +1200 - -ccache (2.4-8) unstable; urgency=low - - * Enable zlib compression of the cache by default (closes: #409848). - Thanks to Sami Liedes for suggesting this. - * Disable ccache when profiling (closes: #215849). - Thanks to Ted Percival for the Patch. - * Fix NFS renaming issues and add instructions to the README. - Thanks to John Coiner and instructions. - * Put all patches in debian/patches and apply them at build time. - - -- Francois Marier Sun, 20 May 2007 19:42:34 +1200 - -ccache (2.4-7) unstable; urgency=low - - * Use the real compiler when HOME is not set (closes: #396350) - * Include user script under doc/examples (closes: #392435) - Thanks to Behan Webster! - * Add support for GNU --long options (closes: #297126) - - -- Francois Marier Sat, 18 Nov 2006 00:50:59 -0500 - -ccache (2.4-6) unstable; urgency=low - - * Include symlinks for gcc 4.1 (closes: #372838) - * Update watch file - - -- Francois Marier Tue, 13 Jun 2006 22:17:37 -0400 - -ccache (2.4-5) unstable; urgency=low - - * Document the fact that cross-compiling is supported (closes: #349221) - * Bump Standards-Version up to 3.7.2 (no changes) - - -- Francois Marier Sun, 4 Jun 2006 01:20:07 -0400 - -ccache (2.4-4) unstable; urgency=low - - * Mention another way to use ccache in README.Debian (thanks to Benjamin - Drieu for the suggestion) (closes: #267632) - * Update FSF address - * Fix watch file - - -- Francois Marier Sat, 26 Nov 2005 00:15:13 -0500 - -ccache (2.4-3) unstable; urgency=low - - * Actually use the configuration flags in debian/rules - * Bump Standards-Version up to 3.6.2 (no changes) - - -- Francois Marier Sun, 26 Jun 2005 13:33:19 -0400 - -ccache (2.4-2) unstable; urgency=low - - * Add gcc and g++ symlinks to /usr/lib/ccache (closes: #313490) - * Remove invalid entry from Depends - - -- Francois Marier Wed, 15 Jun 2005 20:51:03 -0400 - -ccache (2.4-1) unstable; urgency=low - - * New maintainer (closes: #312867) - * New upstream version: (closes: #273753, #239640) - - New CCACHE_READONLY and CCACHE_TEMPDIR options - - Fixed handling of hard-linked compilers on AIX - - Fixed handling of HOME environment variable (closes: #299880) - - Show cache directory in stats output - * Fix copyright file - * Add 'distcc' to Suggests (closes: #269158) - * Add a note about whitespace in README.Debian (closes: #229116) - * Update rules to add symmlinks for gcc 3.4 & 4.0 (closes: #261177) - * Acknowledge NMUs (closes: #200185, #177129, #174417) - - -- Francois Marier Sun, 12 Jun 2005 12:05:34 -0400 - -ccache (2.3-1.1) unstable; urgency=low - - * Non-maintainer upload during BSP - * Re-apply patch for - #200185 ccache: Incorrect symlinks in /usr/lib/ccache - (Closes: #200185) - - -- Frank Lichtenheld Fri, 19 Mar 2004 11:14:50 +0100 - -ccache (2.3-1) unstable; urgency=low - - * New upstream release: obsoletes existing caches. - * Tweak package description in arbitrary way (closes: #181721) - - -- Paul Russell Mon, 29 Sep 2003 02:53:20 +0200 - -ccache (2.2-2) unstable; urgency=low - - * Insert more symlinks in ccache dir (closes: #197468) - - -- Paul Russell Mon, 16 Jun 2003 10:52:50 +0100 - -ccache (2.2-1) unstable; urgency=low - - * New upstream release (closes: #150755) - * Insert more symlinks in ccache dir (closes: #144462) - - -- Paul Russell Mon, 17 Feb 2003 07:19:36 +0100 - -ccache (2.1.1-2) unstable; urgency=low - - * Restored /usr/lib/ccache symlinks (closes: #179393) - * Fixed manpage typo (closes: #179564) - * With thanks to Andreas Rottmann. - - -- Paul Russell Wed, 5 Feb 2003 10:01:10 +0100 - -ccache (2.1.1-1) unstable; urgency=low - - * NMU (with maintainer consent). - * New upstream release (closes: #174417, #177129). - * debian/control: - + Build-Depend on and use dephelper 4 (DH_COMPAT = 4). - + Bumped Standards-Version to 3.5.8. - + No full stop on short package description (fixes linda warning). - * debian/copright: - + Make lintian feel comfortable; fixes warnings: - - copyright-should-refer-to-common-license-file-for-gpl - - copyright-lists-upstream-authors-with-dh_make-boilerplate - * Built with g++ 3.2 :-). - - -- Andreas Rottmann Thu, 16 Jan 2003 11:42:38 +0100 - -ccache (1.9-1) unstable; urgency=low - - * New upstream release (closes: #144920) - - -- Paul Russell Mon, 13 May 2002 10:01:09 +0200 - -ccache (1.8-1) unstable; urgency=low - - * New upstream release (closes: #145401) - - -- Paul Russell Fri, 3 May 2002 02:26:32 +0200 - -ccache (1.7-1) unstable; urgency=low - - * New upstream release - * Install symlinks in /usr/lib/ccache (closes: #141337) - - -- Paul Russell Wed, 10 Apr 2002 17:51:21 +0200 - -ccache (1.4-1) unstable; urgency=low - - * New upstream release - - -- Paul Russell Wed, 3 Apr 2002 03:41:46 +0200 - -ccache (1.2-1) unstable; urgency=low - - * Initial Release. - - -- Paul Russell Sun, 31 Mar 2002 14:08:57 +0200 - diff --git a/CCache/debian/compat b/CCache/debian/compat deleted file mode 100644 index 1e8b31496..000000000 --- a/CCache/debian/compat +++ /dev/null @@ -1 +0,0 @@ -6 diff --git a/CCache/debian/control b/CCache/debian/control deleted file mode 100644 index 0b7e57282..000000000 --- a/CCache/debian/control +++ /dev/null @@ -1,20 +0,0 @@ -Source: ccache -Section: devel -Priority: optional -Maintainer: Francois Marier -Build-Depends: debhelper (>> 6), autotools-dev, zlib1g-dev -Standards-Version: 3.7.3 -Homepage: http://ccache.samba.org -Vcs-Svn: svn://svn.debian.org/svn/collab-maint/deb-maint/ccache/ -Vcs-Browser: http://svn.debian.org/wsvn/collab-maint/deb-maint/ccache/ - -Package: ccache -Architecture: any -Depends: ${shlibs:Depends} -Suggests: distcc -Description: Compiler results cacher, for fast recompiles - ccache is a compiler cache. It speeds up re-compilation of C/C++ code - by caching previous compiles and detecting when the same compile is - being done again. - . - This is similar to, but faster than, the compilercache package. diff --git a/CCache/debian/copyright b/CCache/debian/copyright deleted file mode 100644 index 7ac791dc5..000000000 --- a/CCache/debian/copyright +++ /dev/null @@ -1,29 +0,0 @@ -This package was debianized by Paul Russell on -Sun, 31 Mar 2002 14:08:57 +0200. - -It was downloaded from http://ccache.samba.org/ftp/ccache/ - -The ccache-zlib patch was downloaded from http://www.gustaebel.de/lars/ccache/ - -Upstream Author: Andrew Tridgell - -Copyright: 2002-2005 Andrew Tridgell - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301, USA - -You are free to distribute this software under the terms of the GNU General -Public License. On Debian systems, the complete text of the GNU General -Public License can be found in /usr/share/common-licenses/GPL file. diff --git a/CCache/debian/dirs b/CCache/debian/dirs deleted file mode 100644 index 8ceb4c4e8..000000000 --- a/CCache/debian/dirs +++ /dev/null @@ -1,3 +0,0 @@ -usr/bin -usr/lib/ccache -usr/share/man/man1 diff --git a/CCache/debian/docs b/CCache/debian/docs deleted file mode 100644 index e845566c0..000000000 --- a/CCache/debian/docs +++ /dev/null @@ -1 +0,0 @@ -README diff --git a/CCache/debian/examples b/CCache/debian/examples deleted file mode 100644 index fc549228c..000000000 --- a/CCache/debian/examples +++ /dev/null @@ -1,2 +0,0 @@ -debian/update-ccache -manage-cache.sh diff --git a/CCache/debian/patches/01_no_home.diff b/CCache/debian/patches/01_no_home.diff deleted file mode 100644 index 019634c0c..000000000 --- a/CCache/debian/patches/01_no_home.diff +++ /dev/null @@ -1,100 +0,0 @@ ---- ccache.c -+++ ccache.c -@@ -836,6 +836,13 @@ - { - /* find the real compiler */ - find_compiler(argc, argv); -+ -+ /* use the real compiler if HOME is not set */ -+ if (!cache_dir) { -+ cc_log("Unable to determine home directory\n"); -+ cc_log("ccache is disabled\n"); -+ failed(); -+ } - - /* we might be disabled */ - if (getenv("CCACHE_DISABLE")) { -@@ -895,6 +902,13 @@ - printf("-V print version number\n"); - } - -+static void check_cache_dir(void) -+{ -+ if (!cache_dir) { -+ fatal("Unable to determine home directory"); -+ } -+} -+ - /* the main program when not doing a compile */ - static int ccache_main(int argc, char *argv[]) - { -@@ -914,31 +928,37 @@ - exit(0); - - case 's': -+ check_cache_dir(); - stats_summary(); - break; - - case 'c': -+ check_cache_dir(); - cleanup_all(cache_dir); - printf("Cleaned cache\n"); - break; - - case 'C': -+ check_cache_dir(); - wipe_all(cache_dir); - printf("Cleared cache\n"); - break; - - case 'z': -+ check_cache_dir(); - stats_zero(); - printf("Statistics cleared\n"); - break; - - case 'F': -+ check_cache_dir(); - v = atoi(optarg); - stats_set_limits(v, -1); - printf("Set cache file limit to %u\n", (unsigned)v); - break; - - case 'M': -+ check_cache_dir(); - v = value_units(optarg); - stats_set_limits(-1, v); - printf("Set cache size limit to %uk\n", (unsigned)v); -@@ -983,7 +1003,10 @@ - - cache_dir = getenv("CCACHE_DIR"); - if (!cache_dir) { -- x_asprintf(&cache_dir, "%s/.ccache", get_home_directory()); -+ const char *home_directory = get_home_directory(); -+ if (home_directory) { -+ x_asprintf(&cache_dir, "%s/.ccache", home_directory); -+ } - } - - temp_dir = getenv("CCACHE_TEMPDIR"); -@@ -1023,7 +1046,7 @@ - } - - /* make sure the cache dir exists */ -- if (create_dir(cache_dir) != 0) { -+ if (cache_dir && (create_dir(cache_dir) != 0)) { - fprintf(stderr,"ccache: failed to create %s (%s)\n", - cache_dir, strerror(errno)); - exit(1); ---- util.c -+++ util.c -@@ -448,7 +448,7 @@ - } - } - #endif -- fatal("Unable to determine home directory"); -+ cc_log("Unable to determine home directory"); - return NULL; - } - diff --git a/CCache/debian/patches/02_ccache-compressed.diff b/CCache/debian/patches/02_ccache-compressed.diff deleted file mode 100644 index 5740c2ca4..000000000 --- a/CCache/debian/patches/02_ccache-compressed.diff +++ /dev/null @@ -1,1026 +0,0 @@ -Index: ccache.1 -=================================================================== -RCS file: /home/cvsroot/lars/ccache/ccache.1,v -retrieving revision 1.1.1.1.2.1 -retrieving revision 1.6 -diff -u -r1.1.1.1.2.1 -r1.6 ---- ccache.1 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 -+++ ccache.1 21 Nov 2004 18:19:28 -0000 1.6 -@@ -210,7 +210,8 @@ - CCACHE_HARDLINK then ccache will attempt to use hard links from the - cache directory when creating the compiler output rather than using a - file copy\&. Using hard links is faster, but can confuse programs like --\&'make\&' that rely on modification times\&. -+\&'make\&' that rely on modification times\&. Hard links are never made for -+compressed cache files\&. - .IP - .IP "\fBCCACHE_RECACHE\fP" - This forces ccache to not use any cached -@@ -257,6 +258,11 @@ - the default\&. On HP-UX set this environment variable to "i" if you use - the aCC compiler\&. - .IP -+.IP "\fBCCACHE_NOCOMPRESS\fP" -+If you set the environment variable -+CCACHE_NOCOMPRESS then there is no compression used on files that go -+into the cache\&. -+.IP - .PP - .SH "CACHE SIZE MANAGEMENT" - .PP -@@ -269,6 +275,14 @@ - below the numbers you specified in order to avoid doing the cache - clean operation too often\&. - .PP -+.SH "CACHE COMPRESSION" -+.PP -+By default ccache will compress all files it puts into the cache -+using the zlib compression\&. While this involves a negligible -+performance slowdown, it significantly increases the number of files -+that fit in the cache\&. You can turn off compression setting the -+CCACHE_NOCOMPRESS environment variable\&. -+.PP - .SH "HOW IT WORKS" - .PP - The basic idea is to detect when you are compiling exactly the same -Index: ccache.c -=================================================================== -RCS file: /home/cvsroot/lars/ccache/ccache.c,v -retrieving revision 1.1.1.1.2.1 -retrieving revision 1.9 -diff -u -r1.1.1.1.2.1 -r1.9 ---- ccache.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 -+++ ccache.c 21 Nov 2004 18:19:28 -0000 1.9 -@@ -199,7 +199,7 @@ - fd = open(tmp_stderr, O_RDONLY | O_BINARY); - if (fd != -1) { - if (strcmp(output_file, "/dev/null") == 0 || -- rename(tmp_hashname, output_file) == 0 || errno == ENOENT) { -+ move_file(tmp_hashname, output_file) == 0 || errno == ENOENT) { - if (cpp_stderr) { - /* we might have some stderr from cpp */ - int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY); -@@ -231,14 +231,25 @@ - x_asprintf(&path_stderr, "%s.stderr", hashname); - - if (stat(tmp_stderr, &st1) != 0 || -- stat(tmp_hashname, &st2) != 0 || -- rename(tmp_hashname, hashname) != 0 || -- rename(tmp_stderr, path_stderr) != 0) { -+ stat(tmp_hashname, &st2) != 0 || -+ move_file(tmp_hashname, hashname) != 0 || -+ move_file(tmp_stderr, path_stderr) != 0) { - cc_log("failed to rename tmp files - %s\n", strerror(errno)); - stats_update(STATS_ERROR); - failed(); - } - -+#if ENABLE_ZLIB -+ /* do an extra stat on the cache files for -+ the size statistics */ -+ if (stat(path_stderr, &st1) != 0 || -+ stat(hashname, &st2) != 0) { -+ cc_log("failed to stat cache files - %s\n", strerror(errno)); -+ stats_update(STATS_ERROR); -+ failed(); -+ } -+#endif -+ - cc_log("Placed %s into cache\n", output_file); - stats_tocache(file_size(&st1) + file_size(&st2)); - -@@ -474,7 +485,13 @@ - } - - /* the user might be disabling cache hits */ -+#ifndef ENABLE_ZLIB -+ /* if the cache file is compressed we must recache */ -+ if ((first && getenv("CCACHE_RECACHE")) || -+ test_if_compressed(hashname) == 1) { -+#else - if (first && getenv("CCACHE_RECACHE")) { -+#endif - close(fd_stderr); - unlink(stderr_file); - free(stderr_file); -@@ -487,7 +504,9 @@ - ret = 0; - } else { - unlink(output_file); -- if (getenv("CCACHE_HARDLINK")) { -+ /* only make a hardlink if the cache file is uncompressed */ -+ if (getenv("CCACHE_HARDLINK") && -+ test_if_compressed(hashname) == 0) { - ret = link(hashname, output_file); - } else { - ret = copy_file(hashname, output_file); -Index: ccache.h -=================================================================== -RCS file: /home/cvsroot/lars/ccache/ccache.h,v -retrieving revision 1.1.1.1.2.1 -retrieving revision 1.7 -diff -u -r1.1.1.1.2.1 -r1.7 ---- ccache.h 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 -+++ ccache.h 21 Nov 2004 18:19:28 -0000 1.7 -@@ -23,6 +23,10 @@ - #include - #endif - -+#ifdef ENABLE_ZLIB -+#include -+#endif -+ - #define STATUS_NOTFOUND 3 - #define STATUS_FATAL 4 - #define STATUS_NOCACHE 5 -@@ -36,6 +40,13 @@ - #define DEFAULT_MAXSIZE (1000*1000) - #endif - -+/* file copy mode */ -+#ifdef ENABLE_ZLIB -+#define COPY_UNCOMPRESSED 0 -+#define COPY_FROM_CACHE 1 -+#define COPY_TO_CACHE 2 -+#endif -+ - enum stats { - STATS_NONE=0, - STATS_STDOUT, -@@ -79,6 +90,8 @@ - - void copy_fd(int fd_in, int fd_out); - int copy_file(const char *src, const char *dest); -+int move_file(const char *src, const char *dest); -+int test_if_compressed(const char *filename); - - int create_dir(const char *dir); - void x_asprintf(char **ptr, const char *format, ...); -Index: ccache.yo -=================================================================== -RCS file: /home/cvsroot/lars/ccache/ccache.yo,v -retrieving revision 1.1.1.1.2.1 -retrieving revision 1.5 -diff -u -r1.1.1.1.2.1 -r1.5 ---- ccache.yo 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 -+++ ccache.yo 21 Nov 2004 18:19:28 -0000 1.5 -@@ -169,6 +169,11 @@ - this optimisation, in which case this option could allow ccache to be - used. - -+dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable -+CCACHE_NOCOMPRESS then there is no compression used on files that go -+into the cache. However, this setting has no effect on how files are -+retrieved from the cache, compressed results will still be usable. -+ - dit(bf(CCACHE_NOSTATS)) If you set the environment variable - CCACHE_NOSTATS then ccache will not update the statistics files on - each compile. -@@ -181,7 +186,8 @@ - CCACHE_HARDLINK then ccache will attempt to use hard links from the - cache directory when creating the compiler output rather than using a - file copy. Using hard links is faster, but can confuse programs like --'make' that rely on modification times. -+'make' that rely on modification times. Hard links are never made for -+compressed cache files. - - dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached - results, even if it finds them. New results are still cached, but -@@ -236,6 +242,14 @@ - below the numbers you specified in order to avoid doing the cache - clean operation too often. - -+manpagesection(CACHE COMPRESSION) -+ -+By default ccache will compress all files it puts into the cache -+using the zlib compression. While this involves a negligible -+performance slowdown, it significantly increases the number of files -+that fit in the cache. You can turn off compression setting the -+CCACHE_NOCOMPRESS environment variable. -+ - manpagesection(HOW IT WORKS) - - The basic idea is to detect when you are compiling exactly the same -@@ -294,6 +308,8 @@ - cache. This tells the filesystem to inherit group ownership for new - directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might - be useful for this. -+ it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with -+ versions of ccache that do not support compression. - ) - - manpagesection(HISTORY) -Index: config.h.in -=================================================================== -RCS file: /home/cvsroot/lars/ccache/config.h.in,v -retrieving revision 1.1.1.1 -retrieving revision 1.2 -diff -u -r1.1.1.1 -r1.2 ---- config.h.in 30 Apr 2004 13:13:41 -0000 1.1.1.1 -+++ config.h.in 4 May 2004 20:49:26 -0000 1.2 -@@ -98,3 +98,6 @@ - - /* Define _GNU_SOURCE so that we get all necessary prototypes */ - #undef _GNU_SOURCE -+ -+/* Define to 1 if you like to have zlib compression for the ccache. */ -+#undef ENABLE_ZLIB -Index: configure -=================================================================== -RCS file: /home/cvsroot/lars/ccache/configure,v -retrieving revision 1.1.1.1.2.1 -diff -u -r1.1.1.1.2.1 configure ---- configure 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 -+++ configure 21 Nov 2004 18:24:42 -0000 -@@ -836,6 +836,11 @@ - - cat <<\_ACEOF - -+Optional Features: -+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) -+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes] -+ --enable-zlib enable zlib support for ccache compression -+ - Some influential environment variables: - CC C compiler command - CFLAGS C compiler flags -@@ -936,7 +941,7 @@ - else - echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 - fi -- cd "$ac_popdir" -+ cd $ac_popdir - done - fi - -@@ -1859,7 +1864,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -1917,7 +1923,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2033,7 +2040,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2087,7 +2095,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2132,7 +2141,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2176,7 +2186,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2609,7 +2620,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2681,7 +2693,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2735,7 +2748,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2806,7 +2820,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2860,7 +2875,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2927,7 +2943,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -2997,7 +3014,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -3078,7 +3096,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -3248,7 +3267,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -3319,7 +3339,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -3509,7 +3530,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -3611,7 +3633,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -3676,7 +3699,8 @@ - cat conftest.err >&5 - echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && -- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' - { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 - (eval $ac_try) 2>&5 - ac_status=$? -@@ -3775,6 +3799,229 @@ - - fi - -+# Check whether --enable-zlib or --disable-zlib was given. -+if test "${enable_zlib+set}" = set; then -+ enableval="$enable_zlib" -+ -+else -+ enable_zlib=yes -+fi; -+ -+if test x"$enable_zlib" = x"yes"; then -+ if test "${ac_cv_header_zlib_h+set}" = set; then -+ echo "$as_me:$LINENO: checking for zlib.h" >&5 -+echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 -+if test "${ac_cv_header_zlib_h+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+fi -+echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -+echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 -+else -+ # Is the header compilable? -+echo "$as_me:$LINENO: checking zlib.h usability" >&5 -+echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+$ac_includes_default -+#include -+_ACEOF -+rm -f conftest.$ac_objext -+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 -+ (eval $ac_compile) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest.$ac_objext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_header_compiler=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_header_compiler=no -+fi -+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -+echo "${ECHO_T}$ac_header_compiler" >&6 -+ -+# Is the header present? -+echo "$as_me:$LINENO: checking zlib.h presence" >&5 -+echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6 -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+#include -+_ACEOF -+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 -+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } >/dev/null; then -+ if test -s conftest.err; then -+ ac_cpp_err=$ac_c_preproc_warn_flag -+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag -+ else -+ ac_cpp_err= -+ fi -+else -+ ac_cpp_err=yes -+fi -+if test -z "$ac_cpp_err"; then -+ ac_header_preproc=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ ac_header_preproc=no -+fi -+rm -f conftest.err conftest.$ac_ext -+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -+echo "${ECHO_T}$ac_header_preproc" >&6 -+ -+# So? What about this header? -+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in -+ yes:no: ) -+ { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 -+echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} -+ { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5 -+echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;} -+ ac_header_preproc=yes -+ ;; -+ no:yes:* ) -+ { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5 -+echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;} -+ { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5 -+echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;} -+ { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5 -+echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;} -+ { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5 -+echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;} -+ { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5 -+echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;} -+ { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5 -+echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;} -+ ( -+ cat <<\_ASBOX -+## ------------------------------------------ ## -+## Report this to the AC_PACKAGE_NAME lists. ## -+## ------------------------------------------ ## -+_ASBOX -+ ) | -+ sed "s/^/$as_me: WARNING: /" >&2 -+ ;; -+esac -+echo "$as_me:$LINENO: checking for zlib.h" >&5 -+echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6 -+if test "${ac_cv_header_zlib_h+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_cv_header_zlib_h=$ac_header_preproc -+fi -+echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5 -+echo "${ECHO_T}$ac_cv_header_zlib_h" >&6 -+ -+fi -+if test $ac_cv_header_zlib_h = yes; then -+ echo "$as_me:$LINENO: checking for gzdopen in -lz" >&5 -+echo $ECHO_N "checking for gzdopen in -lz... $ECHO_C" >&6 -+if test "${ac_cv_lib_z_gzdopen+set}" = set; then -+ echo $ECHO_N "(cached) $ECHO_C" >&6 -+else -+ ac_check_lib_save_LIBS=$LIBS -+LIBS="-lz $LIBS" -+cat >conftest.$ac_ext <<_ACEOF -+/* confdefs.h. */ -+_ACEOF -+cat confdefs.h >>conftest.$ac_ext -+cat >>conftest.$ac_ext <<_ACEOF -+/* end confdefs.h. */ -+ -+/* Override any gcc2 internal prototype to avoid an error. */ -+#ifdef __cplusplus -+extern "C" -+#endif -+/* We use char because int might match the return type of a gcc2 -+ builtin and then its argument prototype would still apply. */ -+char gzdopen (); -+int -+main () -+{ -+gzdopen (); -+ ; -+ return 0; -+} -+_ACEOF -+rm -f conftest.$ac_objext conftest$ac_exeext -+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 -+ (eval $ac_link) 2>conftest.er1 -+ ac_status=$? -+ grep -v '^ *+' conftest.er1 >conftest.err -+ rm -f conftest.er1 -+ cat conftest.err >&5 -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); } && -+ { ac_try='test -z "$ac_c_werror_flag" -+ || test ! -s conftest.err' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; } && -+ { ac_try='test -s conftest$ac_exeext' -+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 -+ (eval $ac_try) 2>&5 -+ ac_status=$? -+ echo "$as_me:$LINENO: \$? = $ac_status" >&5 -+ (exit $ac_status); }; }; then -+ ac_cv_lib_z_gzdopen=yes -+else -+ echo "$as_me: failed program was:" >&5 -+sed 's/^/| /' conftest.$ac_ext >&5 -+ -+ac_cv_lib_z_gzdopen=no -+fi -+rm -f conftest.err conftest.$ac_objext \ -+ conftest$ac_exeext conftest.$ac_ext -+LIBS=$ac_check_lib_save_LIBS -+fi -+echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzdopen" >&5 -+echo "${ECHO_T}$ac_cv_lib_z_gzdopen" >&6 -+if test $ac_cv_lib_z_gzdopen = yes; then -+ LIBS="-lz $LIBS"; cat >>confdefs.h <<\_ACEOF -+#define ENABLE_ZLIB 1 -+_ACEOF -+ -+fi -+ -+fi -+ -+ -+fi -+ - ac_config_files="$ac_config_files Makefile" - - cat >confcache <<\_ACEOF -@@ -4568,6 +4815,11 @@ - *) ac_INSTALL=$ac_top_builddir$INSTALL ;; - esac - -+ if test x"$ac_file" != x-; then -+ { echo "$as_me:$LINENO: creating $ac_file" >&5 -+echo "$as_me: creating $ac_file" >&6;} -+ rm -f "$ac_file" -+ fi - # Let's still pretend it is `configure' which instantiates (i.e., don't - # use $as_me), people would be surprised to read: - # /* config.h. Generated by config.status. */ -@@ -4606,12 +4858,6 @@ - fi;; - esac - done` || { (exit 1); exit 1; } -- -- if test x"$ac_file" != x-; then -- { echo "$as_me:$LINENO: creating $ac_file" >&5 --echo "$as_me: creating $ac_file" >&6;} -- rm -f "$ac_file" -- fi - _ACEOF - cat >>$CONFIG_STATUS <<_ACEOF - sed "$ac_vpsub -Index: configure.in -=================================================================== -RCS file: /home/cvsroot/lars/ccache/configure.in,v -retrieving revision 1.1.1.1.2.1 -retrieving revision 1.4 -diff -u -r1.1.1.1.2.1 -r1.4 ---- configure.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 -+++ configure.in 21 Nov 2004 18:19:28 -0000 1.4 -@@ -68,5 +68,14 @@ - AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ]) - fi - -+dnl Check for zlib. -+AC_ARG_ENABLE([zlib], -+ AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),, -+ [enable_zlib=yes]) -+ -+if test x"$enable_zlib" = x"yes"; then -+ AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, LIBS="-lz $LIBS"; AC_DEFINE(ENABLE_ZLIB))) -+fi -+ - AC_CONFIG_FILES([Makefile]) - AC_OUTPUT -Index: util.c -=================================================================== -RCS file: /home/cvsroot/lars/ccache/util.c,v -retrieving revision 1.1.1.1.2.1 -retrieving revision 1.11 -diff -u -r1.1.1.1.2.1 -r1.11 ---- util.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 -+++ util.c 21 Nov 2004 18:19:28 -0000 1.11 -@@ -44,6 +44,7 @@ - exit(1); - } - -+#ifndef ENABLE_ZLIB - /* copy all data from one file descriptor to another */ - void copy_fd(int fd_in, int fd_out) - { -@@ -57,6 +58,11 @@ - } - } - -+/* move a file using rename */ -+int move_file(const char *src, const char *dest) { -+ return rename(src, dest); -+} -+ - /* copy a file - used when hard links don't work - the copy is done via a temporary file and atomic rename - */ -@@ -120,6 +126,174 @@ - return 0; - } - -+#else /* ENABLE_ZLIB */ -+ -+/* copy all data from one file descriptor to another -+ possibly decompressing it -+*/ -+void copy_fd(int fd_in, int fd_out) { -+ char buf[10240]; -+ int n; -+ gzFile gz_in; -+ -+ gz_in = gzdopen(dup(fd_in), "rb"); -+ -+ if (!gz_in) { -+ fatal("Failed to copy fd"); -+ } -+ -+ while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { -+ if (write(fd_out, buf, n) != n) { -+ fatal("Failed to copy fd"); -+ } -+ } -+} -+ -+static int _copy_file(const char *src, const char *dest, int mode) { -+ int fd_in, fd_out; -+ gzFile gz_in, gz_out = NULL; -+ char buf[10240]; -+ int n, ret; -+ char *tmp_name; -+ mode_t mask; -+ struct stat st; -+ -+ x_asprintf(&tmp_name, "%s.XXXXXX", dest); -+ -+ if (getenv("CCACHE_NOCOMPRESS")) { -+ mode = COPY_UNCOMPRESSED; -+ } -+ -+ /* open source file */ -+ fd_in = open(src, O_RDONLY); -+ if (fd_in == -1) { -+ return -1; -+ } -+ -+ gz_in = gzdopen(fd_in, "rb"); -+ if (!gz_in) { -+ close(fd_in); -+ return -1; -+ } -+ -+ /* open destination file */ -+ fd_out = mkstemp(tmp_name); -+ if (fd_out == -1) { -+ gzclose(gz_in); -+ free(tmp_name); -+ return -1; -+ } -+ -+ if (mode == COPY_TO_CACHE) { -+ /* The gzip file format occupies at least 20 bytes. So -+ it will always occupy an entire filesystem block, -+ even for empty files. -+ Since most stderr files will be empty, we turn off -+ compression in this case to save space. -+ */ -+ if (fstat(fd_in, &st) != 0) { -+ gzclose(gz_in); -+ close(fd_out); -+ free(tmp_name); -+ return -1; -+ } -+ if (file_size(&st) == 0) { -+ mode = COPY_UNCOMPRESSED; -+ } -+ } -+ -+ if (mode == COPY_TO_CACHE) { -+ gz_out = gzdopen(dup(fd_out), "wb"); -+ if (!gz_out) { -+ gzclose(gz_in); -+ close(fd_out); -+ free(tmp_name); -+ return -1; -+ } -+ } -+ -+ while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { -+ if (mode == COPY_TO_CACHE) { -+ ret = gzwrite(gz_out, buf, n); -+ } else { -+ ret = write(fd_out, buf, n); -+ } -+ if (ret != n) { -+ gzclose(gz_in); -+ if (gz_out) { -+ gzclose(gz_out); -+ } -+ close(fd_out); -+ unlink(tmp_name); -+ free(tmp_name); -+ return -1; -+ } -+ } -+ -+ gzclose(gz_in); -+ if (gz_out) { -+ gzclose(gz_out); -+ } -+ -+ /* get perms right on the tmp file */ -+ mask = umask(0); -+ fchmod(fd_out, 0666 & ~mask); -+ umask(mask); -+ -+ /* the close can fail on NFS if out of space */ -+ if (close(fd_out) == -1) { -+ unlink(tmp_name); -+ free(tmp_name); -+ return -1; -+ } -+ -+ unlink(dest); -+ -+ if (rename(tmp_name, dest) == -1) { -+ unlink(tmp_name); -+ free(tmp_name); -+ return -1; -+ } -+ -+ free(tmp_name); -+ -+ return 0; -+} -+ -+/* move a file to the cache, compressing it */ -+int move_file(const char *src, const char *dest) { -+ int ret; -+ -+ ret = _copy_file(src, dest, COPY_TO_CACHE); -+ if (ret != -1) unlink(src); -+ return ret; -+} -+ -+/* copy a file from the cache, decompressing it */ -+int copy_file(const char *src, const char *dest) { -+ return _copy_file(src, dest, COPY_FROM_CACHE); -+} -+#endif /* ENABLE_ZLIB */ -+ -+/* test if a file is zlib compressed */ -+int test_if_compressed(const char *filename) { -+ FILE *f; -+ -+ f = fopen(filename, "rb"); -+ if (!f) { -+ return 0; -+ } -+ -+ /* test if file starts with 1F8B, which is zlib's -+ * magic number */ -+ if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) { -+ fclose(f); -+ return 0; -+ } -+ -+ fclose(f); -+ return 1; -+} - - /* make sure a directory exists */ - int create_dir(const char *dir) -Index: manage-cache.sh -=================================================================== -RCS file: manage-cache.sh -diff -N manage-cache.sh ---- manage-cache.sh 1 Jan 1970 00:00:00 -0000 -+++ manage-cache.sh-cache.sh 12 May 2004 19:22:20 -0000 1.1 -@@ -0,0 +1,68 @@ -+#!/bin/bash -+# -+# 2004-05-12 lars@gustaebel.de -+ -+CCACHE_DIR=${CCACHE_DIR:-$HOME/.ccache} -+ -+echo "Do you want to compress or decompress the ccache in $CCACHE_DIR?" -+read -p "Type c or d: " mode -+ -+if [ "$mode" != "c" ] && [ "$mode" != "d" ] -+then -+ exit 1 -+fi -+ -+is_compressed() { -+ test "$(head -c 2 $1)" = $'\x1f\x8b' -+ return $? -+} -+ -+tmpfile=$(mktemp) -+ -+for dir in 0 1 2 3 4 5 6 7 8 9 a b c d e f -+do -+ # process ccache subdir -+ echo -n "$dir " -+ -+ # find cache files -+ find $CCACHE_DIR/$dir -type f -name '*-*' | -+ sort > $tmpfile -+ -+ oldsize=$(cat $CCACHE_DIR/$dir/stats | cut -d ' ' -f 13) -+ newsize=0 -+ -+ while read file -+ do -+ # empty files will be ignored since compressing -+ # them makes them bigger -+ test $(stat -c %s $file) -eq 0 && continue -+ -+ if [ $mode = c ] -+ then -+ if ! is_compressed $file -+ then -+ gzip $file -+ mv $file.gz $file -+ fi -+ else -+ if is_compressed $file -+ then -+ mv $file $file.gz -+ gzip -d $file.gz -+ fi -+ fi -+ -+ # calculate new size statistic for this subdir -+ let newsize=$newsize+$(stat -c "%B*%b" $file)/1024 -+ done < $tmpfile -+ -+ # update statistic file -+ read -a numbers < $CCACHE_DIR/$dir/stats -+ numbers[12]=$newsize -+ echo "${numbers[*]} " > $CCACHE_DIR/$dir/stats -+done -+echo -+ -+# clean up -+rm $tmpfile -+ -Index: Makefile.in -=================================================================== -RCS file: /home/cvsroot/lars/ccache/Makefile.in,v -retrieving revision 1.1.1.1.2.1 -retrieving revision 1.12 -diff -u -r1.1.1.1.2.1 -r1.12 ---- Makefile.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1 -+++ Makefile.in 21 Nov 2004 18:19:28 -0000 1.12 -@@ -11,6 +11,7 @@ - CFLAGS=@CFLAGS@ -I. - EXEEXT=@EXEEXT@ - -+LIBS= @LIBS@ - OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \ - cleanup.o snprintf.o unify.o - HEADERS = ccache.h mdfour.h -@@ -20,7 +21,7 @@ - docs: ccache.1 web/ccache-man.html - - ccache$(EXEEXT): $(OBJS) $(HEADERS) -- $(CC) $(CFLAGS) -o $@ $(OBJS) -+ $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) - - ccache.1: ccache.yo - -yodl2man -o ccache.1 ccache.yo diff --git a/CCache/debian/patches/03_long_options.diff b/CCache/debian/patches/03_long_options.diff deleted file mode 100644 index 3235c3806..000000000 --- a/CCache/debian/patches/03_long_options.diff +++ /dev/null @@ -1,133 +0,0 @@ -Index: ccache.c -=================================================================== ---- ccache.c (révision 7695) -+++ ccache.c (copie de travail) -@@ -22,6 +22,7 @@ - */ - - #include "ccache.h" -+#include - - /* the base cache directory */ - char *cache_dir = NULL; -@@ -885,14 +886,14 @@ - printf("\tcompiler [compile options] (via symbolic link)\n"); - printf("\nOptions:\n"); - -- printf("-s show statistics summary\n"); -- printf("-z zero statistics\n"); -- printf("-c run a cache cleanup\n"); -- printf("-C clear the cache completely\n"); -- printf("-F set maximum files in cache\n"); -- printf("-M set maximum size of cache (use G, M or K)\n"); -- printf("-h this help page\n"); -- printf("-V print version number\n"); -+ printf("-s, --show-stats show statistics summary\n"); -+ printf("-z, --zero-stats zero statistics\n"); -+ printf("-c, --cleanup run a cache cleanup\n"); -+ printf("-C, --clear clear the cache completely\n"); -+ printf("-F , --max-files= set maximum files in cache\n"); -+ printf("-M , --max-size= set maximum size of cache (use G, M or K)\n"); -+ printf("-h, --help this help page\n"); -+ printf("-V, --version print version number\n"); - } - - /* the main program when not doing a compile */ -@@ -901,7 +902,21 @@ - int c; - size_t v; - -- while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) { -+ static struct option long_options[] = -+ { -+ {"show-stats", no_argument, 0, 's'}, -+ {"zero-stats", no_argument, 0, 'z'}, -+ {"cleanup", no_argument, 0, 'c'}, -+ {"clear", no_argument, 0, 'C'}, -+ {"max-files", required_argument, 0, 'F'}, -+ {"max-size", required_argument, 0, 'M'}, -+ {"help", no_argument, 0, 'h'}, -+ {"version", no_argument, 0, 'V'}, -+ {0, 0, 0, 0} -+ }; -+ int option_index = 0; -+ -+ while ((c = getopt_long(argc, argv, "hszcCF:M:V", long_options, &option_index)) != -1) { - switch (c) { - case 'V': - printf("ccache version %s\n", CCACHE_VERSION); -Index: ccache.1 -=================================================================== ---- ccache.1 (révision 7695) -+++ ccache.1 (copie de travail) -@@ -23,14 +23,14 @@ - .nf - - ---s show statistics summary ---z zero statistics ---c run a cache cleanup ---C clear the cache completely ---F set maximum files in cache ---M set maximum size of cache (use G, M or K) ---h this help page ---V print version number -+\-s, \-\-show-stats show statistics summary -+\-z, \-\-zero-stats zero statistics -+\-c, \-\-cleanup run a cache cleanup -+\-C, \-\-clear clear the cache completely -+\-F , \-\-max-files= set maximum files in cache -+\-M , \-\-max-size= set maximum size of cache (use G, M or K) -+\-h, \-\-help this help page -+\-V, \-\-version print version number - - .fi - -@@ -43,22 +43,22 @@ - normal compiler options apply and you should refer to your compilers - documentation\&. - .PP --.IP "\fB-h\fP" -+.IP "\fB-h, --help\fP" - Print a options summary page - .IP --.IP "\fB-s\fP" -+.IP "\fB-s, --show-stats\fP" - Print the current statistics summary for the cache\&. The - statistics are stored spread across the subdirectories of the - cache\&. Using "ccache -s" adds up the statistics across all - subdirectories and prints the totals\&. - .IP --.IP "\fB-z\fP" -+.IP "\fB-z, --zero-stats\fP" - Zero the cache statistics\&. - .IP --.IP "\fB-V\fP" -+.IP "\fB-V, --version\fP" - Print the ccache version number - .IP --.IP "\fB-c\fP" -+.IP "\fB-c, --cleanup\fP" - Clean the cache and re-calculate the cache file count and - size totals\&. Normally the -c option should not be necessary as ccache - keeps the cache below the specified limits at runtime and keeps -@@ -66,16 +66,16 @@ - if you manually modify the cache contents or believe that the cache - size statistics may be inaccurate\&. - .IP --.IP "\fB-C\fP" -+.IP "\fB-C, --clear\fP" - Clear the entire cache, removing all cached files\&. - .IP --.IP "\fB-F maxfiles\fP" -+.IP "\fB-F , --max-files=\fP" - This sets the maximum number of files allowed in - the cache\&. The value is stored inside the cache directory and applies - to all future compiles\&. Due to the way the value is stored the actual - value used is always rounded down to the nearest multiple of 16\&. - .IP --.IP "\fB-M maxsize\fP" -+.IP "\fB-M , --max-size=\fP" - This sets the maximum cache size\&. You can specify - a value in gigabytes, megabytes or kilobytes by appending a G, M or K - to the value\&. The default is gigabytes\&. The actual value stored is diff --git a/CCache/debian/patches/04_ignore_profile.diff b/CCache/debian/patches/04_ignore_profile.diff deleted file mode 100644 index 568375092..000000000 --- a/CCache/debian/patches/04_ignore_profile.diff +++ /dev/null @@ -1,13 +0,0 @@ -diff -ru ccache-2.4/ccache.c ccache-2.4-tp/ccache.c ---- ccache.c 2007-05-20 03:14:19.000000000 +1000 -+++ ccache.c 2007-05-20 03:17:54.000000000 +1000 -@@ -641,6 +641,9 @@ - - /* these are too hard */ - if (strcmp(argv[i], "-fbranch-probabilities")==0 || -+ strcmp(argv[i], "-fprofile-arcs") == 0 || -+ strcmp(argv[i], "-ftest-coverage") == 0 || -+ strcmp(argv[i], "--coverage") == 0 || - strcmp(argv[i], "-M") == 0 || - strcmp(argv[i], "-MM") == 0 || - strcmp(argv[i], "-x") == 0) { diff --git a/CCache/debian/patches/05_nfs_fix.diff b/CCache/debian/patches/05_nfs_fix.diff deleted file mode 100644 index 662d97639..000000000 --- a/CCache/debian/patches/05_nfs_fix.diff +++ /dev/null @@ -1,45 +0,0 @@ ---- ccache.1.orig 2007-05-20 17:30:57.000000000 +1200 -+++ ccache.1 2007-05-20 17:31:27.000000000 +1200 -@@ -367,12 +367,6 @@ - .IP o - ccache avoids a double call to cpp on a cache miss - .PP --.SH "BUGS" --.PP --When the cache is stored on an NFS filesystem, the filesystem must be --exported with the \fBno_subtree_check\fP option to make renames between --directories reliable\&. --.PP - .SH "CREDITS" - .PP - Thanks to the following people for their contributions to ccache ---- util.c.patched 2007-05-20 18:19:11.000000000 +1200 -+++ util.c 2007-05-20 18:20:55.000000000 +1200 -@@ -58,9 +58,26 @@ - } - } - -+static int safe_rename(const char* oldpath, const char* newpath) -+{ -+ /* safe_rename is for creating entries in the cache. -+ -+ Works like rename(), but it never overwrites an existing -+ cache entry. This avoids corruption on NFS. */ -+ int status = link( oldpath, newpath ); -+ if( status == 0 || errno == EEXIST ) -+ { -+ return unlink( oldpath ); -+ } -+ else -+ { -+ return -1; -+ } -+} -+ - /* move a file using rename */ - int move_file(const char *src, const char *dest) { -- return rename(src, dest); -+ return safe_rename(src, dest); - } - - /* copy a file - used when hard links don't work diff --git a/CCache/debian/patches/06_md.diff b/CCache/debian/patches/06_md.diff deleted file mode 100644 index 3f68850ca..000000000 --- a/CCache/debian/patches/06_md.diff +++ /dev/null @@ -1,77 +0,0 @@ ---- ccache.c Mon Sep 13 11:38:30 2004 -+++ ccache.c Thu Jun 21 22:17:32 2007 -@@ -627,6 +627,13 @@ static void process_args(int argc, char - int found_S_opt = 0; - struct stat st; - char *e; -+ /* is gcc being asked to output dependencies? */ -+ int generating_dependencies = 0; -+ /* is the dependency makefile name overridden with -MF? */ -+ int dependency_filename_specified = 0; -+ /* is the dependency makefile target name specified with -MQ or -MF? */ -+ int dependency_target_specified = 0; -+ - - stripped_args = args_init(0, NULL); - -@@ -702,6 +709,18 @@ static void process_args(int argc, char - continue; - } - -+ /* These options require special handling, because they -+ behave differently with gcc -E, when the output -+ file is not specified. */ -+ -+ if (strcmp(argv[i], "-MD") == 0 || strcmp(argv[i], "-MMD") == 0) { -+ generating_dependencies = 1; -+ } else if (strcmp(argv[i], "-MF") == 0) { -+ dependency_filename_specified = 1; -+ } else if (strcmp(argv[i], "-MQ") == 0 || strcmp(argv[i], "-MT") == 0) { -+ dependency_target_specified = 1; -+ } -+ - /* options that take an argument */ - { - const char *opts[] = {"-I", "-include", "-imacros", "-iprefix", -@@ -812,6 +831,41 @@ static void process_args(int argc, char - } - p[1] = found_S_opt ? 's' : 'o'; - p[2] = 0; -+ } -+ -+ /* If dependencies are generated, configure the preprocessor */ -+ -+ if (generating_dependencies && output_file) { -+ if (!dependency_filename_specified) { -+ char *default_depfile_name = x_strdup(output_file); -+ char *p = strrchr(default_depfile_name, '.'); -+ -+ if (p) { -+ if (strlen(p) < 2) { -+ stats_update(STATS_ARGS); -+ failed(); -+ return; -+ } -+ *p = 0; -+ } -+ else { -+ int len = p - default_depfile_name; -+ -+ p = x_malloc(len + 3); -+ strncpy(default_depfile_name, p, len - 1); -+ free(default_depfile_name); -+ default_depfile_name = p; -+ } -+ -+ strcat(default_depfile_name, ".d"); -+ args_add(stripped_args, "-MF"); -+ args_add(stripped_args, default_depfile_name); -+ } -+ -+ if (!dependency_target_specified) { -+ args_add(stripped_args, "-MT"); -+ args_add(stripped_args, output_file); -+ } - } - - /* cope with -o /dev/null */ diff --git a/CCache/debian/patches/07_cachedirtag.diff b/CCache/debian/patches/07_cachedirtag.diff deleted file mode 100644 index 683b48d14..000000000 --- a/CCache/debian/patches/07_cachedirtag.diff +++ /dev/null @@ -1,75 +0,0 @@ -Index: ccache.c -=================================================================== ---- ccache.c (révision 7695) -+++ ccache.c (copie de travail) -@@ -1029,6 +1029,14 @@ - exit(1); - } - -+ if (!getenv("CCACHE_READONLY")) { -+ if (create_cachedirtag(cache_dir) != 0) { -+ fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n", -+ cache_dir, strerror(errno)); -+ exit(1); -+ } -+ } -+ - ccache(argc, argv); - return 1; - } -Index: ccache.h -=================================================================== ---- ccache.h (révision 7695) -+++ ccache.h (copie de travail) -@@ -81,6 +81,7 @@ - int copy_file(const char *src, const char *dest); - - int create_dir(const char *dir); -+int create_cachedirtag(const char *dir); - void x_asprintf(char **ptr, const char *format, ...); - char *x_strdup(const char *s); - void *x_realloc(void *ptr, size_t size); -Index: util.c -=================================================================== ---- util.c (révision 7695) -+++ util.c (copie de travail) -@@ -138,6 +138,39 @@ - return 0; - } - -+char const CACHEDIR_TAG[] = -+ "Signature: 8a477f597d28d172789f06886806bc55\n" -+ "# This file is a cache directory tag created by ccache.\n" -+ "# For information about cache directory tags, see:\n" -+ "# http://www.brynosaurus.com/cachedir/\n"; -+ -+int create_cachedirtag(const char *dir) -+{ -+ char *filename; -+ struct stat st; -+ FILE *f; -+ x_asprintf(&filename, "%s/CACHEDIR.TAG", dir); -+ if (stat(filename, &st) == 0) { -+ if (S_ISREG(st.st_mode)) { -+ goto success; -+ } -+ errno = EEXIST; -+ goto error; -+ } -+ f = fopen(filename, "w"); -+ if (!f) goto error; -+ if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) { -+ goto error; -+ } -+ if (fclose(f)) goto error; -+success: -+ free(filename); -+ return 0; -+error: -+ free(filename); -+ return 1; -+} -+ - /* - this is like asprintf() but dies if the malloc fails - note that we use vsnprintf in a rather poor way to make this more portable diff --git a/CCache/debian/patches/08_manpage_hyphens.diff b/CCache/debian/patches/08_manpage_hyphens.diff deleted file mode 100644 index 55ced4a23..000000000 --- a/CCache/debian/patches/08_manpage_hyphens.diff +++ /dev/null @@ -1,89 +0,0 @@ -Index: ccache.1 -=================================================================== ---- ccache.1 (révision 7695) -+++ ccache.1 (copie de travail) -@@ -49,7 +49,7 @@ - .IP "\fB-s\fP" - Print the current statistics summary for the cache\&. The - statistics are stored spread across the subdirectories of the --cache\&. Using "ccache -s" adds up the statistics across all -+cache\&. Using "ccache \-s" adds up the statistics across all - subdirectories and prints the totals\&. - .IP - .IP "\fB-z\fP" -@@ -60,7 +60,7 @@ - .IP - .IP "\fB-c\fP" - Clean the cache and re-calculate the cache file count and --size totals\&. Normally the -c option should not be necessary as ccache -+size totals\&. Normally the \-c option should not be necessary as ccache - keeps the cache below the specified limits at runtime and keeps - statistics up to date on each compile\&. This option is mostly useful - if you manually modify the cache contents or believe that the cache -@@ -100,9 +100,9 @@ - - - cp ccache /usr/local/bin/ -- ln -s /usr/local/bin/ccache /usr/local/bin/gcc -- ln -s /usr/local/bin/ccache /usr/local/bin/g++ -- ln -s /usr/local/bin/ccache /usr/local/bin/cc -+ ln \-s /usr/local/bin/ccache /usr/local/bin/gcc -+ ln \-s /usr/local/bin/ccache /usr/local/bin/g++ -+ ln \-s /usr/local/bin/ccache /usr/local/bin/cc - - .fi - -@@ -118,7 +118,7 @@ - .PP - When run as a compiler front end ccache usually just takes the same - command line options as the compiler you are using\&. The only exception --to this is the option \&'--ccache-skip\&'\&. That option can be used to tell -+to this is the option \&'\-\-ccache-skip\&'\&. That option can be used to tell - ccache that the next option is definitely not a input filename, and - should be passed along to the compiler as-is\&. - .PP -@@ -128,7 +128,7 @@ - of the resulting object file (among other things)\&. The heuristic - ccache uses in this parse is that any string on the command line that - exists as a file is treated as an input file name (usually a C --file)\&. By using --ccache-skip you can force an option to not be -+file)\&. By using \-\-ccache-skip you can force an option to not be - treated as an input file name and instead be passed along to the - compiler as a command line option\&. - .PP -@@ -238,7 +238,7 @@ - .IP "\fBCCACHE_UNIFY\fP" - If you set the environment variable CCACHE_UNIFY - then ccache will use the C/C++ unifier when hashing the pre-processor --output if -g is not used in the compile\&. The unifier is slower than a -+output if \-g is not used in the compile\&. The unifier is slower than a - normal hash, so setting this environment variable loses a little bit - of speed, but it means that ccache can take advantage of not - recompiling when the changes to the source code consist of -@@ -262,7 +262,7 @@ - .PP - By default ccache has a one gigabyte limit on the cache size and no - maximum number of files\&. You can set a different limit using the --"ccache -M" and "ccache -F" options, which set the size and number of -+"ccache \-M" and "ccache \-F" options, which set the size and number of - files limits\&. - .PP - When these limits are reached ccache will reduce the cache to 20% -@@ -276,7 +276,7 @@ - that it is the same code by forming a hash of: - .PP - .IP o --the pre-processor output from running the compiler with -E -+the pre-processor output from running the compiler with \-E - .IP o - the command line options - .IP o -@@ -331,7 +331,7 @@ - .IP o - Make sure that the setgid bit is set on all directories in the - cache\&. This tells the filesystem to inherit group ownership for new --directories\&. The command "chmod g+s `find $CCACHE_DIR -type d`" might -+directories\&. The command "chmod g+s `find $CCACHE_DIR \-type d`" might - be useful for this\&. - .PP - .SH "HISTORY" diff --git a/CCache/debian/patches/09_respect_ldflags.diff b/CCache/debian/patches/09_respect_ldflags.diff deleted file mode 100644 index 0ce2c2de3..000000000 --- a/CCache/debian/patches/09_respect_ldflags.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- Makefile.in.orig 2008-03-23 17:01:19.000000000 +1300 -+++ Makefile.in 2008-03-23 17:03:03.000000000 +1300 -@@ -21,7 +21,7 @@ - docs: ccache.1 web/ccache-man.html - - ccache$(EXEEXT): $(OBJS) $(HEADERS) -- $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS) -+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) - - ccache.1: ccache.yo - -yodl2man -o ccache.1 ccache.yo diff --git a/CCache/debian/patches/10_lru_cleanup.diff b/CCache/debian/patches/10_lru_cleanup.diff deleted file mode 100644 index 24463e529..000000000 --- a/CCache/debian/patches/10_lru_cleanup.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- ccache.c (révision 8804) -+++ ccache.c (copie de travail) -@@ -481,6 +481,9 @@ - return; - } - -+ /* update timestamps for LRU cleanup -+ also gives output_file a sensible mtime when hard-linking (for make) */ -+ utime(hashname, NULL); - utime(stderr_file, NULL); - - if (strcmp(output_file, "/dev/null") == 0) { -@@ -513,10 +516,6 @@ - failed(); - } - } -- if (ret == 0) { -- /* update the mtime on the file so that make doesn't get confused */ -- utime(output_file, NULL); -- } - - /* get rid of the intermediate preprocessor file */ - if (i_tmpfile) { diff --git a/CCache/debian/patches/11_utimes.diff b/CCache/debian/patches/11_utimes.diff deleted file mode 100644 index 2886bf3d6..000000000 --- a/CCache/debian/patches/11_utimes.diff +++ /dev/null @@ -1,85 +0,0 @@ ---- ccache.c 2004-09-13 03:38:30.000000000 -0700 -+++ ccache.c 2006-06-09 16:29:16.695117780 -0700 -@@ -481,8 +481,13 @@ - - /* update timestamps for LRU cleanup - also gives output_file a sensible mtime when hard-linking (for make) */ -+#ifdef HAVE_UTIMES -+ utimes(hashname, NULL); -+ utimes(stderr_file, NULL); -+#else - utime(hashname, NULL); - utime(stderr_file, NULL); -+#endif - - if (strcmp(output_file, "/dev/null") == 0) { - ret = 0; ---- ccache.h 2004-09-13 03:38:30.000000000 -0700 -+++ ccache.h 2006-06-09 16:28:16.601658626 -0700 -@@ -22,6 +22,9 @@ - #ifdef HAVE_PWD_H - #include - #endif -+#ifdef HAVE_SYS_TIME_H -+#include -+#endif - - #define STATUS_NOTFOUND 3 - #define STATUS_FATAL 4 ---- config.h.in 2003-09-27 21:48:17.000000000 -0700 -+++ config.h.in 2006-06-09 16:25:43.000000000 -0700 -@@ -19,6 +19,9 @@ - /* Define to 1 if you have the `gethostname' function. */ - #undef HAVE_GETHOSTNAME - -+/* Define to 1 if you have the `getpwuid' function. */ -+#undef HAVE_GETPWUID -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_INTTYPES_H - -@@ -31,6 +34,9 @@ - /* Define to 1 if you have the header file, and it defines `DIR'. */ - #undef HAVE_NDIR_H - -+/* Define to 1 if you have the header file. */ -+#undef HAVE_PWD_H -+ - /* Define to 1 if you have the `realpath' function. */ - #undef HAVE_REALPATH - -@@ -60,6 +66,9 @@ - /* Define to 1 if you have the header file. */ - #undef HAVE_SYS_STAT_H - -+/* Define to 1 if you have the header file. */ -+#undef HAVE_SYS_TIME_H -+ - /* Define to 1 if you have the header file. */ - #undef HAVE_SYS_TYPES_H - -@@ -69,6 +78,9 @@ - /* Define to 1 if you have the header file. */ - #undef HAVE_UNISTD_H - -+/* Define to 1 if you have the `utimes' function. */ -+#undef HAVE_UTIMES -+ - /* Define to 1 if you have the `vasprintf' function. */ - #undef HAVE_VASPRINTF - ---- configure.in 2004-09-13 03:38:30.000000000 -0700 -+++ configure.in 2006-06-09 16:25:15.541288184 -0700 -@@ -27,10 +27,11 @@ - AC_HEADER_TIME - AC_HEADER_SYS_WAIT - --AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h) -+AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h) - - AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp) - AC_CHECK_FUNCS(gethostname getpwuid) -+AC_CHECK_FUNCS(utimes) - - AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [ - AC_TRY_COMPILE( diff --git a/CCache/debian/patches/12_cachesize_permissions.diff b/CCache/debian/patches/12_cachesize_permissions.diff deleted file mode 100644 index 28801b771..000000000 --- a/CCache/debian/patches/12_cachesize_permissions.diff +++ /dev/null @@ -1,83 +0,0 @@ ---- stats.c (révision 8804) -+++ stats.c (copie de travail) -@@ -286,7 +286,7 @@ - - - /* set the per directory limits */ --void stats_set_limits(long maxfiles, long maxsize) -+int stats_set_limits(long maxfiles, long maxsize) - { - int dir; - unsigned counters[STATS_END]; -@@ -298,7 +298,9 @@ - maxsize /= 16; - } - -- create_dir(cache_dir); -+ if (create_dir(cache_dir) != 0) { -+ return 1; -+ } - - /* set the limits in each directory */ - for (dir=0;dir<=0xF;dir++) { -@@ -306,7 +308,9 @@ - int fd; - - x_asprintf(&cdir, "%s/%1x", cache_dir, dir); -- create_dir(cdir); -+ if (create_dir(cdir) != 0) { -+ return 1; -+ } - x_asprintf(&fname, "%s/stats", cdir); - free(cdir); - -@@ -326,6 +330,8 @@ - } - free(fname); - } -+ -+ return 0; - } - - /* set the per directory sizes */ ---- ccache.c (révision 8804) -+++ ccache.c (copie de travail) -@@ -935,15 +934,23 @@ - case 'F': - check_cache_dir(); - v = atoi(optarg); -- stats_set_limits(v, -1); -- printf("Set cache file limit to %u\n", (unsigned)v); -+ if (stats_set_limits(v, -1) == 0) { -+ printf("Set cache file limit to %u\n", (unsigned)v); -+ } else { -+ printf("Could not set cache file limit.\n"); -+ exit(1); -+ } - break; - - case 'M': - check_cache_dir(); - v = value_units(optarg); -- stats_set_limits(-1, v); -- printf("Set cache size limit to %uk\n", (unsigned)v); -+ if (stats_set_limits(-1, v) == 0) { -+ printf("Set cache size limit to %uk\n", (unsigned)v); -+ } else { -+ printf("Could not set cache size limit.\n"); -+ exit(1); -+ } - break; - - default: ---- ccache.h (révision 8804) -+++ ccache.h (copie de travail) -@@ -101,7 +101,7 @@ - void stats_summary(void); - void stats_tocache(size_t size); - void stats_read(const char *stats_file, unsigned counters[STATS_END]); --void stats_set_limits(long maxfiles, long maxsize); -+int stats_set_limits(long maxfiles, long maxsize); - size_t value_units(const char *s); - void display_size(unsigned v); - void stats_set_sizes(const char *dir, size_t num_files, size_t total_size); diff --git a/CCache/debian/patches/13_html_links.diff b/CCache/debian/patches/13_html_links.diff deleted file mode 100644 index dadf1b6c2..000000000 --- a/CCache/debian/patches/13_html_links.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- web/index.html~ 2004-09-13 13:38:30.000000000 +0300 -+++ web/index.html 2004-09-26 01:04:38.458008118 +0300 -@@ -29,10 +29,10 @@ -
  • fixed handling of HOME environment variable - - --See the manual page for details -+See the manual page for details - on the new options.

    - --You can get this release from the download directory -+You can get this release from the download directory - -

    NOTE! This release changes the hash input slighly, so you will - probably find that you will not get any hits against your existing -@@ -87,7 +87,7 @@ - -

    Documentation

    - --See the manual page -+See the manual page - - -

    Performance

    -@@ -116,7 +116,7 @@ -

    Download

    - - You can download the latest release from the download directory.

    -+href="http://ccache.samba.org/ftp/ccache/">download directory.

    - - For the bleeding edge, you can fetch ccache via CVS or - rsync. To fetch via cvs use the following command: diff --git a/CCache/debian/patches/14_hardlink_doc.diff b/CCache/debian/patches/14_hardlink_doc.diff deleted file mode 100644 index bd9e25ba6..000000000 --- a/CCache/debian/patches/14_hardlink_doc.diff +++ /dev/null @@ -1,48 +0,0 @@ -Index: ccache.1 -=================================================================== -RCS file: /cvsroot/ccache/ccache.1,v -retrieving revision 1.26 -diff -u -r1.26 ccache.1 ---- ccache.1 24 Nov 2005 21:10:08 -0000 1.26 -+++ ccache.1 21 Jul 2007 21:03:32 -0000 -@@ -330,7 +330,7 @@ - .IP o - Use the same \fBCCACHE_DIR\fP environment variable setting - .IP o --Set the \fBCCACHE_NOLINK\fP environment variable -+Unset the \fBCCACHE_HARDLINK\fP environment variable - .IP o - Make sure everyone sets the CCACHE_UMASK environment variable - to 002, this ensures that cached files are accessible to everyone in -Index: ccache.yo -=================================================================== -RCS file: /cvsroot/ccache/ccache.yo,v -retrieving revision 1.27 -diff -u -r1.27 ccache.yo ---- ccache.yo 24 Nov 2005 21:54:09 -0000 1.27 -+++ ccache.yo 21 Jul 2007 21:03:32 -0000 -@@ -289,7 +289,7 @@ - - itemize( - it() Use the same bf(CCACHE_DIR) environment variable setting -- it() Set the bf(CCACHE_NOLINK) environment variable -+ it() Unset the bf(CCACHE_HARDLINK) environment variable - it() Make sure everyone sets the CCACHE_UMASK environment variable - to 002, this ensures that cached files are accessible to everyone in - the group. -Index: web/ccache-man.html -=================================================================== -RCS file: /cvsroot/ccache/web/ccache-man.html,v -retrieving revision 1.25 -diff -u -r1.25 ccache-man.html ---- web/ccache-man.html 13 Sep 2004 10:38:17 -0000 1.25 -+++ web/ccache-man.html 21 Jul 2007 21:03:32 -0000 -@@ -256,7 +256,7 @@ - following conditions need to be met: -

      -
    • Use the same CCACHE_DIR environment variable setting --
    • Set the CCACHE_NOLINK environment variable -+
    • Unset the CCACHE_HARDLINK environment variable -
    • Make sure everyone sets the CCACHE_UMASK environment variable - to 002, this ensures that cached files are accessible to everyone in - the group. diff --git a/CCache/debian/patches/CREDITS b/CCache/debian/patches/CREDITS deleted file mode 100644 index c4e323b7b..000000000 --- a/CCache/debian/patches/CREDITS +++ /dev/null @@ -1,47 +0,0 @@ -01_no_home.diff: - Francois Marier - Made especially for the Debian package. - -02_ccache_compressed.diff: - Lars Gustäbel - http://www.gustaebel.de/lars/ccache/ (downloaded on 2007-05-20) - -03_long_options.diff: - Francois Marier - Made especially for the Debian package. - -04_ignore_profile.diff: - Ted Percival - http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=20;filename=ccache-profile.patch;att=1;bug=215849 - -05_nfs_fix.diff: - John Coiner - http://lists.samba.org/archive/ccache/2007q1/000265.html - -06_md.diff: - Andrea Bittau - http://darkircop.org/ccache/ccache-2.4-md.patch (downloaded on 2007-06-30) - -07_cachedirtag.diff: - Karl Chen - http://lists.samba.org/archive/ccache/2008q1/000316.html (downloaded on 2008-02-02) - -08_manpage_hyphens.diff: - Francois Marier - Made especially for the Debian package. - -09_respect_ldflags.diff: - Lisa Seelye - http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-respectflags.patch?rev=1.1&view=markup - -10_lru_cleanup.diff: - RW - http://lists.samba.org/archive/ccache/2008q2/000339.html (downloaded on 2008-04-11) - -11_utimes.diff: - Robin H. Johnson - http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-utimes.patch?rev=1.1&view=markup - -12_cachesize_permissions.diff: - Francois Marier - Made especially for the Debian package to fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=332527 diff --git a/CCache/debian/rules b/CCache/debian/rules deleted file mode 100644 index c5b538b78..000000000 --- a/CCache/debian/rules +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/make -f -# Sample debian/rules that uses debhelper. -# GNU copyright 1997 to 1999 by Joey Hess. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -# These are used for cross-compiling and for saving the configure script -# from having to guess our platform (since we know it already) -export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) -export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) - -ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) - confflags += --build $(DEB_HOST_GNU_TYPE) -else - confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) -endif - -ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) - CFLAGS += -g -endif -ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) - INSTALL_PROGRAM += -s -endif - -config.status: configure - dh_testdir - - # Apply Debian specific patches - cp $(CURDIR)/ccache.c $(CURDIR)/ccache.c.unpatched - cp $(CURDIR)/util.c $(CURDIR)/util.c.unpatched - cp $(CURDIR)/ccache.1 $(CURDIR)/ccache.1.unpatched - cp $(CURDIR)/ccache.h $(CURDIR)/ccache.h.unpatched - cp $(CURDIR)/ccache.yo $(CURDIR)/ccache.yo.unpatched - cp $(CURDIR)/config.h.in $(CURDIR)/config.h.in.unpatched - cp $(CURDIR)/configure $(CURDIR)/configure.unpatched - cp $(CURDIR)/configure.in $(CURDIR)/configure.in.unpatched - cp $(CURDIR)/Makefile.in $(CURDIR)/Makefile.in.unpatched - if test ! -f patch-stamp; then \ - for patch in $(CURDIR)/debian/patches/*.diff ;\ - do \ - echo APPLYING PATCH\: $${patch##*/};\ - patch -p0 < $$patch ;\ - done ;\ - touch patch-stamp ;\ - fi - chmod +x $(CURDIR)/manage-cache.sh - - ./configure $(confflags) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info - -build: build-stamp - -build-stamp: config.status - dh_testdir - - $(MAKE) - - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp - - # Unapply patches - -test -r $(CURDIR)/ccache.c.unpatched && mv $(CURDIR)/ccache.c.unpatched $(CURDIR)/ccache.c - -test -r $(CURDIR)/util.c.unpatched && mv $(CURDIR)/util.c.unpatched $(CURDIR)/util.c - -test -r $(CURDIR)/ccache.1.unpatched && mv $(CURDIR)/ccache.1.unpatched $(CURDIR)/ccache.1 - -test -r $(CURDIR)/ccache.h.unpatched && mv $(CURDIR)/ccache.h.unpatched $(CURDIR)/ccache.h - -test -r $(CURDIR)/ccache.yo.unpatched && mv $(CURDIR)/ccache.yo.unpatched $(CURDIR)/ccache.yo - -test -r $(CURDIR)/config.h.in.unpatched && mv $(CURDIR)/config.h.in.unpatched $(CURDIR)/config.h.in - -test -r $(CURDIR)/configure.unpatched && mv $(CURDIR)/configure.unpatched $(CURDIR)/configure - -test -r $(CURDIR)/configure.in.unpatched && mv $(CURDIR)/configure.in.unpatched $(CURDIR)/configure.in - -test -r $(CURDIR)/Makefile.in.unpatched && mv $(CURDIR)/Makefile.in.unpatched $(CURDIR)/Makefile.in - -rm -f $(CURDIR)/manage-cache.sh - -rm -f patch-stamp - - [ ! -f Makefile ] || $(MAKE) distclean - - dh_clean - - # Update config.sub and config.guess - -test -r /usr/share/misc/config.sub && \ - cp -f /usr/share/misc/config.sub config.sub - -test -r /usr/share/misc/config.guess && \ - cp -f /usr/share/misc/config.guess config.guess - - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # Add here commands to install the package into debian/ccache. - $(MAKE) install prefix=$(CURDIR)/debian/ccache/usr - - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++ - set -e; for ver in 2.95 3.0 3.2 3.3 3.4 4.0 4.1 4.2 4.3; do \ - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc-$$ver; \ - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc-$$ver; \ - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++-$$ver; \ - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++-$$ver; \ - done - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/cc - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/c++ - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++ - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-c++ - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-cc - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-g++ - ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-gcc - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installdocs - dh_installexamples - dh_installmenu - dh_installcron - dh_installman - dh_installinfo - dh_installchangelogs - dh_link - dh_strip - dh_compress - dh_fixperms - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install diff --git a/CCache/debian/update-ccache b/CCache/debian/update-ccache deleted file mode 100644 index 0ef97a140..000000000 --- a/CCache/debian/update-ccache +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# -# Update compiler links to ccache (in /usr/local/bin) -# -# The idea is that /usr/local/bin is ahead of /usr/bin in your PATH, so adding -# the link /usr/local/bin/cc -> /usr/bin/ccache means that it is run instead of -# /usr/bin/cc -# -# Written by: Behan Webster -# - -DIRECTORY=/usr/local/bin -CCACHE=/usr/bin/ccache -CCDIR=/usr/lib/ccache - -usage() { - echo "Usage: `basename $0` [--directory ] [--remove]" - exit 0 -} - -while [ $# -gt 0 ] ; do - case "$1" in - -d*|--d*|--directory) DIRECTORY=$2; shift; shift;; - -h*|--h*|--help) usage;; - -r*|--r*|--remove) REMOVE=1; shift;; - -t*|--t*|--test) TEST=echo; shift;; - esac -done - -for FILE in `cd $CCDIR; ls` ; do - LINK=$DIRECTORY/$FILE - if [ -z "$REMOVE" ] ; then - # Add link - $TEST ln -fs $CCACHE $LINK - else - # Remove link - if [ -L "$LINK" ] ; then - $TEST rm -f $LINK - fi - fi -done - -# vim: sw=4 ts=4 diff --git a/CCache/debian/watch b/CCache/debian/watch deleted file mode 100644 index a72959e50..000000000 --- a/CCache/debian/watch +++ /dev/null @@ -1,2 +0,0 @@ -version=2 -http://samba.org/ftp/ccache/ccache-(.*)\.tar\.gz diff --git a/CCache/execute.c b/CCache/execute.c deleted file mode 100644 index 165b91e66..000000000 --- a/CCache/execute.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - Copyright (C) Andrew Tridgell 2002 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "ccache.h" - -#ifdef _WIN32 -char *argvtos(char **argv) -{ - int i, len; - char *ptr, *str; - - for (i = 0, len = 0; argv[i]; i++) { - len += strlen(argv[i]) + 3; - } - - str = ptr = (char *)malloc(len + 1); - if (str == NULL) - return NULL; - - for (i = 0; argv[i]; i++) { - len = strlen(argv[i]); - *ptr++ = '"'; - memcpy(ptr, argv[i], len); - ptr += len; - *ptr++ = '"'; - *ptr++ = ' '; - } - *ptr = 0; - - return str; -} -#endif - -/* - execute a compiler backend, capturing all output to the given paths - the full path to the compiler to run is in argv[0] -*/ -int execute(char **argv, - const char *path_stdout, - const char *path_stderr) -{ -#ifdef _WIN32 - -#if 1 - PROCESS_INFORMATION pinfo; - STARTUPINFO sinfo; - BOOL ret; - DWORD exitcode; - char *args; - HANDLE fd_out, fd_err; - SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE}; - - /* TODO: needs moving after possible exit() below, but before stdout is redirected */ - if (ccache_verbose) { - display_execute_args(argv); - } - - fd_out = CreateFile(path_stdout, GENERIC_WRITE, 0, &sa, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); - if (fd_out == INVALID_HANDLE_VALUE) { - return STATUS_NOCACHE; - } - - fd_err = CreateFile(path_stderr, GENERIC_WRITE, 0, &sa, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); - if (fd_err == INVALID_HANDLE_VALUE) { - return STATUS_NOCACHE; - } - - ZeroMemory(&pinfo, sizeof(PROCESS_INFORMATION)); - ZeroMemory(&sinfo, sizeof(STARTUPINFO)); - - sinfo.cb = sizeof(STARTUPINFO); - sinfo.hStdError = fd_err; - sinfo.hStdOutput = fd_out; - sinfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE); - sinfo.dwFlags |= STARTF_USESTDHANDLES; - - args = argvtos(argv); - - ret = CreateProcessA(argv[0], args, NULL, NULL, TRUE, 0, NULL, NULL, - &sinfo, &pinfo); - - free(args); - CloseHandle(fd_out); - CloseHandle(fd_err); - - if (ret == 0) - return -1; - - WaitForSingleObject(pinfo.hProcess, INFINITE); - GetExitCodeProcess(pinfo.hProcess, &exitcode); - CloseHandle(pinfo.hProcess); - CloseHandle(pinfo.hThread); - - return exitcode; -#else /* possibly slightly faster */ - /* needs fixing to quote commandline options to handle spaces in CCACHE_DIR etc */ - int status = -2; - int fd, std_od = -1, std_ed = -1; - - /* TODO: needs moving after possible exit() below, but before stdout is redirected */ - if (ccache_verbose) { - display_execute_args(argv); - } - - unlink(path_stdout); - std_od = _dup(1); - fd = _open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); - if (fd == -1) { - exit(STATUS_NOCACHE); - } - _dup2(fd, 1); - _close(fd); - - unlink(path_stderr); - fd = _open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); - std_ed = _dup(2); - if (fd == -1) { - exit(STATUS_NOCACHE); - } - _dup2(fd, 2); - _close(fd); - - /* Spawn process (_exec* familly doesn't return) */ - status = _spawnv(_P_WAIT, argv[0], (const char **)argv); - - /* Restore descriptors */ - if (std_od != -1) _dup2(std_od, 1); - if (std_ed != -1) _dup2(std_ed, 2); - _flushall(); - - return (status>0); - -#endif - -#else - pid_t pid; - int status; - - pid = fork(); - if (pid == -1) fatal("Failed to fork"); - - if (pid == 0) { - int fd; - - /* TODO: needs moving after possible exit() below, but before stdout is redirected */ - if (ccache_verbose) { - display_execute_args(argv); - } - - unlink(path_stdout); - fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); - if (fd == -1) { - exit(STATUS_NOCACHE); - } - dup2(fd, 1); - close(fd); - - unlink(path_stderr); - fd = open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); - if (fd == -1) { - exit(STATUS_NOCACHE); - } - dup2(fd, 2); - close(fd); - - exit(execv(argv[0], argv)); - } - - if (waitpid(pid, &status, 0) != pid) { - fatal("waitpid failed"); - } - - if (WEXITSTATUS(status) == 0 && WIFSIGNALED(status)) { - return -1; - } - - return WEXITSTATUS(status); -#endif -} - - -/* - find an executable by name in $PATH. Exclude any that are links to exclude_name -*/ -char *find_executable(const char *name, const char *exclude_name) -{ -#if _WIN32 - (void)exclude_name; - DWORD ret; - char namebuf[MAX_PATH]; - - ret = SearchPathA(getenv("CCACHE_PATH"), name, ".exe", - sizeof(namebuf), namebuf, NULL); - if (ret != 0) { - return x_strdup(namebuf); - } - - return NULL; -#else - char *path; - char *tok; - struct stat st1, st2; - - if (*name == '/') { - return x_strdup(name); - } - - path = getenv("CCACHE_PATH"); - if (!path) { - path = getenv("PATH"); - } - if (!path) { - cc_log("no PATH variable!?\n"); - stats_update(STATS_ENVIRONMMENT); - return NULL; - } - - path = x_strdup(path); - - /* search the path looking for the first compiler of the right name - that isn't us */ - for (tok=strtok(path,":"); tok; tok = strtok(NULL, ":")) { - char *fname; - x_asprintf(&fname, "%s/%s", tok, name); - /* look for a normal executable file */ - if (access(fname, X_OK) == 0 && - lstat(fname, &st1) == 0 && - stat(fname, &st2) == 0 && - S_ISREG(st2.st_mode)) { - /* if its a symlink then ensure it doesn't - point at something called exclude_name */ - if (S_ISLNK(st1.st_mode)) { - char *buf = x_realpath(fname); - if (buf) { - char *p = str_basename(buf); - if (strcmp(p, exclude_name) == 0) { - /* its a link to "ccache" ! */ - free(p); - free(buf); - continue; - } - free(buf); - free(p); - } - } - - /* found it! */ - free(path); - return fname; - } - free(fname); - } - - return NULL; -#endif -} - -void display_execute_args(char **argv) -{ - if (argv) { - printf("ccache executing: "); - while (*argv) { - printf("%s ", *argv); - ++argv; - } - printf("\n"); - fflush(stdout); - } -} diff --git a/CCache/hash.c b/CCache/hash.c deleted file mode 100644 index d0ce8a6ba..000000000 --- a/CCache/hash.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - Copyright (C) Andrew Tridgell 2002 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -/* - simple front-end functions to mdfour code -*/ - -#include "ccache.h" - -static struct mdfour md; - -void hash_buffer(const char *s, int len) -{ - mdfour_update(&md, (unsigned char *)s, len); -} - -void hash_start(void) -{ - mdfour_begin(&md); -} - -void hash_string(const char *s) -{ - hash_buffer(s, strlen(s)); -} - -void hash_int(int x) -{ - hash_buffer((char *)&x, sizeof(x)); -} - -/* add contents of a file to the hash */ -void hash_file(const char *fname) -{ - char buf[1024]; - int fd, n; - - fd = open(fname, O_RDONLY|O_BINARY); - if (fd == -1) { - cc_log("Failed to open %s\n", fname); - fatal("hash_file"); - } - - while ((n = read(fd, buf, sizeof(buf))) > 0) { - hash_buffer(buf, n); - } - close(fd); -} - -/* return the hash result as a static string */ -char *hash_result(void) -{ - unsigned char sum[16]; - static char ret[53]; - int i; - - hash_buffer(NULL, 0); - mdfour_result(&md, sum); - - for (i=0;i<16;i++) { - sprintf(&ret[i*2], "%02x", (unsigned)sum[i]); - } - sprintf(&ret[i*2], "-%u", (unsigned)md.totalN); - - return ret; -} diff --git a/CCache/install-sh b/CCache/install-sh deleted file mode 100755 index 58719246f..000000000 --- a/CCache/install-sh +++ /dev/null @@ -1,238 +0,0 @@ -#! /bin/sh -# -# install - install a program, script, or datafile -# This comes from X11R5. -# -# Calling this script install-sh is preferred over install.sh, to prevent -# `make' implicit rules from creating a file called install from it -# when there is no Makefile. -# -# This script is compatible with the BSD install script, but was written -# from scratch. -# - - -# set DOITPROG to echo to test this script - -# Don't use :- since 4.3BSD and earlier shells don't like it. -doit="${DOITPROG-}" - - -# put in absolute paths if you don't have them in your path; or use env. vars. - -mvprog="${MVPROG-mv}" -cpprog="${CPPROG-cp}" -chmodprog="${CHMODPROG-chmod}" -chownprog="${CHOWNPROG-chown}" -chgrpprog="${CHGRPPROG-chgrp}" -stripprog="${STRIPPROG-strip}" -rmprog="${RMPROG-rm}" -mkdirprog="${MKDIRPROG-mkdir}" - -transformbasename="" -transform_arg="" -instcmd="$mvprog" -chmodcmd="$chmodprog 0755" -chowncmd="" -chgrpcmd="" -stripcmd="" -rmcmd="$rmprog -f" -mvcmd="$mvprog" -src="" -dst="" -dir_arg="" - -while [ x"$1" != x ]; do - case $1 in - -c) instcmd="$cpprog" - shift - continue;; - - -d) dir_arg=true - shift - continue;; - - -m) chmodcmd="$chmodprog $2" - shift - shift - continue;; - - -o) chowncmd="$chownprog $2" - shift - shift - continue;; - - -g) chgrpcmd="$chgrpprog $2" - shift - shift - continue;; - - -s) stripcmd="$stripprog" - shift - continue;; - - -t=*) transformarg=`echo $1 | sed 's/-t=//'` - shift - continue;; - - -b=*) transformbasename=`echo $1 | sed 's/-b=//'` - shift - continue;; - - *) if [ x"$src" = x ] - then - src=$1 - else - # this colon is to work around a 386BSD /bin/sh bug - : - dst=$1 - fi - shift - continue;; - esac -done - -if [ x"$src" = x ] -then - echo "install: no input file specified" - exit 1 -else - true -fi - -if [ x"$dir_arg" != x ]; then - dst=$src - src="" - - if [ -d $dst ]; then - instcmd=: - else - instcmd=mkdir - fi -else - -# Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad -# if $src (and thus $dsttmp) contains '*'. - - if [ -f $src -o -d $src ] - then - true - else - echo "install: $src does not exist" - exit 1 - fi - - if [ x"$dst" = x ] - then - echo "install: no destination specified" - exit 1 - else - true - fi - -# If destination is a directory, append the input filename; if your system -# does not like double slashes in filenames, you may need to add some logic - - if [ -d $dst ] - then - dst="$dst"/`basename $src` - else - true - fi -fi - -## this sed command emulates the dirname command -dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` - -# Make sure that the destination directory exists. -# this part is taken from Noah Friedman's mkinstalldirs script - -# Skip lots of stat calls in the usual case. -if [ ! -d "$dstdir" ]; then -defaultIFS=' -' -IFS="${IFS-${defaultIFS}}" - -oIFS="${IFS}" -# Some sh's can't handle IFS=/ for some reason. -IFS='%' -set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` -IFS="${oIFS}" - -pathcomp='' - -while [ $# -ne 0 ] ; do - pathcomp="${pathcomp}${1}" - shift - - if [ ! -d "${pathcomp}" ] ; - then - $mkdirprog "${pathcomp}" - else - true - fi - - pathcomp="${pathcomp}/" -done -fi - -if [ x"$dir_arg" != x ] -then - $doit $instcmd $dst && - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi -else - -# If we're going to rename the final executable, determine the name now. - - if [ x"$transformarg" = x ] - then - dstfile=`basename $dst` - else - dstfile=`basename $dst $transformbasename | - sed $transformarg`$transformbasename - fi - -# don't allow the sed command to completely eliminate the filename - - if [ x"$dstfile" = x ] - then - dstfile=`basename $dst` - else - true - fi - -# Make a temp file name in the proper directory. - - dsttmp=$dstdir/#inst.$$# - -# Move or copy the file name to the temp name - - $doit $instcmd $src $dsttmp && - - trap "rm -f ${dsttmp}" 0 && - -# and set any options; do chmod last to preserve setuid bits - -# If any of these fail, we abort the whole thing. If we want to -# ignore errors from any of these, just make sure not to ignore -# errors from the above "$doit $instcmd $src $dsttmp" command. - - if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && - if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && - if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && - if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && - -# Now rename the file to the real destination. - - $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile - -fi && - - -exit 0 diff --git a/CCache/mdfour.c b/CCache/mdfour.c deleted file mode 100644 index b098e0215..000000000 --- a/CCache/mdfour.c +++ /dev/null @@ -1,284 +0,0 @@ -/* - a implementation of MD4 designed for use in the SMB authentication protocol - Copyright (C) Andrew Tridgell 1997-1998. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "ccache.h" - -/* NOTE: This code makes no attempt to be fast! - - It assumes that a int is at least 32 bits long -*/ - -static struct mdfour *m; - -#define MASK32 (0xffffffff) - -#define F(X,Y,Z) ((((X)&(Y)) | ((~(X))&(Z)))) -#define G(X,Y,Z) ((((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z)))) -#define H(X,Y,Z) (((X)^(Y)^(Z))) -#define lshift(x,s) (((((x)<<(s))&MASK32) | (((x)>>(32-(s)))&MASK32))) - -#define ROUND1(a,b,c,d,k,s) a = lshift((a + F(b,c,d) + M[k])&MASK32, s) -#define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c,d) + M[k] + 0x5A827999)&MASK32,s) -#define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s) - -/* this applies md4 to 64 byte chunks */ -static void mdfour64(uint32 *M) -{ - uint32 AA, BB, CC, DD; - uint32 A,B,C,D; - - A = m->A; B = m->B; C = m->C; D = m->D; - AA = A; BB = B; CC = C; DD = D; - - ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7); - ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19); - ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7); - ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19); - ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7); - ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19); - ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7); - ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19); - - - ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5); - ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13); - ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5); - ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13); - ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5); - ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13); - ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5); - ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13); - - ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9); - ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15); - ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9); - ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15); - ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9); - ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15); - ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9); - ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15); - - A += AA; B += BB; - C += CC; D += DD; - - A &= MASK32; B &= MASK32; - C &= MASK32; D &= MASK32; - - m->A = A; m->B = B; m->C = C; m->D = D; -} - -static void copy64(uint32 *M, const unsigned char *in) -{ - int i; - - for (i=0;i<16;i++) - M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) | - (in[i*4+1]<<8) | (in[i*4+0]<<0); -} - -static void copy4(unsigned char *out,uint32 x) -{ - out[0] = x&0xFF; - out[1] = (x>>8)&0xFF; - out[2] = (x>>16)&0xFF; - out[3] = (x>>24)&0xFF; -} - -void mdfour_begin(struct mdfour *md) -{ - md->A = 0x67452301; - md->B = 0xefcdab89; - md->C = 0x98badcfe; - md->D = 0x10325476; - md->totalN = 0; - md->tail_len = 0; -} - - -static void mdfour_tail(const unsigned char *in, int n) -{ - unsigned char buf[128]; - uint32 M[16]; - uint32 b; - - m->totalN += n; - - b = m->totalN * 8; - - memset(buf, 0, 128); - if (n) memcpy(buf, in, n); - buf[n] = 0x80; - - if (n <= 55) { - copy4(buf+56, b); - copy64(M, buf); - mdfour64(M); - } else { - copy4(buf+120, b); - copy64(M, buf); - mdfour64(M); - copy64(M, buf+64); - mdfour64(M); - } -} - -void mdfour_update(struct mdfour *md, const unsigned char *in, int n) -{ - uint32 M[16]; - - m = md; - - if (in == NULL) { - mdfour_tail(md->tail, md->tail_len); - return; - } - - if (md->tail_len) { - int len = 64 - md->tail_len; - if (len > n) len = n; - memcpy(md->tail+md->tail_len, in, len); - md->tail_len += len; - n -= len; - in += len; - if (md->tail_len == 64) { - copy64(M, md->tail); - mdfour64(M); - m->totalN += 64; - md->tail_len = 0; - } - } - - while (n >= 64) { - copy64(M, in); - mdfour64(M); - in += 64; - n -= 64; - m->totalN += 64; - } - - if (n) { - memcpy(md->tail, in, n); - md->tail_len = n; - } -} - - -void mdfour_result(struct mdfour *md, unsigned char *out) -{ - m = md; - - copy4(out, m->A); - copy4(out+4, m->B); - copy4(out+8, m->C); - copy4(out+12, m->D); -} - - -void mdfour(unsigned char *out, const unsigned char *in, int n) -{ - struct mdfour md; - mdfour_begin(&md); - mdfour_update(&md, in, n); - mdfour_update(&md, NULL, 0); - mdfour_result(&md, out); -} - -#ifdef TEST_MDFOUR -static void file_checksum1(char *fname) -{ - int fd, i; - struct mdfour md; - unsigned char buf[1024], sum[16]; - unsigned chunk; - - fd = open(fname,O_RDONLY|O_BINARY); - if (fd == -1) { - perror("fname"); - exit(1); - } - - chunk = 1 + random() % (sizeof(buf) - 1); - - mdfour_begin(&md); - - while (1) { - int n = read(fd, buf, chunk); - if (n >= 0) { - mdfour_update(&md, buf, n); - } - if (n < chunk) break; - } - - close(fd); - - mdfour_update(&md, NULL, 0); - - mdfour_result(&md, sum); - - for (i=0;i<16;i++) - printf("%02x", sum[i]); - printf("\n"); -} - -#if 0 -#include "../md4.h" - -static void file_checksum2(char *fname) -{ - int fd, i; - MDstruct md; - unsigned char buf[64], sum[16]; - - fd = open(fname,O_RDONLY|O_BINARY); - if (fd == -1) { - perror("fname"); - exit(1); - } - - MDbegin(&md); - - while (1) { - int n = read(fd, buf, sizeof(buf)); - if (n <= 0) break; - MDupdate(&md, buf, n*8); - } - - if (!md.done) { - MDupdate(&md, buf, 0); - } - - close(fd); - - memcpy(sum, md.buffer, 16); - - for (i=0;i<16;i++) - printf("%02x", sum[i]); - printf("\n"); -} -#endif - - int main(int argc, char *argv[]) -{ - file_checksum1(argv[1]); -#if 0 - file_checksum2(argv[1]); -#endif - return 0; -} -#endif diff --git a/CCache/mdfour.h b/CCache/mdfour.h deleted file mode 100644 index 92ef2f831..000000000 --- a/CCache/mdfour.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Unix SMB/Netbios implementation. - Version 1.9. - a implementation of MD4 designed for use in the SMB authentication protocol - Copyright (C) Andrew Tridgell 1997-1998. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -struct mdfour { - uint32 A, B, C, D; - uint32 totalN; - unsigned char tail[64]; - unsigned tail_len; -}; - -void mdfour_begin(struct mdfour *md); -void mdfour_update(struct mdfour *md, const unsigned char *in, int n); -void mdfour_result(struct mdfour *md, unsigned char *out); -void mdfour(unsigned char *out, const unsigned char *in, int n); - - - - diff --git a/CCache/packaging/README b/CCache/packaging/README deleted file mode 100644 index fadc342c4..000000000 --- a/CCache/packaging/README +++ /dev/null @@ -1,5 +0,0 @@ -These packaging files are contributd by users of ccache. I do not -maintain them, and they may well need updating before you use them. - -I don't distribute binary packages of ccache myself, but if you wish -to add ccache to a distribution then that's OK diff --git a/CCache/packaging/ccache.spec b/CCache/packaging/ccache.spec deleted file mode 100644 index 0972121d7..000000000 --- a/CCache/packaging/ccache.spec +++ /dev/null @@ -1,37 +0,0 @@ -Summary: Compiler Cache -Name: ccache -Version: 2.3 -Release: 1 -Group: Development/Languages -License: GPL -URL: http://ccache.samba.org/ -Source: ccache-%{version}.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-root - -%description -ccache caches gcc output files - -%prep -%setup -q - -%build -%configure -make - -install -d -m 0755 $RPM_BUILD_ROOT%{_bindir} -install -m 0755 ccache $RPM_BUILD_ROOT%{_bindir} -install -d -m 0755 $RPM_BUILD_ROOT%{_mandir}/man1 -install -m 0644 ccache.1 $RPM_BUILD_ROOT%{_mandir}/man1 - -%files -%defattr(-,root,root) -%doc README -%{_mandir}/man1/ccache.1* -%{_bindir}/ccache - -%clean -[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT - -%changelog -* Mon Apr 01 2002 Peter Jones -- Created the package diff --git a/CCache/snprintf.c b/CCache/snprintf.c deleted file mode 100644 index 32187c1a5..000000000 --- a/CCache/snprintf.c +++ /dev/null @@ -1,962 +0,0 @@ -/* - * Copyright Patrick Powell 1995 - * This code is based on code written by Patrick Powell (papowell@astart.com) - * It may be used for any purpose as long as this notice remains intact - * on all source code distributions - */ - -/************************************************************** - * Original: - * Patrick Powell Tue Apr 11 09:48:21 PDT 1995 - * A bombproof version of doprnt (dopr) included. - * Sigh. This sort of thing is always nasty do deal with. Note that - * the version here does not include floating point... - * - * snprintf() is used instead of sprintf() as it does limit checks - * for string length. This covers a nasty loophole. - * - * The other functions are there to prevent NULL pointers from - * causing nast effects. - * - * More Recently: - * Brandon Long 9/15/96 for mutt 0.43 - * This was ugly. It is still ugly. I opted out of floating point - * numbers, but the formatter understands just about everything - * from the normal C string format, at least as far as I can tell from - * the Solaris 2.5 printf(3S) man page. - * - * Brandon Long 10/22/97 for mutt 0.87.1 - * Ok, added some minimal floating point support, which means this - * probably requires libm on most operating systems. Don't yet - * support the exponent (e,E) and sigfig (g,G). Also, fmtint() - * was pretty badly broken, it just wasn't being exercised in ways - * which showed it, so that's been fixed. Also, formated the code - * to mutt conventions, and removed dead code left over from the - * original. Also, there is now a builtin-test, just compile with: - * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm - * and run snprintf for results. - * - * Thomas Roessler 01/27/98 for mutt 0.89i - * The PGP code was using unsigned hexadecimal formats. - * Unfortunately, unsigned formats simply didn't work. - * - * Michael Elkins 03/05/98 for mutt 0.90.8 - * The original code assumed that both snprintf() and vsnprintf() were - * missing. Some systems only have snprintf() but not vsnprintf(), so - * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF. - * - * Andrew Tridgell (tridge@samba.org) Oct 1998 - * fixed handling of %.0f - * added test for HAVE_LONG_DOUBLE - * - * tridge@samba.org, idra@samba.org, April 2001 - * got rid of fcvt code (twas buggy and made testing harder) - * added C99 semantics - * - **************************************************************/ - -#ifndef NO_CONFIG_H /* for some tests */ -#include "config.h" -#endif - -#ifdef HAVE_STRING_H -#include -#endif - -#ifdef HAVE_STRINGS_H -#include -#endif -#ifdef HAVE_CTYPE_H -#include -#endif -#include -#include -#ifdef HAVE_STDLIB_H -#include -#endif - -#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF) -/* only include stdio.h if we are not re-defining snprintf or vsnprintf */ -#include - /* make the compiler happy with an empty file */ - void dummy_snprintf(void) {} -#else - -#ifdef HAVE_LONG_DOUBLE -#define LDOUBLE long double -#else -#define LDOUBLE double -#endif - -#ifdef HAVE_LONG_LONG -#define LLONG long long -#else -#define LLONG long -#endif - -static size_t dopr(char *buffer, size_t maxlen, const char *format, - va_list args); -static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, - char *value, int flags, int min, int max); -static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags); -static void fmtfp(char *buffer, size_t *currlen, size_t maxlen, - LDOUBLE fvalue, int min, int max, int flags); -static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c); - -/* - * dopr(): poor man's version of doprintf - */ - -/* format read states */ -#define DP_S_DEFAULT 0 -#define DP_S_FLAGS 1 -#define DP_S_MIN 2 -#define DP_S_DOT 3 -#define DP_S_MAX 4 -#define DP_S_MOD 5 -#define DP_S_CONV 6 -#define DP_S_DONE 7 - -/* format flags - Bits */ -#define DP_F_MINUS (1 << 0) -#define DP_F_PLUS (1 << 1) -#define DP_F_SPACE (1 << 2) -#define DP_F_NUM (1 << 3) -#define DP_F_ZERO (1 << 4) -#define DP_F_UP (1 << 5) -#define DP_F_UNSIGNED (1 << 6) - -/* Conversion Flags */ -#define DP_C_SHORT 1 -#define DP_C_LONG 2 -#define DP_C_LDOUBLE 3 -#define DP_C_LLONG 4 - -#define char_to_int(p) ((p)- '0') -#ifndef MAX -#define MAX(p,q) (((p) >= (q)) ? (p) : (q)) -#endif - -static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args) -{ - char ch; - LLONG value; - LDOUBLE fvalue; - char *strvalue; - int min; - int max; - int state; - int flags; - int cflags; - size_t currlen; - - state = DP_S_DEFAULT; - currlen = flags = cflags = min = 0; - max = -1; - ch = *format++; - - while (state != DP_S_DONE) { - if (ch == '\0') - state = DP_S_DONE; - - switch(state) { - case DP_S_DEFAULT: - if (ch == '%') - state = DP_S_FLAGS; - else - dopr_outch (buffer, &currlen, maxlen, ch); - ch = *format++; - break; - case DP_S_FLAGS: - switch (ch) { - case '-': - flags |= DP_F_MINUS; - ch = *format++; - break; - case '+': - flags |= DP_F_PLUS; - ch = *format++; - break; - case ' ': - flags |= DP_F_SPACE; - ch = *format++; - break; - case '#': - flags |= DP_F_NUM; - ch = *format++; - break; - case '0': - flags |= DP_F_ZERO; - ch = *format++; - break; - default: - state = DP_S_MIN; - break; - } - break; - case DP_S_MIN: - if (isdigit((unsigned char)ch)) { - min = 10*min + char_to_int (ch); - ch = *format++; - } else if (ch == '*') { - min = va_arg (args, int); - ch = *format++; - state = DP_S_DOT; - } else { - state = DP_S_DOT; - } - break; - case DP_S_DOT: - if (ch == '.') { - state = DP_S_MAX; - ch = *format++; - } else { - state = DP_S_MOD; - } - break; - case DP_S_MAX: - if (isdigit((unsigned char)ch)) { - if (max < 0) - max = 0; - max = 10*max + char_to_int (ch); - ch = *format++; - } else if (ch == '*') { - max = va_arg (args, int); - ch = *format++; - state = DP_S_MOD; - } else { - state = DP_S_MOD; - } - break; - case DP_S_MOD: - switch (ch) { - case 'h': - cflags = DP_C_SHORT; - ch = *format++; - break; - case 'l': - cflags = DP_C_LONG; - ch = *format++; - if (ch == 'l') { /* It's a long long */ - cflags = DP_C_LLONG; - ch = *format++; - } - break; - case 'L': - cflags = DP_C_LDOUBLE; - ch = *format++; - break; - default: - break; - } - state = DP_S_CONV; - break; - case DP_S_CONV: - switch (ch) { - case 'd': - case 'i': - if (cflags == DP_C_SHORT) - value = va_arg (args, int); - else if (cflags == DP_C_LONG) - value = va_arg (args, long int); - else if (cflags == DP_C_LLONG) - value = va_arg (args, LLONG); - else - value = va_arg (args, int); - fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); - break; - case 'o': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg (args, unsigned int); - else if (cflags == DP_C_LONG) - value = (long)va_arg (args, unsigned long int); - else if (cflags == DP_C_LLONG) - value = (long)va_arg (args, unsigned LLONG); - else - value = (long)va_arg (args, unsigned int); - fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags); - break; - case 'u': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg (args, unsigned int); - else if (cflags == DP_C_LONG) - value = (long)va_arg (args, unsigned long int); - else if (cflags == DP_C_LLONG) - value = (LLONG)va_arg (args, unsigned LLONG); - else - value = (long)va_arg (args, unsigned int); - fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags); - break; - case 'X': - flags |= DP_F_UP; - case 'x': - flags |= DP_F_UNSIGNED; - if (cflags == DP_C_SHORT) - value = va_arg (args, unsigned int); - else if (cflags == DP_C_LONG) - value = (long)va_arg (args, unsigned long int); - else if (cflags == DP_C_LLONG) - value = (LLONG)va_arg (args, unsigned LLONG); - else - value = (long)va_arg (args, unsigned int); - fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags); - break; - case 'f': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg (args, LDOUBLE); - else - fvalue = va_arg (args, double); - /* um, floating point? */ - fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags); - break; - case 'E': - flags |= DP_F_UP; - case 'e': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg (args, LDOUBLE); - else - fvalue = va_arg (args, double); - break; - case 'G': - flags |= DP_F_UP; - case 'g': - if (cflags == DP_C_LDOUBLE) - fvalue = va_arg (args, LDOUBLE); - else - fvalue = va_arg (args, double); - break; - case 'c': - dopr_outch (buffer, &currlen, maxlen, va_arg (args, int)); - break; - case 's': - strvalue = va_arg (args, char *); - if (!strvalue) strvalue = "(NULL)"; - if (max == -1) { - max = strlen(strvalue); - } - if (min > 0 && max >= 0 && min > max) max = min; - fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max); - break; - case 'p': - strvalue = (char *)va_arg(args, void *); - fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags); - break; - case 'n': - if (cflags == DP_C_SHORT) { - short int *num; - num = va_arg (args, short int *); - *num = currlen; - } else if (cflags == DP_C_LONG) { - long int *num; - num = va_arg (args, long int *); - *num = (long int)currlen; - } else if (cflags == DP_C_LLONG) { - LLONG *num; - num = va_arg (args, LLONG *); - *num = (LLONG)currlen; - } else { - int *num; - num = va_arg (args, int *); - *num = currlen; - } - break; - case '%': - dopr_outch (buffer, &currlen, maxlen, ch); - break; - case 'w': - /* not supported yet, treat as next char */ - ch = *format++; - break; - default: - /* Unknown, skip */ - break; - } - ch = *format++; - state = DP_S_DEFAULT; - flags = cflags = min = 0; - max = -1; - break; - case DP_S_DONE: - break; - default: - /* hmm? */ - break; /* some picky compilers need this */ - } - } - if (maxlen != 0) { - if (currlen < maxlen - 1) - buffer[currlen] = '\0'; - else if (maxlen > 0) - buffer[maxlen - 1] = '\0'; - } - - return currlen; -} - -static void fmtstr(char *buffer, size_t *currlen, size_t maxlen, - char *value, int flags, int min, int max) -{ - int padlen, strln; /* amount to pad */ - int cnt = 0; - -#ifdef DEBUG_SNPRINTF - printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value); -#endif - if (value == 0) { - value = ""; - } - - for (strln = 0; value[strln]; ++strln); /* strlen */ - padlen = min - strln; - if (padlen < 0) - padlen = 0; - if (flags & DP_F_MINUS) - padlen = -padlen; /* Left Justify */ - - while ((padlen > 0) && (cnt < max)) { - dopr_outch (buffer, currlen, maxlen, ' '); - --padlen; - ++cnt; - } - while (*value && (cnt < max)) { - dopr_outch (buffer, currlen, maxlen, *value++); - ++cnt; - } - while ((padlen < 0) && (cnt < max)) { - dopr_outch (buffer, currlen, maxlen, ' '); - ++padlen; - ++cnt; - } -} - -/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */ - -static void fmtint(char *buffer, size_t *currlen, size_t maxlen, - long value, int base, int min, int max, int flags) -{ - int signvalue = 0; - unsigned long uvalue; - char convert[20]; - int place = 0; - int spadlen = 0; /* amount to space pad */ - int zpadlen = 0; /* amount to zero pad */ - int caps = 0; - - if (max < 0) - max = 0; - - uvalue = value; - - if(!(flags & DP_F_UNSIGNED)) { - if( value < 0 ) { - signvalue = '-'; - uvalue = -value; - } else { - if (flags & DP_F_PLUS) /* Do a sign (+/i) */ - signvalue = '+'; - else if (flags & DP_F_SPACE) - signvalue = ' '; - } - } - - if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ - - do { - convert[place++] = - (caps? "0123456789ABCDEF":"0123456789abcdef") - [uvalue % (unsigned)base ]; - uvalue = (uvalue / (unsigned)base ); - } while(uvalue && (place < 20)); - if (place == 20) place--; - convert[place] = 0; - - zpadlen = max - place; - spadlen = min - MAX (max, place) - (signvalue ? 1 : 0); - if (zpadlen < 0) zpadlen = 0; - if (spadlen < 0) spadlen = 0; - if (flags & DP_F_ZERO) { - zpadlen = MAX(zpadlen, spadlen); - spadlen = 0; - } - if (flags & DP_F_MINUS) - spadlen = -spadlen; /* Left Justifty */ - -#ifdef DEBUG_SNPRINTF - printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n", - zpadlen, spadlen, min, max, place); -#endif - - /* Spaces */ - while (spadlen > 0) { - dopr_outch (buffer, currlen, maxlen, ' '); - --spadlen; - } - - /* Sign */ - if (signvalue) - dopr_outch (buffer, currlen, maxlen, signvalue); - - /* Zeros */ - if (zpadlen > 0) { - while (zpadlen > 0) { - dopr_outch (buffer, currlen, maxlen, '0'); - --zpadlen; - } - } - - /* Digits */ - while (place > 0) - dopr_outch (buffer, currlen, maxlen, convert[--place]); - - /* Left Justified spaces */ - while (spadlen < 0) { - dopr_outch (buffer, currlen, maxlen, ' '); - ++spadlen; - } -} - -static LDOUBLE abs_val(LDOUBLE value) -{ - LDOUBLE result = value; - - if (value < 0) - result = -value; - - return result; -} - -static LDOUBLE POW10(int exp) -{ - LDOUBLE result = 1; - - while (exp) { - result *= 10; - exp--; - } - - return result; -} - -static LLONG ROUND(LDOUBLE value) -{ - LLONG intpart; - - intpart = (LLONG)value; - value = value - intpart; - if (value >= 0.5) intpart++; - - return intpart; -} - -/* a replacement for modf that doesn't need the math library. Should - be portable, but slow */ -static double my_modf(double x0, double *iptr) -{ - int i; - long l; - double x = x0; - double f = 1.0; - - for (i=0;i<100;i++) { - l = (long)x; - if (l <= (x+1) && l >= (x-1)) break; - x *= 0.1; - f *= 10.0; - } - - if (i == 100) { - /* yikes! the number is beyond what we can handle. What do we do? */ - (*iptr) = 0; - return 0; - } - - if (i != 0) { - double i2; - double ret; - - ret = my_modf(x0-l*f, &i2); - (*iptr) = l*f + i2; - return ret; - } - - (*iptr) = l; - return x - (*iptr); -} - - -static void fmtfp (char *buffer, size_t *currlen, size_t maxlen, - LDOUBLE fvalue, int min, int max, int flags) -{ - int signvalue = 0; - double ufvalue; - char iconvert[311]; - char fconvert[311]; - int iplace = 0; - int fplace = 0; - int padlen = 0; /* amount to pad */ - int zpadlen = 0; - int caps = 0; - int index; - double intpart; - double fracpart; - double temp; - - /* - * AIX manpage says the default is 0, but Solaris says the default - * is 6, and sprintf on AIX defaults to 6 - */ - if (max < 0) - max = 6; - - ufvalue = abs_val (fvalue); - - if (fvalue < 0) { - signvalue = '-'; - } else { - if (flags & DP_F_PLUS) { /* Do a sign (+/i) */ - signvalue = '+'; - } else { - if (flags & DP_F_SPACE) - signvalue = ' '; - } - } - -#if 0 - if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */ -#endif - -#if 0 - if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */ -#endif - - /* - * Sorry, we only support 16 digits past the decimal because of our - * conversion method - */ - if (max > 16) - max = 16; - - /* We "cheat" by converting the fractional part to integer by - * multiplying by a factor of 10 - */ - - temp = ufvalue; - my_modf(temp, &intpart); - - fracpart = ROUND((POW10(max)) * (ufvalue - intpart)); - - if (fracpart >= POW10(max)) { - intpart++; - fracpart -= POW10(max); - } - - - /* Convert integer part */ - do { - temp = intpart; - my_modf(intpart*0.1, &intpart); - temp = temp*0.1; - index = (int) ((temp -intpart +0.05)* 10.0); - /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */ - /* printf ("%llf, %f, %x\n", temp, intpart, index); */ - iconvert[iplace++] = - (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; - } while (intpart && (iplace < 311)); - if (iplace == 311) iplace--; - iconvert[iplace] = 0; - - /* Convert fractional part */ - if (fracpart) - { - do { - temp = fracpart; - my_modf(fracpart*0.1, &fracpart); - temp = temp*0.1; - index = (int) ((temp -fracpart +0.05)* 10.0); - /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */ - /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */ - fconvert[fplace++] = - (caps? "0123456789ABCDEF":"0123456789abcdef")[index]; - } while(fracpart && (fplace < 311)); - if (fplace == 311) fplace--; - } - fconvert[fplace] = 0; - - /* -1 for decimal point, another -1 if we are printing a sign */ - padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); - zpadlen = max - fplace; - if (zpadlen < 0) zpadlen = 0; - if (padlen < 0) - padlen = 0; - if (flags & DP_F_MINUS) - padlen = -padlen; /* Left Justifty */ - - if ((flags & DP_F_ZERO) && (padlen > 0)) { - if (signvalue) { - dopr_outch (buffer, currlen, maxlen, signvalue); - --padlen; - signvalue = 0; - } - while (padlen > 0) { - dopr_outch (buffer, currlen, maxlen, '0'); - --padlen; - } - } - while (padlen > 0) { - dopr_outch (buffer, currlen, maxlen, ' '); - --padlen; - } - if (signvalue) - dopr_outch (buffer, currlen, maxlen, signvalue); - - while (iplace > 0) - dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]); - -#ifdef DEBUG_SNPRINTF - printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen); -#endif - - /* - * Decimal point. This should probably use locale to find the correct - * char to print out. - */ - if (max > 0) { - dopr_outch (buffer, currlen, maxlen, '.'); - - while (fplace > 0) - dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]); - } - - while (zpadlen > 0) { - dopr_outch (buffer, currlen, maxlen, '0'); - --zpadlen; - } - - while (padlen < 0) { - dopr_outch (buffer, currlen, maxlen, ' '); - ++padlen; - } -} - -static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c) -{ - if (*currlen < maxlen) { - buffer[(*currlen)] = c; - } - (*currlen)++; -} - -/* yes this really must be a ||. Don't muck with this (tridge) */ -#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF) - int vsnprintf (char *str, size_t count, const char *fmt, va_list args) -{ - return dopr(str, count, fmt, args); -} -#endif - -/* yes this really must be a ||. Don't muck wiith this (tridge) - * - * The logic for these two is that we need our own definition if the - * OS *either* has no definition of *sprintf, or if it does have one - * that doesn't work properly according to the autoconf test. Perhaps - * these should really be smb_snprintf to avoid conflicts with buggy - * linkers? -- mbp - */ -#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_SNPRINTF) - int snprintf(char *str,size_t count,const char *fmt,...) -{ - size_t ret; - va_list ap; - - va_start(ap, fmt); - ret = vsnprintf(str, count, fmt, ap); - va_end(ap); - return ret; -} -#endif - -#endif - -#ifndef HAVE_VASPRINTF - int vasprintf(char **ptr, const char *format, va_list ap) -{ - int ret; - - ret = vsnprintf(0, 0, format, ap); - if (ret <= 0) return ret; - - (*ptr) = (char *)malloc(ret+1); - if (!*ptr) return -1; - ret = vsnprintf(*ptr, ret+1, format, ap); - - return ret; -} -#endif - - -#ifndef HAVE_ASPRINTF - int asprintf(char **ptr, const char *format, ...) -{ - va_list ap; - int ret; - - *ptr = 0; - va_start(ap, format); - ret = vasprintf(ptr, format, ap); - va_end(ap); - - return ret; -} -#endif - -#ifndef HAVE_VSYSLOG -#ifdef HAVE_SYSLOG - void vsyslog (int facility_priority, char *format, va_list arglist) -{ - char *msg = 0; - vasprintf(&msg, format, arglist); - if (!msg) - return; - syslog(facility_priority, "%s", msg); - free(msg); -} -#endif /* HAVE_SYSLOG */ -#endif /* HAVE_VSYSLOG */ - -#ifdef TEST_SNPRINTF - - int sprintf(char *str,const char *fmt,...); - - int main (void) -{ - char buf1[1024]; - char buf2[1024]; - char *fp_fmt[] = { - "%1.1f", - "%-1.5f", - "%1.5f", - "%123.9f", - "%10.5f", - "% 10.5f", - "%+22.9f", - "%+4.9f", - "%01.3f", - "%4f", - "%3.1f", - "%3.2f", - "%.0f", - "%f", - "-16.16f", - 0 - }; - double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996, - 0.9996, 1.996, 4.136, 0}; - char *int_fmt[] = { - "%-1.5d", - "%1.5d", - "%123.9d", - "%5.5d", - "%10.5d", - "% 10.5d", - "%+22.33d", - "%01.3d", - "%4d", - "%d", - 0 - }; - long int_nums[] = { -1, 134, 91340, 341, 0203, 0}; - char *str_fmt[] = { - "10.5s", - "5.10s", - "10.1s", - "0.10s", - "10.0s", - "1.10s", - "%s", - "%.1s", - "%.10s", - "%10s", - 0 - }; - char *str_vals[] = {"hello", "a", "", "a longer string", 0}; - int x, y; - int fail = 0; - int num = 0; - - printf ("Testing snprintf format codes against system sprintf...\n"); - - for (x = 0; fp_fmt[x] ; x++) { - for (y = 0; fp_nums[y] != 0 ; y++) { - int l1 = snprintf(0, 0, fp_fmt[x], fp_nums[y]); - int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]); - sprintf (buf2, fp_fmt[x], fp_nums[y]); - if (strcmp (buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", - fp_fmt[x], buf1, buf2); - fail++; - } - if (l1 != l2) { - printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]); - fail++; - } - num++; - } - } - - for (x = 0; int_fmt[x] ; x++) { - for (y = 0; int_nums[y] != 0 ; y++) { - int l1 = snprintf(0, 0, int_fmt[x], int_nums[y]); - int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]); - sprintf (buf2, int_fmt[x], int_nums[y]); - if (strcmp (buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", - int_fmt[x], buf1, buf2); - fail++; - } - if (l1 != l2) { - printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]); - fail++; - } - num++; - } - } - - for (x = 0; str_fmt[x] ; x++) { - for (y = 0; str_vals[y] != 0 ; y++) { - int l1 = snprintf(0, 0, str_fmt[x], str_vals[y]); - int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]); - sprintf (buf2, str_fmt[x], str_vals[y]); - if (strcmp (buf1, buf2)) { - printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n", - str_fmt[x], buf1, buf2); - fail++; - } - if (l1 != l2) { - printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]); - fail++; - } - num++; - } - } - - printf ("%d tests failed out of %d.\n", fail, num); - - printf("seeing how many digits we support\n"); - { - double v0 = 0.12345678901234567890123456789012345678901; - for (x=0; x<100; x++) { - snprintf(buf1, sizeof(buf1), "%1.1f", v0*pow(10, x)); - sprintf(buf2, "%1.1f", v0*pow(10, x)); - if (strcmp(buf1, buf2)) { - printf("we seem to support %d digits\n", x-1); - break; - } - } - } - - return 0; -} -#endif /* SNPRINTF_TEST */ diff --git a/CCache/stats.c b/CCache/stats.c deleted file mode 100644 index 92bc4a835..000000000 --- a/CCache/stats.c +++ /dev/null @@ -1,361 +0,0 @@ -/* - Copyright (C) Andrew Tridgell 2002 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -/* - routines to handle the stats files - - the stats file is stored one per cache subdirectory to make this more - scalable - */ - -#include "ccache.h" - -extern char *stats_file; -extern char *cache_dir; - -#define STATS_VERSION 1 - -#define FLAG_NOZERO 1 /* don't zero with the -z option */ -#define FLAG_ALWAYS 2 /* always show, even if zero */ - -static struct { - enum stats stat; - char *message; - void (*fn)(unsigned ); - unsigned flags; -} stats_info[] = { - { STATS_CACHED, "cache hit ", NULL, FLAG_ALWAYS }, - { STATS_TOCACHE, "cache miss ", NULL, FLAG_ALWAYS }, - { STATS_LINK, "called for link ", NULL, 0 }, - { STATS_MULTIPLE, "multiple source files ", NULL, 0 }, - { STATS_STDOUT, "compiler produced stdout ", NULL, 0 }, - { STATS_STATUS, "compile failed ", NULL, 0 }, - { STATS_ERROR, "ccache internal error ", NULL, 0 }, - { STATS_PREPROCESSOR, "preprocessor error ", NULL, 0 }, - { STATS_COMPILER, "couldn't find the compiler ", NULL, 0 }, - { STATS_MISSING, "cache file missing ", NULL, 0 }, - { STATS_ARGS, "bad compiler arguments ", NULL, 0 }, - { STATS_NOTC, "not a C/C++ file ", NULL, 0 }, - { STATS_CONFTEST, "autoconf compile/link ", NULL, 0 }, - { STATS_UNSUPPORTED, "unsupported compiler option ", NULL, 0 }, - { STATS_OUTSTDOUT, "output to stdout ", NULL, 0 }, - { STATS_DEVICE, "output to a non-regular file ", NULL, 0 }, - { STATS_NOINPUT, "no input file ", NULL, 0 }, - { STATS_ENVIRONMMENT, "error due to bad env variable ", NULL, 0 }, - { STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS }, - { STATS_TOTALSIZE, "cache size ", display_size , FLAG_NOZERO|FLAG_ALWAYS }, - { STATS_MAXFILES, "max files ", NULL, FLAG_NOZERO }, - { STATS_MAXSIZE, "max cache size ", display_size, FLAG_NOZERO }, - { STATS_NONE, NULL, NULL, 0 } -}; - -/* parse a stats file from a buffer - adding to the counters */ -static void parse_stats(unsigned counters[STATS_END], char *buf) -{ - int i; - char *p, *p2; - - p = buf; - for (i=0;i= (int)sizeof(buf)-1) fatal("stats too long?!"); - } - len += snprintf(buf+len, sizeof(buf)-(len+1), "\n"); - if (len >= (int)sizeof(buf)-1) fatal("stats too long?!"); - - lseek(fd, 0, SEEK_SET); - if (write(fd, buf, len) == -1) fatal("could not write stats"); -} - - -/* fill in some default stats values */ -static void stats_default(unsigned counters[STATS_END]) -{ - counters[STATS_MAXSIZE] += DEFAULT_MAXSIZE / 16; -} - -/* read in the stats from one dir and add to the counters */ -static void stats_read_fd(int fd, unsigned counters[STATS_END]) -{ - char buf[1024]; - int len; - len = read(fd, buf, sizeof(buf)-1); - if (len <= 0) { - stats_default(counters); - return; - } - buf[len] = 0; - parse_stats(counters, buf); -} - -/* update the stats counter for this compile */ -static void stats_update_size(enum stats stat, size_t size, size_t numfiles) -{ - int fd; - unsigned counters[STATS_END]; - int need_cleanup = 0; - - if (getenv("CCACHE_NOSTATS")) return; - - if (!stats_file) { - if (!cache_dir) return; - x_asprintf(&stats_file, "%s/stats", cache_dir); - } - - /* open safely to try to prevent symlink races */ - fd = safe_open(stats_file); - - /* still can't get it? don't bother ... */ - if (fd == -1) return; - - memset(counters, 0, sizeof(counters)); - - if (lock_fd(fd) != 0) return; - - /* read in the old stats */ - stats_read_fd(fd, counters); - - /* update them */ - counters[stat]++; - - /* on a cache miss we up the file count and size */ - if (stat == STATS_TOCACHE) { - counters[STATS_NUMFILES] += numfiles; - counters[STATS_TOTALSIZE] += size; - } - - /* and write them out */ - write_stats(fd, counters); - close(fd); - - /* we might need to cleanup if the cache has now got too big */ - if (counters[STATS_MAXFILES] != 0 && - counters[STATS_NUMFILES] > counters[STATS_MAXFILES]) { - need_cleanup = 1; - } - if (counters[STATS_MAXSIZE] != 0 && - counters[STATS_TOTALSIZE] > counters[STATS_MAXSIZE]) { - need_cleanup = 1; - } - - if (need_cleanup) { - char *p = dirname(stats_file); - cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE]); - free(p); - } -} - -/* record a cache miss */ -void stats_tocache(size_t size, size_t numfiles) -{ - /* convert size to kilobytes */ - size = size / 1024; - - stats_update_size(STATS_TOCACHE, size, numfiles); -} - -/* update a normal stat */ -void stats_update(enum stats stat) -{ - stats_update_size(stat, 0, 0); -} - -/* read in the stats from one dir and add to the counters */ -void stats_read(const char *stats_file, unsigned counters[STATS_END]) -{ - int fd; - - fd = open(stats_file, O_RDONLY|O_BINARY); - if (fd == -1) { - stats_default(counters); - return; - } - lock_fd(fd); - stats_read_fd(fd, counters); - close(fd); -} - -/* sum and display the total stats for all cache dirs */ -void stats_summary(void) -{ - int dir, i; - unsigned counters[STATS_END]; - - memset(counters, 0, sizeof(counters)); - - /* add up the stats in each directory */ - for (dir=-1;dir<=0xF;dir++) { - char *fname; - - if (dir == -1) { - x_asprintf(&fname, "%s/stats", cache_dir); - } else { - x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir); - } - - stats_read(fname, counters); - free(fname); - - /* oh what a nasty hack ... */ - if (dir == -1) { - counters[STATS_MAXSIZE] = 0; - } - - } - - printf("cache directory %s\n", cache_dir); - - /* and display them */ - for (i=0;stats_info[i].message;i++) { - enum stats stat = stats_info[i].stat; - - if (counters[stat] == 0 && - !(stats_info[i].flags & FLAG_ALWAYS)) { - continue; - } - - printf("%s ", stats_info[i].message); - if (stats_info[i].fn) { - stats_info[i].fn(counters[stat]); - printf("\n"); - } else { - printf("%8u\n", counters[stat]); - } - } -} - -/* zero all the stats structures */ -void stats_zero(void) -{ - int dir, fd; - unsigned i; - char *fname; - unsigned counters[STATS_END]; - - x_asprintf(&fname, "%s/stats", cache_dir); - unlink(fname); - free(fname); - - for (dir=0;dir<=0xF;dir++) { - x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir); - fd = safe_open(fname); - if (fd == -1) { - free(fname); - continue; - } - memset(counters, 0, sizeof(counters)); - lock_fd(fd); - stats_read_fd(fd, counters); - for (i=0;stats_info[i].message;i++) { - if (!(stats_info[i].flags & FLAG_NOZERO)) { - counters[stats_info[i].stat] = 0; - } - } - write_stats(fd, counters); - close(fd); - free(fname); - } -} - - -/* set the per directory limits */ -int stats_set_limits(long maxfiles, long maxsize) -{ - int dir; - unsigned counters[STATS_END]; - - if (maxfiles != -1) { - maxfiles /= 16; - } - if (maxsize != -1) { - maxsize /= 16; - } - - if (create_dir(cache_dir) != 0) { - return 1; - } - - /* set the limits in each directory */ - for (dir=0;dir<=0xF;dir++) { - char *fname, *cdir; - int fd; - - x_asprintf(&cdir, "%s/%1x", cache_dir, dir); - if (create_dir(cdir) != 0) { - return 1; - } - x_asprintf(&fname, "%s/stats", cdir); - free(cdir); - - memset(counters, 0, sizeof(counters)); - fd = safe_open(fname); - if (fd != -1) { - lock_fd(fd); - stats_read_fd(fd, counters); - if (maxfiles != -1) { - counters[STATS_MAXFILES] = maxfiles; - } - if (maxsize != -1) { - counters[STATS_MAXSIZE] = maxsize; - } - write_stats(fd, counters); - close(fd); - } - free(fname); - } - - return 0; -} - -/* set the per directory sizes */ -void stats_set_sizes(const char *dir, size_t num_files, size_t total_size) -{ - int fd; - unsigned counters[STATS_END]; - char *stats_file; - - create_dir(dir); - x_asprintf(&stats_file, "%s/stats", dir); - - memset(counters, 0, sizeof(counters)); - - fd = safe_open(stats_file); - if (fd != -1) { - lock_fd(fd); - stats_read_fd(fd, counters); - counters[STATS_NUMFILES] = num_files; - counters[STATS_TOTALSIZE] = total_size; - write_stats(fd, counters); - close(fd); - } - - free(stats_file); -} diff --git a/CCache/test.sh b/CCache/test.sh deleted file mode 100755 index 9581c85e3..000000000 --- a/CCache/test.sh +++ /dev/null @@ -1,452 +0,0 @@ -#!/bin/sh - -# a simple test suite for ccache -# tridge@samba.org - -if test -n "$CC"; then - COMPILER="$CC" -else - COMPILER=cc -fi - -if test -n "$SWIG"; then - SWIG="$SWIG" -else - SWIG=swig -fi - -CCACHE=../ccache-swig -TESTDIR=test.$$ - -test_failed() { - reason="$1" - echo $1 - $CCACHE -s - cd .. - rm -rf $TESTDIR - echo TEST FAILED - exit 1 -} - -randcode() { - outfile="$1" - nlines=$2 - i=0; - ( - while [ $i -lt $nlines ]; do - echo "int foo$nlines$i(int x) { return x; }" - i=`expr $i + 1` - done - ) >> "$outfile" -} - -genswigcode() { - outfile="$1" - nlines=$2 - i=0; - ( - echo "%module swigtest$2;" - while [ $i -lt $nlines ]; do - echo "int foo$nlines$i(int x);" - echo "struct Bar$nlines$i { int y; };" - i=`expr $i + 1` - done - ) >> "$outfile" -} - - -getstat() { - stat="$1" - value=`$CCACHE -s | grep "$stat" | cut -c34-40` - echo $value -} - -checkstat() { - stat="$1" - expected_value="$2" - value=`getstat "$stat"` -# echo "exp: $expected_value got: $value $testname" - if [ "$expected_value" != "$value" ]; then - test_failed "SUITE: $testsuite TEST: $testname - Expected $stat to be $expected_value got $value" - fi -} - - -basetests() { - echo "starting testsuite $testsuite" - rm -rf "$CCACHE_DIR" - checkstat 'cache hit' 0 - checkstat 'cache miss' 0 - - j=1 - rm -f *.c - while [ $j -lt 32 ]; do - randcode test$j.c $j - j=`expr $j + 1` - done - - testname="BASIC" - $CCACHE_COMPILE -c test1.c - checkstat 'cache hit' 0 - checkstat 'cache miss' 1 - - testname="BASIC2" - $CCACHE_COMPILE -c test1.c - checkstat 'cache hit' 1 - checkstat 'cache miss' 1 - - testname="debug" - $CCACHE_COMPILE -c test1.c -g - checkstat 'cache hit' 1 - checkstat 'cache miss' 2 - - testname="debug2" - $CCACHE_COMPILE -c test1.c -g - checkstat 'cache hit' 2 - checkstat 'cache miss' 2 - - testname="output" - $CCACHE_COMPILE -c test1.c -o foo.o - checkstat 'cache hit' 3 - checkstat 'cache miss' 2 - - testname="link" - $CCACHE_COMPILE test1.c -o test 2> /dev/null - checkstat 'called for link' 1 - - testname="multiple" - $CCACHE_COMPILE -c test1.c test2.c - checkstat 'multiple source files' 1 - - testname="find" - $CCACHE blahblah -c test1.c 2> /dev/null - checkstat "couldn't find the compiler" 1 - - testname="bad" - $CCACHE_COMPILE -c test1.c -I 2> /dev/null - checkstat 'bad compiler arguments' 1 - - testname="c/c++" - ln -f test1.c test1.ccc - $CCACHE_COMPILE -c test1.ccc 2> /dev/null - checkstat 'not a C/C++ file' 1 - - testname="unsupported" - $CCACHE_COMPILE -M foo -c test1.c > /dev/null 2>&1 - checkstat 'unsupported compiler option' 1 - - testname="stdout" - $CCACHE echo foo -c test1.c > /dev/null - checkstat 'compiler produced stdout' 1 - - testname="non-regular" - mkdir testd - $CCACHE_COMPILE -o testd -c test1.c > /dev/null 2>&1 - rmdir testd - checkstat 'output to a non-regular file' 1 - - testname="no-input" - $CCACHE_COMPILE -c -O2 2> /dev/null - checkstat 'no input file' 1 - - - testname="CCACHE_DISABLE" - CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2> /dev/null - checkstat 'cache hit' 3 - $CCACHE_COMPILE -c test1.c - checkstat 'cache hit' 4 - - testname="CCACHE_CPP2" - CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O - checkstat 'cache hit' 4 - checkstat 'cache miss' 3 - - CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O - checkstat 'cache hit' 5 - checkstat 'cache miss' 3 - - testname="CCACHE_NOSTATS" - CCACHE_NOSTATS=1 $CCACHE_COMPILE -c test1.c -O -O - checkstat 'cache hit' 5 - checkstat 'cache miss' 3 - - testname="CCACHE_RECACHE" - CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c -O -O - checkstat 'cache hit' 5 - checkstat 'cache miss' 4 - - # strictly speaking should be 6 - RECACHE causes a double counting! - checkstat 'files in cache' 8 - $CCACHE -c > /dev/null - checkstat 'files in cache' 6 - - - testname="CCACHE_HASHDIR" - CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O - checkstat 'cache hit' 5 - checkstat 'cache miss' 5 - - CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O - checkstat 'cache hit' 6 - checkstat 'cache miss' 5 - - checkstat 'files in cache' 8 - - testname="comments" - echo '/* a silly comment */' > test1-comment.c - cat test1.c >> test1-comment.c - $CCACHE_COMPILE -c test1-comment.c - rm -f test1-comment* - checkstat 'cache hit' 6 - checkstat 'cache miss' 6 - - testname="CCACHE_UNIFY" - CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c - checkstat 'cache hit' 6 - checkstat 'cache miss' 7 - mv test1.c test1-saved.c - echo '/* another comment */' > test1.c - cat test1-saved.c >> test1.c - CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c - mv test1-saved.c test1.c - checkstat 'cache hit' 7 - checkstat 'cache miss' 7 - - testname="cache-size" - for f in *.c; do - $CCACHE_COMPILE -c $f - done - checkstat 'cache hit' 8 - checkstat 'cache miss' 37 - checkstat 'files in cache' 72 - $CCACHE -F 48 -c > /dev/null - if [ `getstat 'files in cache'` -gt 48 ]; then - test_failed '-F test failed' - fi - - testname="cpp call" - $CCACHE_COMPILE -c test1.c -E > test1.i - checkstat 'cache hit' 8 - checkstat 'cache miss' 37 - - testname="direct .i compile" - $CCACHE_COMPILE -c test1.c - checkstat 'cache hit' 8 - checkstat 'cache miss' 38 - - $CCACHE_COMPILE -c test1.i - checkstat 'cache hit' 9 - checkstat 'cache miss' 38 - - $CCACHE_COMPILE -c test1.i - checkstat 'cache hit' 10 - checkstat 'cache miss' 38 - - # removed these tests as some compilers (including newer versions of gcc) - # determine which language to use based on .ii/.i extension, and C++ may - # not be installed -# testname="direct .ii file" -# mv test1.i test1.ii -# $CCACHE_COMPILE -c test1.ii -# checkstat 'cache hit' 10 -# checkstat 'cache miss' 39 - -# $CCACHE_COMPILE -c test1.ii -# checkstat 'cache hit' 11 -# checkstat 'cache miss' 39 - - testname="stripc" # This test might not be portable - CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c - checkstat 'cache hit' 10 - checkstat 'cache miss' 39 - - CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c - checkstat 'cache hit' 11 - checkstat 'cache miss' 39 - - testname="zero-stats" - $CCACHE -z > /dev/null - checkstat 'cache hit' 0 - checkstat 'cache miss' 0 - - testname="clear" - $CCACHE -C > /dev/null - checkstat 'files in cache' 0 - - - rm -f test1.c -} - -swigtests() { - echo "starting swig testsuite $testsuite" - rm -rf "$CCACHE_DIR" - checkstat 'cache hit' 0 - checkstat 'cache miss' 0 - - j=1 - rm -f *.i - genswigcode testswig1.i 1 - - testname="BASIC" - $CCACHE_COMPILE -java testswig1.i - checkstat 'cache hit' 0 - checkstat 'cache miss' 1 - - checkstat 'files in cache' 6 - - testname="BASIC2" - $CCACHE_COMPILE -java testswig1.i - checkstat 'cache hit' 1 - checkstat 'cache miss' 1 - - testname="output" - $CCACHE_COMPILE -java testswig1.i -o foo_wrap.c - checkstat 'cache hit' 1 - checkstat 'cache miss' 2 - - testname="bad" - $CCACHE_COMPILE -java testswig1.i -I 2> /dev/null - checkstat 'bad compiler arguments' 1 - - testname="stdout" - $CCACHE_COMPILE -v -java testswig1.i > /dev/null - checkstat 'compiler produced stdout' 1 - - testname="non-regular" - mkdir testd - $CCACHE_COMPILE -o testd -java testswig1.i > /dev/null 2>&1 - rmdir testd - checkstat 'output to a non-regular file' 1 - - testname="no-input" - $CCACHE_COMPILE -java 2> /dev/null - checkstat 'no input file' 1 - - - testname="CCACHE_DISABLE" - CCACHE_DISABLE=1 $CCACHE_COMPILE -java testswig1.i 2> /dev/null - checkstat 'cache hit' 1 - $CCACHE_COMPILE -java testswig1.i - checkstat 'cache hit' 2 - - testname="CCACHE_CPP2" - CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i - checkstat 'cache hit' 2 - checkstat 'cache miss' 3 - - CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i - checkstat 'cache hit' 3 - checkstat 'cache miss' 3 - - testname="CCACHE_NOSTATS" - CCACHE_NOSTATS=1 $CCACHE_COMPILE -java -O -O testswig1.i - checkstat 'cache hit' 3 - checkstat 'cache miss' 3 - - testname="CCACHE_RECACHE" - CCACHE_RECACHE=1 $CCACHE_COMPILE -java -O -O testswig1.i - checkstat 'cache hit' 3 - checkstat 'cache miss' 4 - - # strictly speaking should be 3x6=18 instead of 4x6=24 - RECACHE causes a double counting! - checkstat 'files in cache' 24 - $CCACHE -c > /dev/null - checkstat 'files in cache' 18 - - - testname="CCACHE_HASHDIR" - CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i - checkstat 'cache hit' 3 - checkstat 'cache miss' 5 - - CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i - checkstat 'cache hit' 4 - checkstat 'cache miss' 5 - - checkstat 'files in cache' 24 - - testname="cpp call" - $CCACHE_COMPILE -java -E testswig1.i > testswig1-preproc.i - checkstat 'cache hit' 4 - checkstat 'cache miss' 5 - - testname="direct .i compile" - $CCACHE_COMPILE -java testswig1.i - checkstat 'cache hit' 5 - checkstat 'cache miss' 5 - - # No cache hit due to different input file name, -nopreprocess should not be given twice to SWIG - $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i - checkstat 'cache hit' 5 - checkstat 'cache miss' 6 - - $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i - checkstat 'cache hit' 6 - checkstat 'cache miss' 6 - - testname="stripc" - CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O testswig1.i - checkstat 'cache hit' 7 - checkstat 'cache miss' 6 - - CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O -O testswig1.i - checkstat 'cache hit' 7 - checkstat 'cache miss' 7 - - rm -f testswig1-preproc.i - rm -f testswig1.i -} - -###### -# main program -rm -rf $TESTDIR -mkdir $TESTDIR -cd $TESTDIR || exit 1 -CCACHE_DIR="ccache dir" # with space in directory name (like Windows default) -mkdir "$CCACHE_DIR" -export CCACHE_DIR - -testsuite="base" -CCACHE_COMPILE="$CCACHE $COMPILER" -basetests -CCACHE_COMPILE="$CCACHE $SWIG" -swigtests - -if test -z "$NOSOFTLINKSTEST"; then - testsuite="link" - ln -s $CCACHE $COMPILER - CCACHE_COMPILE="./$COMPILER" - basetests - rm "./$COMPILER" - ln -s $CCACHE $SWIG - CCACHE_COMPILE="./$SWIG" - swigtests - rm "./$SWIG" -else - echo "skipping testsuite link" -fi - -testsuite="hardlink" -CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $COMPILER" -basetests -CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $SWIG" -swigtests - -testsuite="cpp2" -CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $COMPILER" -basetests -CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $SWIG" -swigtests - -testsuite="nlevels4" -CCACHE_COMPILE="env CCACHE_NLEVELS=4 $CCACHE $COMPILER" -basetests - -testsuite="nlevels1" -CCACHE_COMPILE="env CCACHE_NLEVELS=1 $CCACHE $COMPILER" -basetests - -cd .. -rm -rf $TESTDIR -echo test done - OK -exit 0 diff --git a/CCache/unify.c b/CCache/unify.c deleted file mode 100644 index a93d48a02..000000000 --- a/CCache/unify.c +++ /dev/null @@ -1,307 +0,0 @@ -/* - Copyright (C) Andrew Tridgell 2002 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ -/* - C/C++ unifier - - the idea is that changes that don't affect the resulting C code - should not change the hash. This is achieved by folding white-space - and other non-semantic fluff in the input into a single unified format. - - This unifier was design to match the output of the unifier in - compilercache, which is flex based. The major difference is that - this unifier is much faster (about 2x) and more forgiving of - syntactic errors. Continuing on syntactic errors is important to - cope with C/C++ extensions in the local compiler (for example, - inline assembly systems). -*/ - -#include "ccache.h" - -static char *s_tokens[] = { - "...", ">>=", "<<=", "+=", "-=", "*=", "/=", "%=", "&=", "^=", - "|=", ">>", "<<", "++", "--", "->", "&&", "||", "<=", ">=", - "==", "!=", ";", "{", "<%", "}", "%>", ",", ":", "=", - "(", ")", "[", "<:", "]", ":>", ".", "&", "!", "~", - "-", "+", "*", "/", "%", "<", ">", "^", "|", "?", - 0 -}; - -#define C_ALPHA 1 -#define C_SPACE 2 -#define C_TOKEN 4 -#define C_QUOTE 8 -#define C_DIGIT 16 -#define C_HEX 32 -#define C_FLOAT 64 -#define C_SIGN 128 - -static struct { - unsigned char type; - unsigned char num_toks; - char *toks[7]; -} tokens[256]; - -/* build up the table used by the unifier */ -static void build_table(void) -{ - unsigned char c; - int i; - static int done; - - if (done) return; - done = 1; - - memset(tokens, 0, sizeof(tokens)); - for (c=0;c<128;c++) { - if (isalpha(c) || c == '_') tokens[c].type |= C_ALPHA; - if (isdigit(c)) tokens[c].type |= C_DIGIT; - if (isspace(c)) tokens[c].type |= C_SPACE; - if (isxdigit(c)) tokens[c].type |= C_HEX; - } - tokens['\''].type |= C_QUOTE; - tokens['"'].type |= C_QUOTE; - tokens['l'].type |= C_FLOAT; - tokens['L'].type |= C_FLOAT; - tokens['f'].type |= C_FLOAT; - tokens['F'].type |= C_FLOAT; - tokens['U'].type |= C_FLOAT; - tokens['u'].type |= C_FLOAT; - - tokens['-'].type |= C_SIGN; - tokens['+'].type |= C_SIGN; - - for (i=0;s_tokens[i];i++) { - c = s_tokens[i][0]; - tokens[c].type |= C_TOKEN; - tokens[c].toks[tokens[c].num_toks] = s_tokens[i]; - tokens[c].num_toks++; - } -} - -/* buffer up characters before hashing them */ -static void pushchar(unsigned char c) -{ - static unsigned char buf[64]; - static int len; - - if (c == 0) { - if (len > 0) { - hash_buffer((char *)buf, len); - len = 0; - } - hash_buffer(NULL, 0); - return; - } - - buf[len++] = c; - if (len == 64) { - hash_buffer((char *)buf, len); - len = 0; - } -} - -/* hash some C/C++ code after unifying */ -static void unify(unsigned char *p, size_t size) -{ - size_t ofs; - unsigned char q; - int i; - - build_table(); - - for (ofs=0; ofs 2 && p[ofs+1] == ' ' && isdigit(p[ofs+2])) { - do { - ofs++; - } while (ofs < size && p[ofs] != '\n'); - ofs++; - } else { - do { - pushchar(p[ofs]); - ofs++; - } while (ofs < size && p[ofs] != '\n'); - pushchar('\n'); - ofs++; - } - continue; - } - - if (tokens[p[ofs]].type & C_ALPHA) { - do { - pushchar(p[ofs]); - ofs++; - } while (ofs < size && - (tokens[p[ofs]].type & (C_ALPHA|C_DIGIT))); - pushchar('\n'); - continue; - } - - if (tokens[p[ofs]].type & C_DIGIT) { - do { - pushchar(p[ofs]); - ofs++; - } while (ofs < size && - ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.')); - if (ofs < size && (p[ofs] == 'x' || p[ofs] == 'X')) { - do { - pushchar(p[ofs]); - ofs++; - } while (ofs < size && (tokens[p[ofs]].type & C_HEX)); - } - if (ofs < size && (p[ofs] == 'E' || p[ofs] == 'e')) { - pushchar(p[ofs]); - ofs++; - while (ofs < size && - (tokens[p[ofs]].type & (C_DIGIT|C_SIGN))) { - pushchar(p[ofs]); - ofs++; - } - } - while (ofs < size && (tokens[p[ofs]].type & C_FLOAT)) { - pushchar(p[ofs]); - ofs++; - } - pushchar('\n'); - continue; - } - - if (tokens[p[ofs]].type & C_SPACE) { - do { - ofs++; - } while (ofs < size && (tokens[p[ofs]].type & C_SPACE)); - continue; - } - - if (tokens[p[ofs]].type & C_QUOTE) { - q = p[ofs]; - pushchar(p[ofs]); - do { - ofs++; - while (ofs < size-1 && p[ofs] == '\\') { - pushchar(p[ofs]); - pushchar(p[ofs+1]); - ofs+=2; - } - pushchar(p[ofs]); - } while (ofs < size && p[ofs] != q); - pushchar('\n'); - ofs++; - continue; - } - - if (tokens[p[ofs]].type & C_TOKEN) { - q = p[ofs]; - for (i=0;i= ofs+len && memcmp(&p[ofs], s, len) == 0) { - int j; - for (j=0;s[j];j++) { - pushchar(s[j]); - ofs++; - } - pushchar('\n'); - break; - } - } - if (i < tokens[q].num_toks) { - continue; - } - } - - pushchar(p[ofs]); - pushchar('\n'); - ofs++; - } - pushchar(0); -} - - -/* hash a file that consists of preprocessor output, but remove any line - number information from the hash -*/ -int unify_hash(const char *fname) -{ -#ifdef _WIN32 - HANDLE file; - HANDLE section; - DWORD filesize_low; - char *map; - int ret = -1; - - file = CreateFileA(fname, GENERIC_READ, FILE_SHARE_READ, NULL, - OPEN_EXISTING, 0, NULL); - if (file != INVALID_HANDLE_VALUE) { - filesize_low = GetFileSize(file, NULL); - if (!(filesize_low == INVALID_FILE_SIZE && GetLastError() != NO_ERROR)) { - section = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL); - CloseHandle(file); - if (section != NULL) { - map = MapViewOfFile(section, FILE_MAP_READ, 0, 0, 0); - CloseHandle(section); - if (map != NULL) - ret = 0; - } - } - } - - if (ret == -1) { - cc_log("Failed to open preprocessor output %s\n", fname); - stats_update(STATS_PREPROCESSOR); - return -1; - } - - /* pass it through the unifier */ - unify((unsigned char *)map, filesize_low); - - UnmapViewOfFile(map); - - return 0; -#else - int fd; - struct stat st; - char *map; - - fd = open(fname, O_RDONLY|O_BINARY); - if (fd == -1 || fstat(fd, &st) != 0) { - cc_log("Failed to open preprocessor output %s\n", fname); - stats_update(STATS_PREPROCESSOR); - return -1; - } - - /* we use mmap() to make it easy to handle arbitrarily long - lines in preprocessor output. I have seen lines of over - 100k in length, so this is well worth it */ - map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0); - if (map == (char *)-1) { - cc_log("Failed to mmap %s\n", fname); - stats_update(STATS_PREPROCESSOR); - return -1; - } - close(fd); - - /* pass it through the unifier */ - unify((unsigned char *)map, st.st_size); - - munmap(map, st.st_size); - - return 0; -#endif -} - diff --git a/CCache/util.c b/CCache/util.c deleted file mode 100644 index bba232492..000000000 --- a/CCache/util.c +++ /dev/null @@ -1,884 +0,0 @@ -/* - Copyright (C) Andrew Tridgell 2002 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "ccache.h" - -static FILE *logfile; - -/* log a message to the CCACHE_LOGFILE location */ -void cc_log(const char *format, ...) -{ - va_list ap; - extern char *cache_logfile; - - if (!cache_logfile) return; - - if (!logfile) logfile = fopen(cache_logfile, "a"); - if (!logfile) return; - - va_start(ap, format); - vfprintf(logfile, format, ap); - va_end(ap); - fflush(logfile); -} - -/* something went badly wrong! */ -void fatal(const char *msg) -{ - cc_log("FATAL: %s\n", msg); - exit(1); -} - -int safe_rename(const char* oldpath, const char* newpath) -{ - /* safe_rename is for creating entries in the cache. - - Works like rename(), but it never overwrites an existing - cache entry. This avoids corruption on NFS. */ -#ifndef _WIN32 - int status = link(oldpath, newpath); - if( status == 0 || errno == EEXIST ) -#else - int status = CreateHardLinkA(newpath, oldpath, NULL) ? 0 : -1; - if( status == 0 || GetLastError() == ERROR_ALREADY_EXISTS ) -#endif - { - return unlink( oldpath ); - } - else - { - return -1; - } -} - -#ifndef ENABLE_ZLIB -/* copy all data from one file descriptor to another */ -void copy_fd(int fd_in, int fd_out) -{ - char buf[10240]; - int n; - - while ((n = read(fd_in, buf, sizeof(buf))) > 0) { - if (write(fd_out, buf, n) != n) { - fatal("Failed to copy fd"); - } - } -} - -#ifndef HAVE_MKSTEMP -/* cheap and nasty mkstemp replacement */ -static int mkstemp(char *template) -{ - mktemp(template); - return open(template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600); -} -#endif - -/* move a file using rename */ -int move_file(const char *src, const char *dest) { - return safe_rename(src, dest); -} - -/* copy a file - used when hard links don't work - the copy is done via a temporary file and atomic rename -*/ -static int copy_file(const char *src, const char *dest) -{ - int fd1, fd2; - char buf[10240]; - int n; - char *tmp_name; - mode_t mask; - - x_asprintf(&tmp_name, "%s.XXXXXX", dest); - - fd1 = open(src, O_RDONLY|O_BINARY); - if (fd1 == -1) { - free(tmp_name); - return -1; - } - - fd2 = mkstemp(tmp_name); - if (fd2 == -1) { - close(fd1); - free(tmp_name); - return -1; - } - - while ((n = read(fd1, buf, sizeof(buf))) > 0) { - if (write(fd2, buf, n) != n) { - close(fd2); - close(fd1); - unlink(tmp_name); - free(tmp_name); - return -1; - } - } - - close(fd1); - - /* get perms right on the tmp file */ -#ifndef _WIN32 - mask = umask(0); - fchmod(fd2, 0666 & ~mask); - umask(mask); -#else - (void)mask; -#endif - - /* the close can fail on NFS if out of space */ - if (close(fd2) == -1) { - unlink(tmp_name); - free(tmp_name); - return -1; - } - - unlink(dest); - - if (rename(tmp_name, dest) == -1) { - unlink(tmp_name); - free(tmp_name); - return -1; - } - - free(tmp_name); - - return 0; -} - -/* copy a file to the cache */ -static int copy_file_to_cache(const char *src, const char *dest) { - return copy_file(src, dest); -} - -/* copy a file from the cache */ -static int copy_file_from_cache(const char *src, const char *dest) { - return copy_file(src, dest); -} - -#else /* ENABLE_ZLIB */ - -/* copy all data from one file descriptor to another - possibly decompressing it -*/ -void copy_fd(int fd_in, int fd_out) { - char buf[10240]; - int n; - gzFile gz_in; - - gz_in = gzdopen(dup(fd_in), "rb"); - - if (!gz_in) { - fatal("Failed to copy fd"); - } - - while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { - if (write(fd_out, buf, n) != n) { - fatal("Failed to copy fd"); - } - } -} - -static int _copy_file(const char *src, const char *dest, int mode) { - int fd_in, fd_out; - gzFile gz_in, gz_out = NULL; - char buf[10240]; - int n, ret; - char *tmp_name; - mode_t mask; - struct stat st; - - x_asprintf(&tmp_name, "%s.XXXXXX", dest); - - if (getenv("CCACHE_NOCOMPRESS")) { - mode = COPY_UNCOMPRESSED; - } - - /* open source file */ - fd_in = open(src, O_RDONLY); - if (fd_in == -1) { - return -1; - } - - gz_in = gzdopen(fd_in, "rb"); - if (!gz_in) { - close(fd_in); - return -1; - } - - /* open destination file */ - fd_out = mkstemp(tmp_name); - if (fd_out == -1) { - gzclose(gz_in); - free(tmp_name); - return -1; - } - - if (mode == COPY_TO_CACHE) { - /* The gzip file format occupies at least 20 bytes. So - it will always occupy an entire filesystem block, - even for empty files. - Since most stderr files will be empty, we turn off - compression in this case to save space. - */ - if (fstat(fd_in, &st) != 0) { - gzclose(gz_in); - close(fd_out); - free(tmp_name); - return -1; - } - if (file_size(&st) == 0) { - mode = COPY_UNCOMPRESSED; - } - } - - if (mode == COPY_TO_CACHE) { - gz_out = gzdopen(dup(fd_out), "wb"); - if (!gz_out) { - gzclose(gz_in); - close(fd_out); - free(tmp_name); - return -1; - } - } - - while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) { - if (mode == COPY_TO_CACHE) { - ret = gzwrite(gz_out, buf, n); - } else { - ret = write(fd_out, buf, n); - } - if (ret != n) { - gzclose(gz_in); - if (gz_out) { - gzclose(gz_out); - } - close(fd_out); - unlink(tmp_name); - free(tmp_name); - return -1; - } - } - - gzclose(gz_in); - if (gz_out) { - gzclose(gz_out); - } - - /* get perms right on the tmp file */ - mask = umask(0); - fchmod(fd_out, 0666 & ~mask); - umask(mask); - - /* the close can fail on NFS if out of space */ - if (close(fd_out) == -1) { - unlink(tmp_name); - free(tmp_name); - return -1; - } - - unlink(dest); - - if (rename(tmp_name, dest) == -1) { - unlink(tmp_name); - free(tmp_name); - return -1; - } - - free(tmp_name); - - return 0; -} - -/* move a file to the cache, compressing it */ -int move_file(const char *src, const char *dest) { - int ret; - - ret = _copy_file(src, dest, COPY_TO_CACHE); - if (ret != -1) unlink(src); - return ret; -} - -/* copy a file to the cache, compressing it */ -static int copy_file_to_cache(const char *src, const char *dest) { - return _copy_file(src, dest, COPY_TO_CACHE); -} - -/* copy a file from the cache, decompressing it */ -static int copy_file_from_cache(const char *src, const char *dest) { - return _copy_file(src, dest, COPY_FROM_CACHE); -} -#endif /* ENABLE_ZLIB */ - -/* test if a file is zlib compressed */ -int test_if_compressed(const char *filename) { - FILE *f; - - f = fopen(filename, "rb"); - if (!f) { - return 0; - } - - /* test if file starts with 1F8B, which is zlib's - * magic number */ - if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) { - fclose(f); - return 0; - } - - fclose(f); - return 1; -} - -/* copy file to the cache with error checking taking into account compression and hard linking if desired */ -int commit_to_cache(const char *src, const char *dest, int hardlink) -{ - int ret = -1; - struct stat st; - if (stat(src, &st) == 0) { - unlink(dest); - if (hardlink) { -#ifdef _WIN32 - ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1; -#else - ret = link(src, dest); -#endif - } - if (ret == -1) { - ret = copy_file_to_cache(src, dest); - if (ret == -1) { - cc_log("failed to commit %s -> %s (%s)\n", src, dest, strerror(errno)); - stats_update(STATS_ERROR); - } - } - } else { - cc_log("failed to put %s in the cache (%s)\n", src, strerror(errno)); - stats_update(STATS_ERROR); - } - return ret; -} - -/* copy file out of the cache with error checking taking into account compression and hard linking if desired */ -int retrieve_from_cache(const char *src, const char *dest, int hardlink) -{ - int ret = 0; - - x_utimes(src); - - if (strcmp(dest, "/dev/null") == 0) { - ret = 0; - } else { - unlink(dest); - /* only make a hardlink if the cache file is uncompressed */ - if (hardlink && test_if_compressed(src) == 0) { -#ifdef _WIN32 - ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1; -#else - ret = link(src, dest); -#endif - } else { - ret = copy_file_from_cache(src, dest); - } - } - - /* the cached file might have been deleted by some external process */ - if (ret == -1 && errno == ENOENT) { - cc_log("hashfile missing for %s\n", dest); - stats_update(STATS_MISSING); - return -1; - } - - if (ret == -1) { - ret = copy_file_from_cache(src, dest); - if (ret == -1) { - cc_log("failed to retrieve %s -> %s (%s)\n", src, dest, strerror(errno)); - stats_update(STATS_ERROR); - return -1; - } - } - return ret; -} - -/* make sure a directory exists */ -int create_dir(const char *dir) -{ - struct stat st; - if (stat(dir, &st) == 0) { - if (S_ISDIR(st.st_mode)) { - return 0; - } - errno = ENOTDIR; - return 1; - } -#ifdef _WIN32 - if (mkdir(dir) != 0 && errno != EEXIST) { - return 1; - } -#else - if (mkdir(dir, 0777) != 0 && errno != EEXIST) { - return 1; - } -#endif - return 0; -} - -char const CACHEDIR_TAG[] = - "Signature: 8a477f597d28d172789f06886806bc55\n" - "# This file is a cache directory tag created by ccache.\n" - "# For information about cache directory tags, see:\n" - "# http://www.brynosaurus.com/cachedir/\n"; - -int create_cachedirtag(const char *dir) -{ - char *filename; - struct stat st; - FILE *f; - x_asprintf(&filename, "%s/CACHEDIR.TAG", dir); - if (stat(filename, &st) == 0) { - if (S_ISREG(st.st_mode)) { - goto success; - } - errno = EEXIST; - goto error; - } - f = fopen(filename, "w"); - if (!f) goto error; - if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) { - goto error; - } - if (fclose(f)) goto error; -success: - free(filename); - return 0; -error: - free(filename); - return 1; -} - -/* - this is like asprintf() but dies if the malloc fails - note that we use vsnprintf in a rather poor way to make this more portable -*/ -void x_asprintf(char **ptr, const char *format, ...) -{ - va_list ap; - - *ptr = NULL; - va_start(ap, format); - if (vasprintf(ptr, format, ap) == -1) { - fatal("out of memory in x_asprintf"); - } - va_end(ap); - - if (!ptr) fatal("out of memory in x_asprintf"); -} - -/* - this is like strdup() but dies if the malloc fails -*/ -char *x_strdup(const char *s) -{ - char *ret; - ret = strdup(s); - if (!ret) { - fatal("out of memory in strdup\n"); - } - return ret; -} - -/* - this is like malloc() but dies if the malloc fails -*/ -void *x_malloc(size_t size) -{ - void *ret; - ret = malloc(size); - if (!ret) { - fatal("out of memory in malloc\n"); - } - return ret; -} - -/* - this is like realloc() but dies if the malloc fails -*/ -void *x_realloc(void *ptr, size_t size) -{ - void *p2; -#if 1 - /* Avoid invalid read in memcpy below */ - p2 = realloc(ptr, size); - if (!p2) { - fatal("out of memory in x_realloc"); - } -#else - if (!ptr) return x_malloc(size); - p2 = malloc(size); - if (!p2) { - fatal("out of memory in x_realloc"); - } - if (ptr) { - /* Note invalid read as the memcpy reads beyond the memory allocated by ptr */ - memcpy(p2, ptr, size); - free(ptr); - } -#endif - return p2; -} - - -/* - revsusive directory traversal - used for cleanup - fn() is called on all files/dirs in the tree - */ -void traverse(const char *dir, void (*fn)(const char *, struct stat *)) -{ - DIR *d; - struct dirent *de; - - d = opendir(dir); - if (!d) return; - - while ((de = readdir(d))) { - char *fname; - struct stat st; - - if (strcmp(de->d_name,".") == 0) continue; - if (strcmp(de->d_name,"..") == 0) continue; - - if (strlen(de->d_name) == 0) continue; - - x_asprintf(&fname, "%s/%s", dir, de->d_name); -#ifdef _WIN32 - if (stat(fname, &st)) -#else - if (lstat(fname, &st)) -#endif - { - if (errno != ENOENT) { - perror(fname); - } - free(fname); - continue; - } - - if (S_ISDIR(st.st_mode)) { - traverse(fname, fn); - } - - fn(fname, &st); - free(fname); - } - - closedir(d); -} - - -/* return the base name of a file - caller frees */ -char *str_basename(const char *s) -{ - char *p = strrchr(s, '/'); - if (p) { - s = (p+1); - } - -#ifdef _WIN32 - p = strrchr(s, '\\'); - - if (p) { - s = (p+1); - } -#endif - - return x_strdup(s); -} - -/* return the dir name of a file - caller frees */ -char *dirname(char *s) -{ - char *p; - s = x_strdup(s); - p = strrchr(s, '/'); -#ifdef _WIN32 - p = strrchr(s, '\\'); -#endif - if (p) { - *p = 0; - } - return s; -} - -/* - http://www.ecst.csuchico.edu/~beej/guide/ipc/flock.html - http://cvs.php.net/viewvc.cgi/php-src/win32/flock.c?revision=1.2&view=markup - Should return 0 for success, >0 otherwise - */ -int lock_fd(int fd) -{ -#ifdef _WIN32 -# if 1 - return _locking(fd, _LK_NBLCK, 1); -# else - HANDLE fl = (HANDLE)_get_osfhandle(fd); - OVERLAPPED o; - memset(&o, 0, sizeof(o)); - return (LockFileEx(fl, LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &o)) - ? 0 : GetLastError(); -# endif -#else - struct flock fl; - int ret; - - fl.l_type = F_WRLCK; - fl.l_whence = SEEK_SET; - fl.l_start = 0; - fl.l_len = 1; - fl.l_pid = 0; - - /* not sure why we would be getting a signal here, - but one user claimed it is possible */ - do { - ret = fcntl(fd, F_SETLKW, &fl); - } while (ret == -1 && errno == EINTR); - return ret; -#endif -} - -/* return size on disk of a file */ -size_t file_size(struct stat *st) -{ -#ifdef _WIN32 - return (st->st_size + 1023) & ~1023; -#else - size_t size = st->st_blocks * 512; - if ((size_t)st->st_size > size) { - /* probably a broken stat() call ... */ - size = (st->st_size + 1023) & ~1023; - } - return size; -#endif -} - - -/* a safe open/create for read-write */ -int safe_open(const char *fname) -{ - int fd = open(fname, O_RDWR|O_BINARY); - if (fd == -1 && errno == ENOENT) { - fd = open(fname, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0666); - if (fd == -1 && errno == EEXIST) { - fd = open(fname, O_RDWR|O_BINARY); - } - } - return fd; -} - -/* display a kilobyte unsigned value in M, k or G */ -void display_size(unsigned v) -{ - if (v > 1024*1024) { - printf("%8.1f Gbytes", v/((double)(1024*1024))); - } else if (v > 1024) { - printf("%8.1f Mbytes", v/((double)(1024))); - } else { - printf("%8u Kbytes", v); - } -} - -/* return a value in multiples of 1024 give a string that can end - in K, M or G -*/ -size_t value_units(const char *s) -{ - char m; - double v = atof(s); - m = s[strlen(s)-1]; - switch (m) { - case 'G': - case 'g': - default: - v *= 1024*1024; - break; - case 'M': - case 'm': - v *= 1024; - break; - case 'K': - case 'k': - v *= 1; - break; - } - return (size_t)v; -} - - -/* - a sane realpath() function, trying to cope with stupid path limits and - a broken API -*/ -char *x_realpath(const char *path) -{ -#ifdef _WIN32 - char namebuf[MAX_PATH]; - DWORD ret; - - ret = GetFullPathNameA(path, sizeof(namebuf), namebuf, NULL); - if (ret == 0 || ret >= sizeof(namebuf)) { - return NULL; - } - - return x_strdup(namebuf); -#else - int maxlen; - char *ret, *p; -#ifdef PATH_MAX - maxlen = PATH_MAX; -#elif defined(MAXPATHLEN) - maxlen = MAXPATHLEN; -#elif defined(_PC_PATH_MAX) - maxlen = pathconf(path, _PC_PATH_MAX); -#endif - if (maxlen < 4096) maxlen = 4096; - - ret = x_malloc(maxlen); - -#if HAVE_REALPATH - p = realpath(path, ret); -#else - /* yes, there are such systems. This replacement relies on - the fact that when we call x_realpath we only care about symlinks */ - { - int len = readlink(path, ret, maxlen-1); - if (len == -1) { - free(ret); - return NULL; - } - ret[len] = 0; - p = ret; - } -#endif - if (p) { - p = x_strdup(p); - free(ret); - return p; - } - free(ret); - return NULL; -#endif -} - -/* a getcwd that will returns an allocated buffer */ -char *gnu_getcwd(void) -{ - unsigned size = 128; - - while (1) { - char *buffer = (char *)x_malloc(size); - if (getcwd(buffer, size) == buffer) { - return buffer; - } - free(buffer); - if (errno != ERANGE) { - return 0; - } - size *= 2; - } -} - -/* create an empty file */ -int create_empty_file(const char *fname) -{ - int fd; - - fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666); - if (fd == -1) { - return -1; - } - close(fd); - return 0; -} - -/* - return current users home directory or die -*/ -const char *get_home_directory(void) -{ -#ifdef _WIN32 - static char home_path[MAX_PATH] = {0}; - HRESULT ret; - - /* we already have the path */ - if (home_path[0] != 0) { - return home_path; - } - - /* get the path to "Application Data" folder */ - ret = SHGetFolderPathA(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, home_path); - if (SUCCEEDED(ret)) { - return home_path; - } - - fprintf(stderr, "ccache: Unable to determine home directory\n"); - return NULL; -#else - const char *p = getenv("HOME"); - if (p) { - return p; - } -#ifdef HAVE_GETPWUID - { - struct passwd *pwd = getpwuid(getuid()); - if (pwd) { - return pwd->pw_dir; - } - } -#endif - fatal("Unable to determine home directory"); - return NULL; -#endif -} - -int x_utimes(const char *filename) -{ -#ifdef HAVE_UTIMES - return utimes(filename, NULL); -#else - return utime(filename, NULL); -#endif -} - -#ifdef _WIN32 -/* perror for Win32 API calls, using GetLastError() instead of errno */ -void perror_win32(LPTSTR pszFunction) -{ - LPTSTR pszMessage; - DWORD dwLastError = GetLastError(); - - FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | - FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - dwLastError, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - (LPTSTR)&pszMessage, - 0, NULL ); - - fprintf(stderr, "%s: %s\n", pszFunction, pszMessage); - LocalFree(pszMessage); -} -#endif diff --git a/CCache/web/index.html b/CCache/web/index.html deleted file mode 100644 index 4af839135..000000000 --- a/CCache/web/index.html +++ /dev/null @@ -1,158 +0,0 @@ - - - -ccache - - -

      ccache

      - -ccache is a compiler cache. It acts as a caching pre-processor to -C/C++ compilers, using the -E compiler switch and a hash to detect -when a compilation can be satisfied from cache. This often results in -a 5 to 10 times speedup in common compilations.

      - -The idea came from Erik Thiele wrote the original compilercache program -as a bourne shell script. ccache is a re-implementation of Erik's idea -in C with more features and better performance.

      - -

      Latest release

      - -The latest release is ccache 2.4. - -
        -
      • Added CCACHE_READONLY option -
      • Added CCACHE_TEMPDIR option -
      • fixed handling of hard-linked compilers on AIX -
      • added O_BINARY support, to try and support win32 compiles -
      • show cache directory in stats output -
      • fixed handling of HOME environment variable -
      - -See the manual page for details -on the new options.

      - -You can get this release from the download directory - -

      NOTE! This release changes the hash input slighly, so you will -probably find that you will not get any hits against your existing -cache when you upgrade. - -

      Why bother?

      - -Why bother with a compiler cache? If you ever run "make clean; make" -then you can probably benefit from ccache. It is very common for -developers to do a clean build of a project for a whole host of -reasons, and this throws away all the information from your previous -compiles.

      - -By using ccache you can get exactly the same effect as "make clean; -make" but much faster. It also helps a lot when doing RPM builds, -as RPM can make doing incremental builds tricky.

      - -I put the effort into writing ccache for 2 reasons. The first is the -Samba build farm -(http://build.samba.org/) -which constantly does clean builds of Samba on about 30 machines after each -CVS commit. On some of those machines the build took over an hour. By -using ccache we get the same effect as clean builds but about 6 times -faster.

      - -The second reason is the autobuild system I used to run for -Quantum. That system builds our whole Linux based OS from scratch -after every CVS commit to catch compilation problems quickly. Using -ccache those builds are much faster. - -

      Is it safe?

      - -Yes. The most important aspect of a compiler cache is to always -produce exactly the same output that the real compiler would -produce. The includes providing exactly the same object files and -exactly the same compiler warnings that would be produced if you use -the real compiler. The only way you should be able to tell that you -are using ccache is the speed.

      - -I have coded ccache very carefully to try to provide these guarantees. - -

      Features

      - -
        -
      • keeps statistics on hits/misses -
      • automatic cache size management -
      • can cache compiles that generate warnings -
      • easy installation -
      • very low overhead -
      • uses hard links where possible to avoid copies -
      - -

      Documentation

      - -See the manual page - - -

      Performance

      - -Here are some results for compiling Samba on my Linux laptop. I have -also included the results of using Erik's compilercache program -(version 1.0.10) for comparison.

      - - - - - - -
          ccache  compilercache
      normal 13m 4s 13m 4s
      uncached 13m 15s 15m 41s
      cached 2m 45s 4m 26s
      - -

      How to use it

      - -You can use ccache in two ways. The first is just to prefix your -compile commands with "ccache". For example, you could change the -"CC=gcc" line in your Makefile to be "CC=ccache gcc".

      - -Alternatively, you can create symbolic links from your compilers name -to ccache. This allows you to use ccache without any changes to your -build system. - -

      Download

      - -You can download the latest release from the download directory.

      - -For the bleeding edge, you can fetch ccache via CVS or -rsync. To fetch via cvs use the following command: - -

      -  cvs -d :pserver:cvs@pserver.samba.org:/cvsroot co ccache
      -
      - -To fetch via rsync use this command: - -
      -  rsync -Pavz samba.org::ftp/unpacked/ccache .
      -
      - -

      Related projects

      - -Here are some related programs you may find interesting - -
        -
      • distcc - a distributed compilation system -
      • cachecc1 - a gcc specific cache -
      • gocache - a cross platform compiler cache -
      -

      - -

      Mailing list

      - -

      A mailing -list is available for discussion of ccache. - - -


      - -Andrew Tridgell
      -bugs@ccache.samba.org -
      - - - diff --git a/CHANGES b/CHANGES index d9426512b..782849c6f 100644 --- a/CHANGES +++ b/CHANGES @@ -2,488 +2,6 @@ SWIG (Simplified Wrapper and Interface Generator) See CHANGES.current for current version. -Version 1.3.39 (21 March 2009) -============================== - -2009-03-19: bhy - [Python] Fix the memory leak related to Python 3 unicode and C char* conversion, - which can be shown in the following example before this fix: - - from li_cstring import * - i=0 - while True: - i += 1 - n = str(i)*10 - test3(n) - - This fix affected SWIG_AsCharPtrAndSize() so you cannot call this function with - a null alloc and non-null cptr argument in Python 3, otherwise a runtime error - will be raised. - -2009-03-18: wsfulton - [C#] std::vector wrapper improvements for .NET 2 and also providing the - necessary machinery to use the std::vector wrappers with more advanced features such - as LINQ - the C# proxy class now derives from IEnumerable<>. The default is now to - generate code requiring .NET 2 as a minimum, although the C# code can be compiled - for .NET 1 by defining the SWIG_DOTNET_1 C# preprocessor constant. See the - std_vector.i file for more details. - - *** POTENTIAL INCOMPATIBILITY *** - -2009-03-12: wsfulton - [Ruby] Fix #2676738 SWIG generated symbol name clashes. - -2009-03-01: bhy - [Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function - PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement. - Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect - the drop of tp_compare and nb_long. - -2009-03-01: bhy - [Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the - case that module already imported at other place. - -2009-02-28: bhy - [Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before - the method calls, since some C compiler don't allow declaration in middle of function - body. - -2009-02-21: wsfulton - [Allegrocl] Fix seg fault wrapping some constant variable (%constant) types. - -2009-02-20: wsfulton - [CFFI] Fix seg faults when for %extend and using statements. - -2009-02-20: wsfulton - Fix SF #2605955: -co option which broke in 1.3.37. - -2009-02-20: wsfulton - New %insert("begin") section added. Also can be used as %begin. This is a new - code section reserved entirely for users and the code within the section is generated - at the top of the C/C++ wrapper file and so provides a means to put custom code - into the wrapper file before anything else that SWIG generates. - -2009-02-17: wsfulton - 'make clean-test-suite' will now run clean on ALL languages. Previously it only - ran the correctly configured languages. This way it is now possible to clean up - properly after running 'make partialcheck-test-suite'. - -2009-02-14: wsfulton - Extend attribute library support for structs/classes and the accessor functions use - pass/return by value semantics. Two new macros are available and usage is identical - to %attribute. These are %attributeval for structs/classes and %attributestring for - string classes, like std::string. See attribute.swg for more details. - -2009-02-13: wsfulton - Add support for %extend and memberin typemaps. Previously the memberin typemaps were - ignored for member variables within a %extend block. - -2009-02-12: wsfulton - Remove unnecessary temporary variable when wrapping return values that are references. - Example of generated code for wrapping: - - struct XYZ { - std::string& refReturn(); - }; - - used to be: - - std::string *result = 0 ; - ... - { - std::string &_result_ref = (arg1)->refReturn(); - result = (std::string *) &_result_ref; - } - - Now it is: - - std::string *result = 0 ; - ... - result = (std::string *) &(arg1)->refReturn(); - -2009-02-08: bhy - Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from - the length of the buffer to the number of items in the buffer. - -2009-02-08: wsfulton - Fix %feature not working for conversion operators, reported by Matt Sprague, for example: - %feature("cs:methodmodifiers") operator bool "protected"; - -2009-02-07: wsfulton - [MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions. - Also fixes Makefile errors building SWIG executable when mzscheme package is installed - (version 3.72 approx and later). - -2009-02-04: talby - [Perl] Fix SF#2564192 reported by David Kolovratnk. - SWIG_AsCharPtrAndSize() now handles "get" magic. - -Version 1.3.38 (31 January 2009) -================================ - -2009-01-31: bhy - [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend - and %pythonappend have correct indentation. - -2009-01-31: bhy - [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list - of static member function in generated proxy code should not have the - 'self' parameter. - -2009-01-29: wsfulton - Fix regression introduced in 1.3.37 where the default output directory - for target language specific files (in the absence of -outdir) was no - longer the same directory as the generated c/c++ file. - -2009-01-28: wsfulton - [Java, C#] Fix proxy class not being used when the global scope operator - was used for parameters passed by value. Reported by David Piepgrass. - -2009-01-15: wsfulton - [Perl] Fix seg fault when running with -v option, reported by John Ky. - -Version 1.3.37 (13 January 2009) -================================ - -2009-01-13: mgossage - [Lua] Added contract support for requiring that unsigned numbers are >=0 - Rewrote much of Examples/Lua/embed3. - Added a lot to the Lua documentation. - -2009-01-13: wsfulton - Fix compilation error when using directors on protected virtual overloaded - methods reported by Sam Hendley. - -2009-01-12: drjoe - [R] Fixed handling of integer arrays - -2009-01-10: drjoe - [R] Fix integer handling in r to deal correctly with signed - and unsigned issues - -2009-01-10: wsfulton - Patch #1992756 from Colin McDonald - %contract not working for classes - in namespace - -2009-01-05: olly - Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source - code and remove documentation of them. - -2008-12-30: wsfulton - Bug #2430756. All the languages now define a macro in the generated C/C++ - wrapper file indicating which language is being wrapped. The macro name is the - same as those defined when SWIG is run, eg SWIGJAVA, SWIGOCTAVE, SWIGCSHARP etc - and are listed in the "Conditional Compilation" section in the documentation. - -2008-12-23: wsfulton - [Java] Fix #2153773 - %nojavaexception was clearing the exception feature - instead of disabling it. Clearing checked Java exceptions also didn't work. - The new %clearjavaexception can be used for clearing the exception feature. - -2008-12-22: wsfulton - Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors - throw exceptions. - -2008-12-21: wsfulton - Apply patch #2440046 which fixes possible seg faults for member and global - variable char arrays when the strings are larger than the string array size. - -2008-12-20: wsfulton - The ccache compiler cache has been adapted to work with SWIG and - named ccache-swig. It now works with C/C++ compilers as well as SWIG - and can result in impressive speedups when used to recompile unchanged - code with either a C/C++ compiler or SWIG. Documentation is in CCache.html - or the installed ccache-swig man page. - -2008-12-12: wsfulton - Apply patch from Kalyanov Dmitry which fixes parsing of nested structs - containing comments. - -2008-12-12: wsfulton - Fix error message in some nested struct and %inline parsing error situations - such as unterminated strings and comments. - -2008-12-07: olly - [PHP] Fix warnings when compiling generated wrapper with GCC 4.3. - -2008-12-06: wsfulton - [PHP] Deprecate %pragma(php4). Please use %pragma(php) instead. - The following two warnings have been renamed: - WARN_PHP4_MULTIPLE_INHERITANCE -> WARN_PHP_MULTIPLE_INHERITANCE - WARN_PHP4_UNKNOWN_PRAGMA -> WARN_PHP_UNKNOWN_PRAGMA - - *** POTENTIAL INCOMPATIBILITY *** - -2008-12-04: bhy - [Python] Applied patch SF#2158938: all the SWIG symbol names started with Py - are changed, since they are inappropriate and discouraged in Python - documentation (from http://www.python.org/doc/2.5.2/api/includes.html): - - "All user visible names defined by Python.h (except those defined by - the included standard headers) have one of the prefixes "Py" or "_Py". - Names beginning with "_Py" are for internal use by the Python implementation - and should not be used by extension writers. Structure member names do - not have a reserved prefix. - - Important: user code should never define names that begin with "Py" or "_Py". - This confuses the reader, and jeopardizes the portability of the user - code to future Python versions, which may define additional names beginning - with one of these prefixes." - - Here is a brief list of what changed: - - PySwig* -> SwigPy* - PyObject_ptr -> SwigPtr_PyObject - PyObject_var -> SwigVar_PyObject - PySequence_Base, PySequence_Cont, PySequence_Ref -> - SwigPySequence_Base, SwigPySequence_Cont, SwigPySequence_Ref - PyMap* -> SwigPyMap* - - We provided a pyname_compat.i for backward compatibility. Users whose code having - these symbols and do not want to change it could simply include this file - at front of your code. A better solution is to run the converting tool on - your code, which has been put in SWIG's SVN trunk (Tools/pyname_patch.py) and - you can download it here: - https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py - - *** POTENTIAL INCOMPATIBILITY *** - -2008-12-02: wsfulton - [Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes - when the package option is specified in %module and that module is %import'ed. - -2008-11-28: wsfulton - [UTL] Fix #2080497. Some incorrect acceptance of types in the STL, eg a double * element - passed into a vector constructor would be accepted, but the ensuing behaviour - was undefined. Now the type conversion correctly raises an exception. - -2008-11-24: wsfulton - Add -outcurrentdir option. This sets the default output directory to the current - directory instead of the path specified by the input file. This option enables - behaviour similar to c/c++ compilers. Note that this controls the output directory, - but only in the absence of the -o and/or -outdir options. - -2008-11-23: wsfulton - [ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in - ruby 1.9. - -2008-11-23: wsfulton - Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace. - -2008-11-21: wsfulton - The use of the include path to find the input file is now deprecated. - This makes the behaviour of SWIG the same as C/C++ compilers in preparation - for use with ccache. - -2008-11-16: wsfulton - Fix -nopreprocess option to: - - correctly report file names in warning and error messages. - - use the original input filename that created the preprocessed output when - determining the C++ wrapper file name (in the absence of -o). Previously - the name of the input file containing the preprocessed output was used. - -2008-11-11: wsfulton - [Java] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the - Intel compiler - -2008-11-01: wsfulton - Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy - class being reported for Python docstrings when %rename is used. - -2008-11-01: wsfulton - Add the strip encoder patch from Anatoly Techtonik #2130016. This enables an - easy way to rename symbols by stripping a commonly used prefix in all the - function/struct names. It works in the same way as the other encoders, such as - title, lower, command etc outlined in CHANGES file dated 12/30/2005. Example - below will rename wxAnotherWidget to AnotherWidget and wxDoSomething to - DoSomething: - - %rename("%(strip:[wx])s") ""; - - struct wxAnotherWidget { - void wxDoSomething(); - }; - -2008-09-26: mutandiz - [allegrocl] - Lots of test-suite work. - - Fix ordering of wrapper output and %{ %} header output. - - Fix declarations of local vars in C wrappers. - - Fix declaration of defined constants in C wrappers. - - Fix declaration of EnumValues in C wrappers. - - add some const typemaps to allegrocl.swg - - add rename for operator bool() overloads. - -2008-09-25: olly - [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186). - -2008-09-22: mutandiz (Mikel Bancroft) - [allegrocl] - - Support wrapping of types whose definitions are not seen by - SWIG. They are treated as forward-referenced classes and if a - definition is not seen are treated as (* :void). - - Don't wrap the contents of unnamed namespaces. - - More code cleanup. Removed some extraneous warnings. - - start work on having the allegrocl mod pass the cpp test-suite. - -2008-09-19: olly - [PHP5] Add typemaps for long long and unsigned long long. - -2008-09-18: wsfulton - [C#] Added C# array typemaps provided by Antti Karanta. - The arrays provide a way to use MarshalAs(UnmanagedType.LPArray) - and pinning the array using 'fixed'. See arrays_csharp.i library file - for details. - -2008-09-18: wsfulton - Document the optional module attribute in the %import directive, - see Modules.html. Add a warning for Python wrappers when the - module name for an imported base class is missing, requiring the - module attribute to be added to %import, eg - - %import(module="FooModule") foo.h - -2008-09-18: olly - [PHP5] Change the default input typemap for char * to turn PHP - Null into C NULL (previously it was converted to an empty string). - The new behaviour is consistent with how the corresponding output - typemap works (SF#2025719). - - If you want to keep the old behaviour, add the following typemap - to your interface file (PHP's convert_to_string_ex() function does - the converting from PHP Null to an empty string): - - %typemap(in) char * { - convert_to_string_ex($input); - $1 = Z_STRVAL_PP($input); - } - -2008-09-18: olly - [PHP5] Fix extra code added to proxy class constructors in the case - where the only constructor takes no arguments. - -2008-09-18: olly - [PHP5] Fix wrapping of a renamed enumerated value of an enum class - member (SF#2095273). - -2008-09-17: mutandiz (Mikel Bancroft) - [allegrocl] - - Fix how forward reference typedefs are handled, so as not to conflict - with other legit typedefs. - - Don't (for now) perform an ffitype typemap lookup when trying to - when calling compose_foreign_type(). This is actually a useful thing - to do in certain cases, the test cases for which I can't currently - locate :/. It's breaking some wrapping behavior that is more commonly - seen, however. I'll readd in a more appropriate way when I can - recreate the needed test case, or a user complains (which means - they probably have a test case). - - document the -isolate command-line arg in the 'swig -help' output. - It was in the html docs, but not there. - - small amount of code cleanup, removed some unused code. - - some minor aesthetic changes. - -2008-09-12: bhy - [Python] Python 3.0 support branch merged into SWIG trunk. Thanks to - Google Summer of Code 2008 for supporting this project! By default - SWIG will generate interface files compatible with both Python 2.x - and 3.0. And there's also some Python 3 new features that can be - enabled by passing a "-py3" command line option to SWIG. These - features are: - - - Function annotation support - Also, the parameter list of proxy function will be generated, - even without the "-py3" option. However, the parameter list - will fallback to *args if the function (or method) is overloaded. - - Buffer interface support - - Abstract base class support - - For details of Python 3 support and these features, please see the - "Python 3 Support" section in the "SWIG and Python" chapter of the SWIG - documentation. - - The "-apply" command line option and support of generating codes - using apply() is removed. Since this is only required by very old - Python. - - This merge also patched SWIG's parser to solve a bug. By this patch, - SWIG features able to be correctly applied on C++ conversion operator, - such like this: - - %feature("shadow") *::operator bool %{ ... %} - -2008-09-02: richardb - [Python] Commit patch #2089149: Director exception handling mangles - returned exception. Exceptions raised by Python code in directors - are now passed through to the caller without change. Also, remove - the ": " prefix which used to be added to other director exceptions - (eg, those due to incorrect return types). - -2008-09-02: wsfulton - [Python] Commit patch #1988296 GCItem multiple module linking issue when using - directors. - -2008-09-02: wsfulton - [C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now - possible through the use of the pre attribute and the new terminator attribute, eg - - %typemap(csin, - pre=" using (CDate temp$csinput = new CDate($csinput)) {", - terminator=" } // terminate temp$csinput using block", - ) const CDate & - "$csclassname.getCPtr(temp$csinput)" - - See CSharp.html for more info. - -2008-09-01: wsfulton - [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into - no-eval context in DEFCENUM - -2008-08-02: wuzzeb - [Chicken,Allegro] Commit Patch 2019314 - Fixes a build error in chicken, and several build errors and other errors - in Allegro CL - -2008-07-19: wsfulton - Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson. - -2008-07-17: wsfulton - Fix SF #2019156 Configuring with --without-octave or --without-alllang - did not disable octave. - -2008-07-14: wsfulton - [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly - marshalled to C#/Java null in director methods. - -2008-07-04: olly - [PHP] For std_vector.i and std_map.i, rename empty() to is_empty() - since "empty" is a PHP reserved word. Based on patch from Mark Klein - in SF#1943417. - -2008-07-04: olly - [PHP] The deprecated command line option "-make" has been removed. - Searches on Google codesearch suggest that nobody is using it now - anyway. - -2008-07-04: olly - [PHP] The SWIG cdata.i library module is now supported. - -2008-07-03: olly - [PHP] The deprecated command line option "-phpfull" has been - removed. We recommend building your extension as a dynamically - loadable module. - -2008-07-02: olly - [PHP4] Support for PHP4 has been removed. The PHP developers are - no longer making new PHP4 releases, and won't even be providing - patches for critical security issues after 2008-08-08. - -2008-07-02: olly - [Python] Import the C extension differently for Python 2.6 and - later so that an implicit relative import doesn't produce a - deprecation warning for 2.6 and a failure for 2.7 and later. - Patch from Richard Boulton in SF#2008229, plus follow-up patches - from Richard and Haoyu Bai. - Version 1.3.36 (24 June 2008) ============================= @@ -959,7 +477,7 @@ Version 1.3.34 (27 February 2008) }; Version 1.3.33 (November 23, 2007) -================================== +================================= 11/21/2007: mikel [allegrocl] omit private slot type info in the classes/types @@ -1891,7 +1409,7 @@ Version 1.3.31 (November 20, 2006) [lua] update to typemap for object by value, to make it c89 compliant Version 1.3.30 (November 13, 2006) -================================== +================================= 11/12/2006: wsfulton [java] Remove DetachCurrentThread patch from 08/11/2006 - it causes segfaults @@ -6214,7 +5732,7 @@ Version 1.3.24 (December 14, 2004) compile with no errors, java shows some problems. Version 1.3.23 (November 11, 2004) -================================== +================================= 11/05/2004: wsfulton Patch #982753 from Fabrice Salvaire: Adds dependencies generation for @@ -8465,8 +7983,7 @@ Version 1.3.22 (September 4, 2004) exception instead. Version 1.3.21 (January 11, 2004) -================================= - +================================== 01/10/2004: cheetah (William Fulton) The output format for both warnings and errors can be selected for integration with your favourite IDE/editor. Editors and IDEs can usually @@ -10240,7 +9757,6 @@ Version 1.3.20 (December 17, 2003) Version 1.3.19 (March 28, 2003) =============================== - 03/28/2003: beazley Variety of minor bug fixes to the 1.3.18 release including: @@ -10827,7 +10343,6 @@ Version 1.3.18 (March 23, 2003) Version 1.3.17 (November 22, 2002) ================================== - 11/19/2002: beazley Fixed [ 613922 ] preprocessor errors with HAVE_LONG_LONG. @@ -11183,7 +10698,6 @@ Version 1.3.16 (October 14, 2002) Version 1.3.15 (September 9, 2002) ================================== - 09/09/2002: beazley Fixed nasty runtime type checking bug with subtypes and inheritance and templates. @@ -12876,7 +12390,6 @@ Version 1.3.14 (August 12, 2002) Version 1.3.13 (June 17, 2002) ============================== - 06/16/2002: beazley Fixed a bug with __FILE__ expansion in the preprocessor. On Windows, the backslash (\) is now converted to (\\) in the string literal @@ -16008,7 +15521,6 @@ Version 1.3.10 (December 10, 2001) Version 1.3.9 (September 25, 2001) ================================== - 9/25/2001: beazley Fixed parsing problem with type declarations like 'char ** const'. SWIG parsed this correctly, but the @@ -16021,7 +15533,6 @@ Version 1.3.9 (September 25, 2001) Version 1.3.8 (September 23, 2001) ================================== - 9/23/2001: beazley Included improved distutils setup.py file in the Tools directory (look for the setup.py.tmpl file). Contributed by @@ -17394,7 +16905,7 @@ Version 1.3 Alpha 5 and function bodies. Preprocessor bug. Version 1.3 Alpha 4 (September 4, 2000) -======================================= +====================================== 9/3/00 : ttn Added instructions for maintainers in Examples/README on how @@ -18480,7 +17991,6 @@ Version 1.3 Alpha 1 (February 11, 2000) Version 1.1 Patch 5 (February 5, 1998) ====================================== - 2/4/98 : Fixed a bug in the configure script when different package locations are specified (--with-tclincl, etc...). @@ -18733,7 +18243,6 @@ Version 1.1 Patch 3 (November 24, 1997) Version 1.1 Patch 2 (September 4, 1997) ======================================= - 9/4/97 : Fixed problem with handling of virtual functions that was introduced by some changes in the C++ module. @@ -19869,7 +19378,7 @@ This release should fix most, if not all, of those problems. it generated alot of unnecessary code). Version 1.1 Beta3 (January 9, 1997) -=================================== +==================================== Note : A *huge* number of changes related to ongoing modifications. @@ -19992,7 +19501,6 @@ Version 1.1 Beta1 (October 30, 1996) Version 1.0 Final (August 31, 1996) =================================== - 1. Fixed minor bug in C++ module 2. Fixed minor bug in pointer type-checker when using @@ -20076,7 +19584,7 @@ number of immediate problems : 3. A few minor fixes were made in the Makefile Version 1.0 Beta 3 (June 14, 1996) -================================== +=================================== There are lots of changes in this release : @@ -20166,7 +19674,6 @@ let me know. Version 1.0 Beta 2 (April 26, 1996) =================================== - This release is identical to Beta1 except a few minor bugs are fixed and the SWIG library has been updated to work with Tcl 7.5/Tk 4.1. A tcl7.5 examples directory is now included. @@ -20181,7 +19688,6 @@ A tcl7.5 examples directory is now included. Version 1.0 Beta 1 (April 10, 1996). ===================================== - This is the first "semi-official" release of SWIG. It has a number of substantial improvements over the Alpha release. These notes are in no particular order--hope I remembered everything.... diff --git a/CHANGES.current b/CHANGES.current index fcf35a6b5..ef3fcca54 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -1,18 +1,3 @@ -Version 1.3.40 (in progress) -============================ +Version 1.3.36 (in progress) +============================= -2009-04-09: wsfulton - Fix #2746858 - C macro expression using floating point numbers - -2009-03-30: olly - [PHP] The default out typemap for char[ANY] now returns the string up to a - zero byte, or the end of the array if there is no zero byte. This - is the same as Python does, and seems more generally useful than - the previous behaviour of returning the whole contents of the array - including any zero bytes. If you want the old behaviour, you can provide - your own typemap to do this: - - %typemap(out) char [ANY] - %{ - RETVAL_STRINGL($1, $1_dim0, 1); - %} diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html old mode 100644 new mode 100755 index cc950db7c..8981f52b5 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -8,7 +8,7 @@ -

      17 SWIG and Allegro Common Lisp

      +

      16 SWIG and Allegro Common Lisp

        @@ -135,10 +135,10 @@ be unhappy to see some enterprising folk use this work to add to it.

        -

        17.1 Basics

        +

        16.1 Basics

        -

        17.1.1 Running Swig

        +

        16.1.1 Running Swig

        @@ -360,7 +360,7 @@ need to link in the Allegro shared library. The library you create from the C++ wrapper will be what you then load into Allegro CL.

        -

        17.1.2 Command Line Options

        +

        16.1.2 Command Line Options

        @@ -396,7 +396,7 @@ See Section 17.5 Identifier converter functions for more details.

        -

        17.1.3 Inserting user code into generated files

        +

        16.1.3 Inserting user code into generated files

        @@ -411,7 +411,7 @@ using the SWIG %insert(section) %{ ...code... %} directive:

         %module example
         
        -%{
        +%insert("runtime") %{
         #include "header.h"
         %}
         
        @@ -432,11 +432,11 @@ generated lisp interface file
         

      Note that the block %{ ... %} is effectively a shortcut for -%insert("header") %{ ... %}. +%insert("runtime") %{ ... %}.

      -

      17.2 Wrapping Overview

      +

      16.2 Wrapping Overview

      @@ -446,7 +446,7 @@ New users to SWIG are encouraged to read interested in generating an interface to C++.

      -

      17.2.1 Function Wrapping

      +

      16.2.1 Function Wrapping

      @@ -499,7 +499,7 @@ interested in generating an interface to C++.

      -

      17.2.2 Foreign Wrappers

      +

      16.2.2 Foreign Wrappers

      @@ -512,7 +512,7 @@ interested in generating an interface to C++. typemap.

      -

      17.2.3 FFI Wrappers

      +

      16.2.3 FFI Wrappers

      @@ -593,7 +593,7 @@ char *xxx(); ff:def-foreign-call's.

      -

      17.2.4 Non-overloaded Defuns

      +

      16.2.4 Non-overloaded Defuns

      @@ -606,7 +606,7 @@ char *xxx(); this function can be manipulated via the lout typemap.

      -

      17.2.5 Overloaded Defuns

      +

      16.2.5 Overloaded Defuns

      @@ -622,7 +622,7 @@ char *xxx(); can be manipulated via the lout typemap.

      -

      17.2.6 What about constant and variable access?

      +

      16.2.6 What about constant and variable access?

      @@ -635,7 +635,7 @@ char *xxx(); into the foreign module.

      -

      17.2.7 Object Wrapping

      +

      16.2.7 Object Wrapping

      @@ -657,7 +657,7 @@ char *xxx(); foreign function interface.

      -

      17.3 Wrapping Details

      +

      16.3 Wrapping Details

      @@ -665,7 +665,7 @@ char *xxx(); translated into lisp.

      -

      17.3.1 Namespaces

      +

      16.3.1 Namespaces

      @@ -742,7 +742,7 @@ namespace car { function such as (car '(1 2 3).

      -

      17.3.2 Constants

      +

      16.3.2 Constants

      @@ -803,7 +803,7 @@ namespace car { not use the -nocwrap command-line option.

      -

      17.3.3 Variables

      +

      16.3.3 Variables

      @@ -881,7 +881,7 @@ globalvar> (globalvar.nnn::glob_float)

  • -

    17.3.4 Enumerations

    +

    16.3.4 Enumerations

    @@ -957,7 +957,7 @@ EXPORT const int ACL_ENUM___FOO3__SWIG_0 = FOO3; -

    17.3.5 Arrays

    +

    16.3.5 Arrays

    @@ -1105,10 +1105,10 @@ namespace BAR { -

    17.3.6 Classes and Structs and Unions (oh my!)

    +

    16.3.6 Classes and Structs and Unions (oh my!)

    -

    17.3.6.1 CLOS wrapping of

    +

    16.3.6.1 CLOS wrapping of

    @@ -1123,7 +1123,7 @@ namespace BAR { integer values.

    -

    17.3.6.2 CLOS Inheritance

    +

    16.3.6.2 CLOS Inheritance

    @@ -1136,7 +1136,7 @@ namespace BAR { parameter.

    -

    17.3.6.3 Member fields and functions

    +

    16.3.6.3 Member fields and functions

    @@ -1152,7 +1152,7 @@ namespace BAR { the interface does nothing for friend directives,

    -

    17.3.6.4 Why not directly access C++ classes using foreign types?

    +

    16.3.6.4 Why not directly access C++ classes using foreign types?

    @@ -1170,11 +1170,11 @@ namespace BAR { use the more robust wrapper functions.

    -

    17.3.7 Templates

    +

    16.3.7 Templates

    -

    17.3.7.1 Generating wrapper code for templates

    +

    16.3.7.1 Generating wrapper code for templates

    @@ -1187,7 +1187,7 @@ namespace BAR { directive.

    -

    17.3.7.2 Implicit Template instantiation

    +

    16.3.7.2 Implicit Template instantiation

    @@ -1197,7 +1197,7 @@ namespace BAR { class schema.

    -

    17.3.8 Typedef, Templates, and Synonym Types

    +

    16.3.8 Typedef, Templates, and Synonym Types

    @@ -1277,7 +1277,7 @@ synonym> -

    17.3.8.1 Choosing a primary type

    +

    16.3.8.1 Choosing a primary type

    @@ -1298,7 +1298,7 @@ synonym> -

    17.3.9 Function overloading/Parameter defaulting

    +

    16.3.9 Function overloading/Parameter defaulting

    @@ -1461,7 +1461,7 @@ overload> -

    17.3.10 Operator wrapping and Operator overloading

    +

    16.3.10 Operator wrapping and Operator overloading

    @@ -1607,7 +1607,7 @@ opoverload> -

    17.3.11 Varargs

    +

    16.3.11 Varargs

    @@ -1628,7 +1628,7 @@ opoverload> with other ways such functions can be wrapped.

    -

    17.3.12 C++ Exceptions

    +

    16.3.12 C++ Exceptions

    @@ -1640,7 +1640,7 @@ opoverload> implemented.

    -

    17.3.13 Pass by value, pass by reference

    +

    16.3.13 Pass by value, pass by reference

    @@ -1652,7 +1652,7 @@ opoverload> newly defined types.

    -

    17.4 Typemaps

    +

    16.4 Typemaps

    @@ -1663,7 +1663,7 @@ opoverload> on Typemaps for more information.

    -

    17.4.1 Code Generation in the C++ Wrapper

    +

    16.4.1 Code Generation in the C++ Wrapper

    @@ -1693,7 +1693,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    17.4.1.1 IN Typemap

    +

    16.4.1.1 IN Typemap

    @@ -1728,7 +1728,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    17.4.1.2 OUT Typemap

    +

    16.4.1.2 OUT Typemap

    @@ -1752,7 +1752,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    17.4.1.3 CTYPE Typemap

    +

    16.4.1.3 CTYPE Typemap

    @@ -1784,7 +1784,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) these common typemaps here.

    -

    17.4.2 Code generation in Lisp wrappers

    +

    16.4.2 Code generation in Lisp wrappers

    @@ -1803,7 +1803,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) 16.3.1 Namespaces for details.

    -

    17.4.2.1 LIN Typemap

    +

    16.4.2.1 LIN Typemap

    @@ -1846,7 +1846,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    17.4.2.2 LOUT Typemap

    +

    16.4.2.2 LOUT Typemap

    @@ -1889,7 +1889,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    17.4.2.3 FFITYPE Typemap

    +

    16.4.2.3 FFITYPE Typemap

    @@ -1939,7 +1939,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    17.4.2.4 LISPTYPE Typemap

    +

    16.4.2.4 LISPTYPE Typemap

    @@ -1959,7 +1959,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    17.4.2.5 LISPCLASS Typemap

    +

    16.4.2.5 LISPCLASS Typemap

    @@ -1983,7 +1983,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    17.4.3 Modifying SWIG behavior using typemaps

    +

    16.4.3 Modifying SWIG behavior using typemaps

    @@ -2017,10 +2017,10 @@ return-val wrapper-name(parm0, parm1, ..., parmN) -

    17.5 Identifier Converter functions

    +

    16.5 Identifier Converter functions

    -

    17.5.1 Creating symbols in the lisp environment

    +

    16.5.1 Creating symbols in the lisp environment

    @@ -2041,11 +2041,11 @@ return-val wrapper-name(parm0, parm1, ..., parmN) of arguments.

    -

    17.5.2 Existing identifier-converter functions

    +

    16.5.2 Existing identifier-converter functions

    Two basic identifier routines have been defined. -

    17.5.2.1 identifier-convert-null

    +

    16.5.2.1 identifier-convert-null

    @@ -2054,7 +2054,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) strings, from which a symbol will be created.

    -

    17.5.2.2 identifier-convert-lispify

    +

    16.5.2.2 identifier-convert-lispify

    @@ -2063,7 +2063,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) same symbol transformations.

    -

    17.5.2.3 Default identifier to symbol conversions

    +

    16.5.2.3 Default identifier to symbol conversions

    @@ -2072,7 +2072,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN) default naming conventions.

    -

    17.5.3 Defining your own identifier-converter

    +

    16.5.3 Defining your own identifier-converter

    @@ -2128,7 +2128,7 @@ indicating the number of arguments passed to the routine indicated by this identifier.

    -

    17.5.4 Instructing SWIG to use a particular identifier-converter

    +

    16.5.4 Instructing SWIG to use a particular identifier-converter

    diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index 81c8a232b..97cb75409 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -5,18 +5,12 @@ -

    18 SWIG and C#

    +

    17 SWIG and C#

    • Introduction
    • Differences to the Java module -
    • C# Arrays -
    • C# Exceptions
      • C# exception example using "check" typemap @@ -45,7 +39,7 @@ -

        18.1 Introduction

        +

        17.1 Introduction

        @@ -65,7 +59,7 @@ The Microsoft Developer Network (MSDN) h Monodoc, available from the Mono project, has a very useful section titled Interop with native libraries.

        -

        18.2 Differences to the Java module

        +

        17.2 Differences to the Java module

        @@ -207,12 +201,7 @@ $jnicall -> $imcall

      • -Unlike the "javain" typemap, the "csin" typemap does not support the 'pgcpp' attribute as the C# module does not have a premature garbage collection prevention parameter. -The "csin" typemap supports additional optional attributes called 'cshin' and 'terminator'. -The 'cshin' attribute should contain the parameter type and name whenever a constructor helper function is generated due to the 'pre' or 'post' attributes. -The 'terminator' attribute normally just contains a closing brace for when the 'pre' attribute contains an opening brace, such as when a C# using or fixed block is started. -Note that 'pre', 'post', 'terminator' and 'cshin' attributes are not used for marshalling the property set. -Please see the Date marshalling example and Date marshalling of properties example for further understanding of these "csin" applicable attributes. +Unlike the "javain" typemap, the "csin" typemap does not support the 'pgcpp' attribute as the C# module does not have a premature garbage collection prevention parameter. The "csin" typemap supports an additional optional attribute called 'cshin'. It should contain the parameter type and name whenever a constructor helper function is generated due to the 'pre' or 'post' attributes. Note that 'pre', 'post' and 'cshin' attributes are not used for marshalling the property set. Please see the Date marshalling example and Date marshalling of properties example for further understanding.

      • @@ -408,275 +397,7 @@ Windows users can also get the examples working using a Cygwin or MinGW environment for automatic configuration of the example makefiles. Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path. -

        18.3 C# Arrays

        - - -

        -There are various ways to pass arrays from C# to C/C++. -The default wrapping treats arrays as pointers and as such simple type wrapper classes are generated, -eg SWIGTYPE_p_int when wrapping the C type int [] or int *. -This gives a rather restricted use of the underlying unmanaged code and the most practical way to use arrays is to enhance or customise -with one of the following three approaches; namely the SWIG C arrays library, P/Invoke default array marshalling or -pinned arrays. -

        - -

        18.3.1 The SWIG C arrays library

        - - -

        -The C arrays library keeps all the array memory in the unmanaged layer. -The library is available to all language modules and is documented in the carrays.i library section. -Please refer to this section for details, but for convenience, the C# usage for the two examples outlined there is shown below. -

        - -

        -For the %array_functions example, the equivalent usage would be: -

        - -
        -
        -SWIGTYPE_p_double a = example.new_doubleArray(10);  // Create an array
        -for (int i=0; i<10; i++)
        -  example.doubleArray_setitem(a,i,2*i);             // Set a value
        -example.print_array(a);                             // Pass to C
        -example.delete_doubleArray(a);                      // Destroy array
        -
        -
        - -

        -and for the %array_class example, the equivalent usage would be: -

        - -
        -
        -doubleArray c = new doubleArray(10);    // Create double[10]
        -for (int i=0; i<10; i++)
        -  c.setitem(i, 2*i);                    // Assign values
        -example.print_array(c.cast());          // Pass to C
        -
        -
        - - -

        18.3.2 Managed arrays using P/Invoke default array marshalling

        - - -

        -In the P/Invoke default marshalling scheme, one needs to designate whether the invoked function will treat a managed -array parameter as input, output, or both. When the function is invoked, the CLR allocates a separate chunk of memory as big as the given managed array, -which is automatically released at the end of the function call. If the array parameter is marked as being input, the content of the managed array is copied -into this buffer when the call is made. Correspondingly, if the array parameter is marked as being output, the contents of the reserved buffer are copied -back into the managed array after the call returns. A pointer to to this buffer -is passed to the native function. -

        - -

        -The reason for allocating a separate buffer is to leave the CLR free to relocate the managed array object -during garbage collection. If the overhead caused by the copying is causing a significant performance penalty, consider pinning the managed array and -passing a direct reference as described in the next section. -

        - -

        -For more information on the subject, see the -Default Marshaling for Arrays article -on MSDN. -

        - - -

        -The P/Invoke default marshalling is supported by the arrays_csharp.i library via the INPUT, OUTPUT and INOUT typemaps. -Let's look at some example usage. Consider the following C function: -

        -
        -
        -void myArrayCopy(int *sourceArray, int *targetArray, int nitems);
        -
        -
        - -

        -We can now instruct SWIG to use the default marshalling typemaps by -

        - -
        -
        -%include "arrays_csharp.i"
        -
        -%apply int INPUT[]  {int *sourceArray}
        -%apply int OUTPUT[] {int *targetArray}
        -
        -
        - -

        -As a result, we get the following method in the module class: -

        - -
        -
        -public static void myArrayCopy(int[] sourceArray, int[] targetArray, int nitems) {
        -    examplePINVOKE.myArrayCopy(sourceArray, targetArray, nitems);
        -}
        -
        -
        - -

        -If we look beneath the surface at the corresponding intermediary class code, we see -that SWIG has generated code that uses attributes -(from the System.Runtime.InteropServices namespace) to tell the CLR to use default -marshalling for the arrays: -

        - -
        -
        -[DllImport("example", EntryPoint="CSharp_myArrayCopy")]
        -public static extern void myArrayCopy([In, MarshalAs(UnmanagedType.LPArray)]int[] jarg1, 
        -                                      [Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
        -
        -
        - -

        -As an example of passing an inout array (i.e. the target function will both read from and -write to the array), consider this C function that swaps a given number of elements -in the given arrays: -

        - -
        -
        -void myArraySwap(int *array1, int *array2, int nitems);
        -
        -
        - -

        -Now, we can instruct SWIG to wrap this by -

        - -
        -
        -%include "arrays_csharp.i"
        -
        -%apply int INOUT[] {int *array1}
        -%apply int INOUT[] {int *array2}
        -
        -
        - -

        -This results in the module class method -

        - -
        -
        -  public static void myArraySwap(int[] array1, int[] array2, int nitems) {
        -    examplePINVOKE.myArraySwap(array1, array2, nitems);
        -  }
        -
        -
        - -

        -and intermediate class method -

        - -
        -
        -  [DllImport("example", EntryPoint="CSharp_myArraySwap")]
        -  public static extern void myArraySwap([In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg1, 
        -                                        [In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
        -
        -
        - - -

        18.3.3 Managed arrays using pinning

        - - -

        -It is also possible to pin a given array in memory (i.e. fix its location in memory), obtain a -direct pointer to it, and then pass this pointer to the wrapped C/C++ function. This approach -involves no copying, but it makes the work of the garbage collector harder as -the managed array object can not be relocated before the fix on the array is released. You should avoid -fixing arrays in memory in cases where the control may re-enter the managed side via a callback and/or -another thread may produce enough garbage to trigger garbage collection. -

        - -

        -For more information, see the fixed statement in the C# language reference. -

        - - -

        -Now let's look at an example using pinning, thus avoiding the CLR making copies -of the arrays passed as parameters. The arrays_csharp.i library file again provides the required support via the FIXED typemaps. -Let's use the same function from the previous section: -

        - -
        -
        -void myArrayCopy(int *sourceArray, int *targetArray, int nitems);
        -
        -
        - -

        -We now need to declare the module class method unsafe, as we are using pointers: -

        - -
        -
        -%csmethodmodifiers myArrayCopy "public unsafe";
        - 
        -
        - -

        -Apply the appropriate typemaps to the array parameters: -

        - -
        -
        -%include "arrays_csharp.i"
        -
        -%apply int FIXED[] {int *sourceArray}
        -%apply int FIXED[] {int *targetArray}
        -
        -
        - -

        -Notice that there is no need for separate in, out or inout typemaps as is the -case when using P/Invoke default marshalling. -

        - -

        -As a result, we get the following method in the module class: -

        - -
        -
        -  public unsafe static void myArrayCopy(int[] sourceArray, int[] targetArray, int nitems) {
        -    fixed ( int *swig_ptrTo_sourceArray = sourceArray ) {
        -    fixed ( int *swig_ptrTo_targetArray = targetArray ) {
        -    {
        -      examplePINVOKE.myArrayCopy((IntPtr)swig_ptrTo_sourceArray, (IntPtr)swig_ptrTo_targetArray, nitems);
        -    }
        -    }
        -    }
        -  }
        -
        -
        - -

        -On the method signature level the only difference to the version using P/Invoke default -marshalling is the "unsafe" quantifier, which is required because we are handling pointers. -

        - -

        -Also the intermediate class method looks a little different from the default marshalling -example - the method is expecting an IntPtr as the parameter type. -

        - -
        -
        -[DllImport("example", EntryPoint="CSharp_myArrayCopy")]
        -public static extern void myArrayCopy(IntPtr jarg1, IntPtr jarg2, int jarg3);
        -
        -
        - - - -

        18.4 C# Exceptions

        +

        17.3 C# Exceptions

        @@ -773,7 +494,7 @@ set so should only be used when a C# exception is not created.

        -

        18.4.1 C# exception example using "check" typemap

        +

        17.3.1 C# exception example using "check" typemap

        @@ -955,7 +676,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute Actually it will issue this warning for any function beginning with SWIG_CSharpSetPendingException.

        -

        18.4.2 C# exception example using %exception

        +

        17.3.2 C# exception example using %exception

        @@ -1020,7 +741,7 @@ The managed code generated does check for the pending exception as mentioned ear

    -

    18.4.3 C# exception example using exception specifications

    +

    17.3.3 C# exception example using exception specifications

    @@ -1077,7 +798,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) { Multiple catch handlers are generated should there be more than one exception specifications declared.

    -

    18.4.4 Custom C# ApplicationException example

    +

    17.3.4 Custom C# ApplicationException example

    @@ -1211,7 +932,7 @@ try { -

    18.5 C# Directors

    +

    17.4 C# Directors

    @@ -1224,7 +945,7 @@ The following sections provide information on the C# director implementation and However, the Java directors section should also be read in order to gain more insight into directors.

    -

    18.5.1 Directors example

    +

    17.4.1 Directors example

    @@ -1345,7 +1066,7 @@ CSharpDerived - UIntMethod(123) -

    18.5.2 Directors implementation

    +

    17.4.2 Directors implementation

    @@ -1531,7 +1252,7 @@ void SwigDirector_Base::BaseBoolMethod(Base const &b, bool flag) { -

    18.5.3 Director caveats

    +

    17.4.3 Director caveats

    @@ -1579,7 +1300,7 @@ However, a call from C# to CSharpDefaults.DefaultMethod() will of cours should pass the call on to CSharpDefaults.DefaultMethod(int)using the C++ default value, as shown above.

    -

    18.6 C# Typemap examples

    +

    17.5 C# Typemap examples

    This section includes a few examples of typemaps. For more examples, you @@ -1587,7 +1308,7 @@ might look at the files "csharp.swg" and "typemaps.i" in the SWIG library. -

    18.6.1 Memory management when returning references to member variables

    +

    17.5.1 Memory management when returning references to member variables

    @@ -1711,7 +1432,7 @@ public class Bike : IDisposable { Note the addReference call.

    -

    18.6.2 Memory management for objects passed to the C++ layer

    +

    17.5.2 Memory management for objects passed to the C++ layer

    @@ -1830,7 +1551,7 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class. -

    18.6.3 Date marshalling using the csin typemap and associated attributes

    +

    17.5.3 Date marshalling using the csin typemap and associated attributes

    @@ -1846,7 +1567,6 @@ Let's assume the code being wrapped is as follows:

     class CDate {
     public:
    -  CDate();
       CDate(int year, int month, int day);
       int getYear();
       int getMonth();
    @@ -1929,8 +1649,8 @@ The typemaps to achieve this are shown below.
     
     %typemap(cstype) const CDate& "System.DateTime"
     %typemap(csin, 
    -         pre="    CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
    -        ) const CDate &
    +         pre="    CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);")
    +         const CDate &
              "$csclassname.getCPtr(temp$csinput)"
     
     %typemap(cstype) CDate& "out System.DateTime"
    @@ -1938,8 +1658,7 @@ The typemaps to achieve this are shown below.
              pre="    CDate temp$csinput = new CDate();", 
              post="      $csinput = new System.DateTime(temp$csinput.getYear(),"
                   " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", 
    -         cshin="out $csinput"
    -        ) CDate &
    +         cshin="out $csinput") CDate &
              "$csclassname.getCPtr(temp$csinput)"
     
     
    @@ -2044,8 +1763,7 @@ will be possible with the following CDate * typemaps pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);", post=" $csinput = new System.DateTime(temp$csinput.getYear()," " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", - cshin="ref $csinput" - ) CDate * + cshin="ref $csinput") CDate * "$csclassname.getCPtr(temp$csinput)"
    @@ -2070,51 +1788,7 @@ public class example { -

    -The following typemap is the same as the previous but demonstrates how a using block can be used for the temporary variable. -The only change to the previous typemap is the introduction of the 'terminator' attribute to terminate the using block. -The subtractYears method is nearly identical to the above addYears method. -

    - -
    -
    -%typemap(csin,
    -         pre="    using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
    -         post="      $csinput = new System.DateTime(temp$csinput.getYear(),"
    -              " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", 
    -         terminator="    } // terminate temp$csinput using block",
    -         cshin="ref $csinput"
    -        ) CDate *
    -         "$csclassname.getCPtr(temp$csinput)"
    -
    -void subtractYears(CDate *pDate, int years) {
    -  *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
    -}
    -
    -
    - -

    -The resulting generated code shows the termination of the using block: -

    - -
    -
    -public class example {
    -  public static void subtractYears(ref System.DateTime pDate, int years) {
    -    using (CDate temppDate = new CDate(pDate.Year, pDate.Month, pDate.Day)) {
    -    try {
    -      examplePINVOKE.subtractYears(CDate.getCPtr(temppDate), years);
    -    } finally {
    -      pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
    -    }
    -    } // terminate temppDate using block
    -  }
    -  ...
    -}
    -
    -
    - -

    18.6.4 A date example demonstrating marshalling of C# properties

    +

    17.5.4 A date example demonstrating marshalling of C# properties

    @@ -2153,8 +1827,7 @@ The typemap type required is thus CDate *. Given that the previous sect pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);", post=" $csinput = new System.DateTime(temp$csinput.getYear()," " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", - cshin="ref $csinput" - ) CDate * + cshin="ref $csinput") CDate * "$csclassname.getCPtr(temp$csinput)" %typemap(csvarin, excode=SWIGEXCODE2) CDate * %{ @@ -2215,7 +1888,7 @@ Some points to note: -

    18.6.5 Turning wrapped classes into partial classes

    +

    17.5.5 Turning wrapped classes into partial classes

    @@ -2315,7 +1988,7 @@ demonstrating that the class contains methods calling both unmanaged code - The following example is an alternative approach to adding managed code to the generated proxy class.

    -

    18.6.6 Extending proxy classes with additional C# code

    +

    17.5.6 Extending proxy classes with additional C# code

    diff --git a/Doc/Manual/Chicken.html b/Doc/Manual/Chicken.html index 98372a0f7..bd1b3d94b 100644 --- a/Doc/Manual/Chicken.html +++ b/Doc/Manual/Chicken.html @@ -8,7 +8,7 @@ -

    19 SWIG and Chicken

    +

    18 SWIG and Chicken

      @@ -72,7 +72,7 @@

      -

      19.1 Preliminaries

      +

      18.1 Preliminaries

      @@ -90,7 +90,7 @@ CHICKEN.

      -

      19.1.1 Running SWIG in C mode

      +

      18.1.1 Running SWIG in C mode

      @@ -123,7 +123,7 @@ object files and linked into your project.

      -

      19.1.2 Running SWIG in C++ mode

      +

      18.1.2 Running SWIG in C++ mode

      @@ -152,10 +152,10 @@ object files and linked into your project.

      -

      19.2 Code Generation

      +

      18.2 Code Generation

      -

      19.2.1 Naming Conventions

      +

      18.2.1 Naming Conventions

      @@ -171,7 +171,7 @@ %rename SWIG directive in the SWIG interface file.

      -

      19.2.2 Modules

      +

      18.2.2 Modules

      @@ -193,7 +193,7 @@ (uses modulename)) CHICKEN Scheme form.

      -

      19.2.3 Constants and Variables

      +

      18.2.3 Constants and Variables

      @@ -230,7 +230,7 @@ for info on how to apply the %feature.

      -

      19.2.4 Functions

      +

      18.2.4 Functions

      @@ -249,7 +249,7 @@ parameters). The return values can then be accessed with (call-with-values).

      -

      19.2.5 Exceptions

      +

      18.2.5 Exceptions

      The SWIG chicken module has support for exceptions thrown from @@ -291,7 +291,7 @@

    -

    19.3 TinyCLOS

    +

    18.3 TinyCLOS

    @@ -334,7 +334,7 @@

    -

    19.4 Linkage

    +

    18.4 Linkage

    @@ -355,7 +355,7 @@

    -

    19.4.1 Static binary or shared library linked at compile time

    +

    18.4.1 Static binary or shared library linked at compile time

    We can easily use csc to build a static binary.

    @@ -396,7 +396,7 @@ in which case the test script does not need to be linked with example.so. The t be run with csi.

    -

    19.4.2 Building chicken extension libraries

    +

    18.4.2 Building chicken extension libraries

    Building a shared library like in the above section only works if the library @@ -454,7 +454,7 @@ distributed and used by anyone, even if SWIG is not installed.

    See the Examples/chicken/egg directory in the SWIG source for an example that builds two eggs, one using the first method and one using the second method.

    -

    19.4.3 Linking multiple SWIG modules with TinyCLOS

    +

    18.4.3 Linking multiple SWIG modules with TinyCLOS

    Linking together multiple modules that share type information using the %import @@ -478,7 +478,7 @@ with (declare (uses ...)). To create an extension library or an egg, just create a module_load.scm file that (declare (uses ...)) all the modules.

    -

    19.5 Typemaps

    +

    18.5 Typemaps

    @@ -487,7 +487,7 @@ all the modules.

    Lib/chicken/chicken.swg.

    -

    19.6 Pointers

    +

    18.6 Pointers

    @@ -520,7 +520,7 @@ all the modules.

    type. flags is either zero or SWIG_POINTER_DISOWN (see below).

    -

    19.6.1 Garbage collection

    +

    18.6.1 Garbage collection

    If the owner flag passed to SWIG_NewPointerObj is 1, NewPointerObj will add a @@ -551,7 +551,7 @@ all the modules.

    must be called manually.

    -

    19.7 Unsupported features and known problems

    +

    18.7 Unsupported features and known problems

    -

    19.7.1 TinyCLOS problems with Chicken version <= 1.92

    +

    18.7.1 TinyCLOS problems with Chicken version <= 1.92

    In Chicken versions equal to or below 1.92, TinyCLOS has a limitation such that generic methods do not properly work on methods diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index c135b7c6f..c3197b9dc 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -162,7 +162,7 @@

  • Character strings and structures
  • Array members
  • Structure data members -
  • C constructors and destructors +
  • C constructors and destructors
  • Adding member functions to C structures
  • Nested structures
  • Other things to note about structure wrapping @@ -272,7 +272,7 @@
  • C Arrays and Pointers @@ -390,7 +390,6 @@
  • More about %apply and %clear
  • Reducing wrapper code size
  • Passing data between typemaps -
  • C++ "this" pointer
  • Where to go for more information? @@ -498,33 +497,7 @@ -

    16 Using SWIG with ccache - ccache-swig(1) manpage

    - - - - - -

    17 SWIG and Allegro Common Lisp

    +

    16 SWIG and Allegro Common Lisp

    @@ -608,19 +581,13 @@
    -

    18 SWIG and C#

    +

    17 SWIG and C#

    -

    19 SWIG and Chicken

    +

    18 SWIG and Chicken

    @@ -685,7 +652,7 @@
    -

    20 SWIG and Guile

    +

    19 SWIG and Guile

    @@ -720,7 +687,7 @@
    -

    21 SWIG and Java

    +

    20 SWIG and Java

    @@ -862,7 +829,7 @@
    -

    22 SWIG and Common Lisp

    +

    21 SWIG and Common Lisp

    @@ -885,7 +852,7 @@
    -

    23 SWIG and Lua

    +

    22 SWIG and Lua

    @@ -914,35 +881,20 @@
  • C++ templates
  • C++ Smart Pointers
  • C++ Exceptions +
  • Writing your own custom wrappers +
  • Adding additional Lua code -
  • Typemaps +
  • Details on the Lua binding -
  • Writing typemaps - -
  • Customization of your Bindings - -
  • Details on the Lua binding - -

    24 SWIG and Modula-3

    +

    23 SWIG and Modula-3

    @@ -983,7 +935,7 @@
    -

    25 SWIG and MzScheme

    +

    24 SWIG and MzScheme

    @@ -993,7 +945,7 @@
    -

    26 SWIG and Ocaml

    +

    25 SWIG and Ocaml

    @@ -1044,7 +996,7 @@
    -

    27 SWIG and Octave

    +

    26 SWIG and Octave

    @@ -1079,7 +1031,7 @@
    -

    28 SWIG and Perl5

    +

    27 SWIG and Perl5

    @@ -1146,7 +1098,7 @@
    -

    29 SWIG and PHP

    +

    28 SWIG and PHP

    @@ -1154,6 +1106,7 @@
  • Generating PHP Extensions
  • Basic PHP interface @@ -1176,7 +1129,7 @@ -

    30 SWIG and Pike

    +

    29 SWIG and Pike

    @@ -1200,7 +1153,7 @@
    -

    31 SWIG and Python

    +

    30 SWIG and Python

    @@ -1241,7 +1194,7 @@
  • Memory management
  • Python 2.2 and classic classes -
  • Cross language polymorphism +
  • Cross language polymorphism
  • Python Packages -
  • Python 3 Support - -

    32 SWIG and Ruby

    +

    31 SWIG and Ruby

    @@ -1440,7 +1387,7 @@
    -

    33 SWIG and Tcl

    +

    32 SWIG and Tcl

    @@ -1505,7 +1452,7 @@
    -

    34 SWIG and R

    +

    33 SWIG and R

    @@ -1521,7 +1468,7 @@
    -

    35 Extending SWIG to support new languages

    +

    34 Extending SWIG to support new languages

    diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html index ec73e5460..e9d70e39a 100644 --- a/Doc/Manual/Customization.html +++ b/Doc/Manual/Customization.html @@ -1019,20 +1019,6 @@ but this will:
    -

    -SWIG provides macros for disabling and clearing features. Many of these can be found in the swig.swg library file. -The typical pattern is to define three macros; one to define the feature itself, one to disable the feature and one to clear the feature. -The three macros below show this for the "except" feature: -

    - -
    -
    -#define %exception      %feature("except")
    -#define %noexception    %feature("except","0")
    -#define %clearexception %feature("except","")
    -
    -
    -

    11.3.4 Features and default arguments

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index 73f1a6673..588912b68 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -6,7 +6,7 @@ -

    35 Extending SWIG to support new languages

    +

    34 Extending SWIG to support new languages

      @@ -73,7 +73,7 @@ -

      35.1 Introduction

      +

      34.1 Introduction

      @@ -89,7 +89,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po you should probably look at one of SWIG's existing modules.

      -

      35.2 Prerequisites

      +

      34.2 Prerequisites

      @@ -119,7 +119,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of wrapper code are driven by C++ datatypes.

      -

      35.3 The Big Picture

      +

      34.3 The Big Picture

      @@ -156,7 +156,7 @@ role in making the system work. For example, both typemaps and declaration anno based on pattern matching and interact heavily with the underlying type system.

      -

      35.4 Execution Model

      +

      34.4 Execution Model

      @@ -201,7 +201,7 @@ latter stage of compilation. The next few sections briefly describe some of these stages.

      -

      35.4.1 Preprocessing

      +

      34.4.1 Preprocessing

      @@ -232,11 +232,10 @@ of swig.swg looks like this: ... /* Code insertion directives such as %wrapper %{ ... %} */ -#define %begin %insert("begin") -#define %runtime %insert("runtime") -#define %header %insert("header") -#define %wrapper %insert("wrapper") #define %init %insert("init") +#define %wrapper %insert("wrapper") +#define %header %insert("header") +#define %runtime %insert("runtime") /* Access control directives */ @@ -282,7 +281,7 @@ been expanded as well as everything else that goes into the low-level construction of the wrapper code.

      -

      35.4.2 Parsing

      +

      34.4.2 Parsing

      @@ -383,7 +382,7 @@ returning a foo and taking types a and b as arguments).

      -

      35.4.3 Parse Trees

      +

      34.4.3 Parse Trees

      @@ -449,8 +448,7 @@ of the output.

      The contents of each parse tree node consist of a collection of attribute/value pairs. Internally, the nodes are simply represented by hash tables. A display of -the entire parse-tree structure can be obtained using swig -debug-top <n>, where n is -the stage being processed. +the entire parse-tree structure can be obtained using swig -dump_tree. There are a number of other parse tree display options, for example, swig -debug-module <n> will avoid displaying system parse information and only display the parse tree pertaining to the user's module at stage n of processing. @@ -638,7 +636,7 @@ $ swig -c++ -python -debug-module 4 example.i

    -

    35.4.4 Attribute namespaces

    +

    34.4.4 Attribute namespaces

    @@ -657,7 +655,7 @@ that matches the name of the target language. For example, python:foo perl:foo.

    -

    35.4.5 Symbol Tables

    +

    34.4.5 Symbol Tables

    @@ -748,7 +746,7 @@ example.i:5. Previous declaration is foo_i(int ) -

    35.4.6 The %feature directive

    +

    34.4.6 The %feature directive

    @@ -804,7 +802,7 @@ For example, the exception code above is simply stored without any modifications.

    -

    35.4.7 Code Generation

    +

    34.4.7 Code Generation

    @@ -926,7 +924,7 @@ public : The role of these functions is described shortly.

    -

    35.4.8 SWIG and XML

    +

    34.4.8 SWIG and XML

    @@ -939,7 +937,7 @@ internal data structures, it may be useful to keep XML in the back of your mind as a model.

    -

    35.5 Primitive Data Structures

    +

    34.5 Primitive Data Structures

    @@ -985,7 +983,7 @@ typedef Hash Typetab; -

    35.5.1 Strings

    +

    34.5.1 Strings

    @@ -1126,7 +1124,7 @@ Returns the number of replacements made (if any). -

    35.5.2 Hashes

    +

    34.5.2 Hashes

    @@ -1203,7 +1201,7 @@ Returns the list of hash table keys. -

    35.5.3 Lists

    +

    34.5.3 Lists

    @@ -1292,7 +1290,7 @@ If t is not a standard object, it is assumed to be a char * and is used to create a String object. -

    35.5.4 Common operations

    +

    34.5.4 Common operations

    The following operations are applicable to all datatypes. @@ -1347,7 +1345,7 @@ objects and report errors. Gets the line number associated with x. -

    35.5.5 Iterating over Lists and Hashes

    +

    34.5.5 Iterating over Lists and Hashes

    To iterate over the elements of a list or a hash table, the following functions are used: @@ -1392,7 +1390,7 @@ for (j = First(j); j.item; j= Next(j)) { -

    35.5.6 I/O

    +

    34.5.6 I/O

    Special I/O functions are used for all internal I/O. These operations @@ -1528,7 +1526,7 @@ Similarly, the preprocessor and parser all operate on string-files. -

    35.6 Navigating and manipulating parse trees

    +

    34.6 Navigating and manipulating parse trees

    Parse trees are built as collections of hash tables. Each node is a hash table in which @@ -1662,7 +1660,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u the parent so that sibling nodes are unaffected. -

    35.7 Working with attributes

    +

    34.7 Working with attributes

    @@ -1779,7 +1777,7 @@ the attribute is optional. Swig_restore() must always be called after function. -

    35.8 Type system

    +

    34.8 Type system

    @@ -1788,7 +1786,7 @@ pointers, references, and pointers to members. A detailed discussion of type theory is impossible here. However, let's cover the highlights.

    -

    35.8.1 String encoding of types

    +

    34.8.1 String encoding of types

    @@ -1889,7 +1887,7 @@ make the final type, the two parts are just joined together using string concatenation.

    -

    35.8.2 Type construction

    +

    34.8.2 Type construction

    @@ -2058,7 +2056,7 @@ Returns the prefix of a type. For example, if ty is ty is unmodified. -

    35.8.3 Type tests

    +

    34.8.3 Type tests

    @@ -2145,7 +2143,7 @@ Checks if ty is a varargs type. Checks if ty is a templatized type. -

    35.8.4 Typedef and inheritance

    +

    34.8.4 Typedef and inheritance

    @@ -2247,7 +2245,7 @@ Fully reduces ty according to typedef rules. Resulting datatype will consist only of primitive typenames. -

    35.8.5 Lvalues

    +

    34.8.5 Lvalues

    @@ -2284,7 +2282,7 @@ Literal y; // type = 'Literal', ltype='p.char' -

    35.8.6 Output functions

    +

    34.8.6 Output functions

    @@ -2346,7 +2344,7 @@ SWIG, but is most commonly associated with type-descriptor objects that appear in wrappers (e.g., SWIGTYPE_p_double). -

    35.9 Parameters

    +

    34.9 Parameters

    @@ -2445,7 +2443,7 @@ included. Used to emit prototypes. Returns the number of required (non-optional) arguments in p. -

    35.10 Writing a Language Module

    +

    34.10 Writing a Language Module

    @@ -2460,7 +2458,7 @@ describes the creation of a minimal Python module. You should be able to extra this to other languages.

    -

    35.10.1 Execution model

    +

    34.10.1 Execution model

    @@ -2470,7 +2468,7 @@ the parsing of command line options, all aspects of code generation are controll different methods of the Language that must be defined by your module.

    -

    35.10.2 Starting out

    +

    34.10.2 Starting out

    @@ -2578,7 +2576,7 @@ that activates your module. For example, swig -python foo.i. The messages from your new module should appear.

    -

    35.10.3 Command line options

    +

    34.10.3 Command line options

    @@ -2637,7 +2635,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit unrecognized command line option error.

    -

    35.10.4 Configuration and preprocessing

    +

    34.10.4 Configuration and preprocessing

    @@ -2686,7 +2684,7 @@ an implementation file python.cxx and a configuration file python.swg.

    -

    35.10.5 Entry point to code generation

    +

    34.10.5 Entry point to code generation

    @@ -2744,7 +2742,7 @@ int Python::top(Node *n) { -

    35.10.6 Module I/O and wrapper skeleton

    +

    34.10.6 Module I/O and wrapper skeleton

    @@ -2886,7 +2884,7 @@ functionWrapper : void Shape_y_set(Shape *self,double y) -

    35.10.7 Low-level code generators

    +

    34.10.7 Low-level code generators

    @@ -3040,7 +3038,7 @@ but without the typemaps, there is still work to do.

    -

    35.10.8 Configuration files

    +

    34.10.8 Configuration files

    @@ -3115,7 +3113,7 @@ entirely upcased.

    At the end of the new section is the place to put the aforementioned -nickname kludges (should they be needed). See Perl5 for +nickname kludges (should they be needed). See Perl5 and Php4 for examples of what to do. [If this is still unclear after you've read the code, ping me and I'll expand on this further. --ttn]

    @@ -3190,7 +3188,7 @@ politely displays the ignoring language message. -

    35.10.9 Runtime support

    +

    34.10.9 Runtime support

    @@ -3199,7 +3197,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g. the SWIG files that implement those functions.

    -

    35.10.10 Standard library files

    +

    34.10.10 Standard library files

    @@ -3218,7 +3216,7 @@ The following are the minimum that are usually supported: Please copy these and modify for any new language.

    -

    35.10.11 Examples and test cases

    +

    34.10.11 Examples and test cases

    @@ -3247,7 +3245,7 @@ during this process, see the section on configuration files.

    -

    35.10.12 Documentation

    +

    34.10.12 Documentation

    @@ -3279,7 +3277,7 @@ Some topics that you'll want to be sure to address include: if available. -

    35.10.13 Prerequisites for adding a new language module to the SWIG distribution

    +

    34.10.13 Prerequisites for adding a new language module to the SWIG distribution

    @@ -3336,7 +3334,7 @@ should be added should there be an area not already covered by the existing tests.

    -

    35.10.14 Coding style guidelines

    +

    34.10.14 Coding style guidelines

    @@ -3360,13 +3358,13 @@ The generated C/C++ code should also follow this style as close as possible. How should be avoided as unlike the SWIG developers, users will never have consistent tab settings.

    -

    35.11 Typemaps

    +

    34.11 Typemaps

    -

    35.11.1 Proxy classes

    +

    34.11.1 Proxy classes

    -

    35.12 Guide to parse tree nodes

    +

    34.12 Guide to parse tree nodes

    diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index cf7e8da2c..20ab716e4 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -8,7 +8,7 @@ -

    20 SWIG and Guile

    +

    19 SWIG and Guile

      @@ -47,7 +47,7 @@

      This section details guile-specific support in SWIG. -

      20.1 Meaning of "Module"

      +

      19.1 Meaning of "Module"

      @@ -55,7 +55,7 @@ There are three different concepts of "module" involved, defined separately for SWIG, Guile, and Libtool. To avoid horrible confusion, we explicitly prefix the context, e.g., "guile-module". -

      20.2 Using the SCM or GH Guile API

      +

      19.2 Using the SCM or GH Guile API

      The guile module can currently export wrapper files that use the guile GH interface or the @@ -103,7 +103,7 @@ for the specific API. Currently only the guile language module has created a ma but there is no reason other languages (like mzscheme or chicken) couldn't also use this. If that happens, there is A LOT less code duplication in the standard typemaps.

      -

      20.3 Linkage

      +

      19.3 Linkage

      @@ -111,7 +111,7 @@ Guile support is complicated by a lack of user community cohesiveness, which manifests in multiple shared-library usage conventions. A set of policies implementing a usage convention is called a linkage. -

      20.3.1 Simple Linkage

      +

      19.3.1 Simple Linkage

      @@ -206,7 +206,7 @@ placed between the define-module form and the SWIG_init via a preprocessor define to avoid symbol clashes. For this case, however, passive linkage is available. -

      20.3.2 Passive Linkage

      +

      19.3.2 Passive Linkage

      Passive linkage is just like simple linkage, but it generates an @@ -216,7 +216,7 @@ package name (see below).

      You should use passive linkage rather than simple linkage when you are using multiple modules. -

      20.3.3 Native Guile Module Linkage

      +

      19.3.3 Native Guile Module Linkage

      SWIG can also generate wrapper code that does all the Guile module @@ -257,7 +257,7 @@ Newer Guile versions have a shorthand procedure for this:

    -

    20.3.4 Old Auto-Loading Guile Module Linkage

    +

    19.3.4 Old Auto-Loading Guile Module Linkage

    Guile used to support an autoloading facility for object-code @@ -283,7 +283,7 @@ option, SWIG generates an exported module initialization function with an appropriate name. -

    20.3.5 Hobbit4D Linkage

    +

    19.3.5 Hobbit4D Linkage

    @@ -308,7 +308,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very experimental; the (hobbit4d link) conventions are not well understood.

    -

    20.4 Underscore Folding

    +

    19.4 Underscore Folding

    @@ -320,7 +320,7 @@ complained so far. %rename to specify the Guile name of the wrapped functions and variables (see CHANGES). -

    20.5 Typemaps

    +

    19.5 Typemaps

    @@ -412,7 +412,7 @@ constant will appear as a scheme variable. See Features and the %feature directive for info on how to apply the %feature.

    -

    20.6 Representation of pointers as smobs

    +

    19.6 Representation of pointers as smobs

    @@ -433,7 +433,7 @@ representing the expected pointer type. See also If the Scheme object passed was not a SWIG smob representing a compatible pointer, a wrong-type-arg exception is raised. -

    20.6.1 GH Smobs

    +

    19.6.1 GH Smobs

    @@ -462,7 +462,7 @@ that created them, so the first module we check will most likely be correct. Once we have a swig_type_info structure, we loop through the linked list of casts, using pointer comparisons.

    -

    20.6.2 SCM Smobs

    +

    19.6.2 SCM Smobs

    The SCM interface (using the "-scm" argument to swig) uses swigrun.swg. @@ -477,7 +477,7 @@ in the smob tag. If a generated GOOPS module has been loaded, smobs will be wra GOOPS class.

    -

    20.6.3 Garbage Collection

    +

    19.6.3 Garbage Collection

    Garbage collection is a feature of the new SCM interface, and it is automatically included @@ -491,7 +491,7 @@ is exactly like described in Object ownership and %newobject in the SWIG manual. All typemaps use an $owner var, and the guile module replaces $owner with 0 or 1 depending on feature:new.

    -

    20.7 Exception Handling

    +

    19.7 Exception Handling

    @@ -517,7 +517,7 @@ mapping: The default when not specified here is to use "swig-error". See Lib/exception.i for details. -

    20.8 Procedure documentation

    +

    19.8 Procedure documentation

    If invoked with the command-line option -procdoc @@ -553,7 +553,7 @@ like this: typemap argument doc. See Lib/guile/typemaps.i for details. -

    20.9 Procedures with setters

    +

    19.9 Procedures with setters

    For global variables, SWIG creates a single wrapper procedure @@ -581,7 +581,7 @@ struct members, the procedures (struct-member-get pointer) and (struct-member-set pointer value) are not generated. -

    20.10 GOOPS Proxy Classes

    +

    19.10 GOOPS Proxy Classes

    SWIG can also generate classes and generic functions for use with @@ -730,7 +730,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th %import "foo.h" before the %inline block.

    -

    20.10.1 Naming Issues

    +

    19.10.1 Naming Issues

    As you can see in the example above, there are potential naming conflicts. The default exported @@ -769,7 +769,7 @@ guile-modules. For example,

    TODO: Renaming class name prefixes?

    -

    20.10.2 Linking

    +

    19.10.2 Linking

    The guile-modules generated above all need to be linked together. GOOPS support requires diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html index 099454cf0..491204d1d 100644 --- a/Doc/Manual/Introduction.html +++ b/Doc/Manual/Introduction.html @@ -414,8 +414,7 @@ SWIG_LINK_LIBRARIES(example ${PYTHON_LIBRARIES})

    The above example will generate native build files such as makefiles, nmake files and Visual Studio projects -which will invoke SWIG and compile the generated C++ files into _example.so (UNIX) or _example.pyd (Windows). -For other target languages on Windows a dll, instead of a .pyd file, is usually generated. +which will invoke SWIG and compile the generated C++ files into _example.so (UNIX) or _example.dll (Windows).

    2.7 Hands off code generation

    diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index c5ff1f906..164fc21e7 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -5,7 +5,7 @@ -

    21 SWIG and Java

    +

    20 SWIG and Java

      @@ -154,7 +154,7 @@ It covers most SWIG features, but certain low-level details are covered in less

      -

      21.1 Overview

      +

      20.1 Overview

      @@ -189,7 +189,7 @@ Various customisation tips and techniques using SWIG directives are covered. The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.

      -

      21.2 Preliminaries

      +

      20.2 Preliminaries

      @@ -205,7 +205,7 @@ Run make -k check from the SWIG root directory after installing SWIG on The Java module requires your system to support shared libraries and dynamic loading. This is the commonly used method to load JNI code so your system will more than likely support this.

      -

      21.2.1 Running SWIG

      +

      20.2.1 Running SWIG

      @@ -258,7 +258,7 @@ The following sections have further practical examples and details on how you mi compiling and using the generated files.

      -

      21.2.2 Additional Commandline Options

      +

      20.2.2 Additional Commandline Options

      @@ -295,7 +295,7 @@ swig -java -help Their use will become clearer by the time you have finished reading this section on SWIG and Java.

      -

      21.2.3 Getting the right header files

      +

      20.2.3 Getting the right header files

      @@ -310,7 +310,7 @@ They are usually in directories like this:

      The exact location may vary on your machine, but the above locations are typical.

      -

      21.2.4 Compiling a dynamic module

      +

      20.2.4 Compiling a dynamic module

      @@ -346,16 +346,16 @@ The name of the shared library output file is important. If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information). The name of the module is specified using the %module directive or -module command line option.

      -

      21.2.5 Using your module

      +

      20.2.5 Using your module

      To load your shared native library module in Java, simply use Java's System.loadLibrary method in a Java class:

      -// runme.java
      +// main.java
       
      -public class runme {
      +public class main {
         static {
           System.loadLibrary("example");
         }
      @@ -372,7 +372,7 @@ Compile all the Java files and run:
       
       
       $ javac *.java
      -$ java runme
      +$ java main
       24
       $
       
      @@ -381,7 +381,7 @@ $ If it doesn't work have a look at the following section which discusses problems loading the shared library.

      -

      21.2.6 Dynamic linking problems

      +

      20.2.6 Dynamic linking problems

      @@ -394,12 +394,12 @@ You may get an exception similar to this:

      -$ java runme
      +$ java main
       Exception in thread "main" java.lang.UnsatisfiedLinkError: no example in java.library.path
               at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1312)
               at java.lang.Runtime.loadLibrary0(Runtime.java:749)
               at java.lang.System.loadLibrary(System.java:820)
      -        at runme.<clinit>(runme.java:5)
      +        at main.<clinit>(main.java:5)
       

      @@ -426,7 +426,7 @@ The following exception is indicative of this:

      -$ java runme
      +$ java main
       Exception in thread "main" java.lang.UnsatisfiedLinkError: libexample.so: undefined
       symbol: fact
               at java.lang.ClassLoader$NativeLibrary.load(Native Method)
      @@ -434,7 +434,7 @@ symbol: fact
               at java.lang.ClassLoader.loadLibrary(ClassLoader.java, Compiled Code)
               at java.lang.Runtime.loadLibrary0(Runtime.java, Compiled Code)
               at java.lang.System.loadLibrary(System.java, Compiled Code)
      -        at runme.<clinit>(runme.java:5)
      +        at main.<clinit>(main.java:5)
       $
       
      @@ -455,7 +455,7 @@ The following section also contains some C++ specific linking problems and solut

      -

      21.2.7 Compilation problems and compiling with C++

      +

      20.2.7 Compilation problems and compiling with C++

      @@ -508,7 +508,7 @@ Finally make sure the version of JDK header files matches the version of Java th

      -

      21.2.8 Building on Windows

      +

      20.2.8 Building on Windows

      @@ -517,7 +517,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine. This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers. In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.

      -

      21.2.8.1 Running SWIG from Visual Studio

      +

      20.2.8.1 Running SWIG from Visual Studio

      @@ -556,7 +556,7 @@ To run the native code in the DLL (example.dll), make sure that it is in your pa If the library fails to load have a look at Dynamic linking problems.

      -

      21.2.8.2 Using NMAKE

      +

      20.2.8.2 Using NMAKE

      @@ -615,7 +615,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -

      -

      21.3 A tour of basic C/C++ wrapping

      +

      20.3 A tour of basic C/C++ wrapping

      @@ -625,7 +625,7 @@ variables are wrapped with JavaBean type getters and setters and so forth. This section briefly covers the essential aspects of this wrapping.

      -

      21.3.1 Modules, packages and generated Java classes

      +

      20.3.1 Modules, packages and generated Java classes

      @@ -659,7 +659,7 @@ swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i SWIG won't create the directory, so make sure it exists beforehand. -

      21.3.2 Functions

      +

      20.3.2 Functions

      @@ -693,7 +693,7 @@ System.out.println(example.fact(4));

      -

      21.3.3 Global variables

      +

      20.3.3 Global variables

      @@ -780,7 +780,7 @@ extern char *path; // Read-only (due to %immutable)

    -

    21.3.4 Constants

    +

    20.3.4 Constants

    @@ -920,7 +920,7 @@ Or if you decide this practice isn't so bad and your own class implements ex

    -

    21.3.5 Enumerations

    +

    20.3.5 Enumerations

    @@ -934,7 +934,7 @@ The final two approaches use simple integers for each enum item. Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.

    -

    21.3.5.1 Anonymous enums

    +

    20.3.5.1 Anonymous enums

    @@ -997,7 +997,7 @@ As in the case of constants, you can access them through either the module class

    -

    21.3.5.2 Typesafe enums

    +

    20.3.5.2 Typesafe enums

    @@ -1090,7 +1090,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit The following section details proper Java enum generation.

    -

    21.3.5.3 Proper Java enums

    +

    20.3.5.3 Proper Java enums

    @@ -1143,7 +1143,7 @@ The additional support methods need not be generated if none of the enum items h Simpler Java enums for enums without initializers section.

    -

    21.3.5.4 Type unsafe enums

    +

    20.3.5.4 Type unsafe enums

    @@ -1191,7 +1191,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.

    -

    21.3.5.5 Simple enums

    +

    20.3.5.5 Simple enums

    @@ -1210,7 +1210,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach. The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.

    -

    21.3.6 Pointers

    +

    20.3.6 Pointers

    @@ -1298,7 +1298,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return a NULL pointer if the conversion can't be performed.

    -

    21.3.7 Structures

    +

    20.3.7 Structures

    @@ -1466,7 +1466,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a -

    21.3.8 C++ classes

    +

    20.3.8 C++ classes

    @@ -1529,7 +1529,7 @@ int bar = Spam.getBar(); -

    21.3.9 C++ inheritance

    +

    20.3.9 C++ inheritance

    @@ -1590,7 +1590,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance A warning is given when multiple inheritance is detected and only the first base class is used.

    -

    21.3.10 Pointers, references, arrays and pass by value

    +

    20.3.10 Pointers, references, arrays and pass by value

    @@ -1645,7 +1645,7 @@ to hold the result and a pointer is returned (Java will release this memory when the returned object's finalizer is run by the garbage collector).

    -

    21.3.10.1 Null pointers

    +

    20.3.10.1 Null pointers

    @@ -1669,7 +1669,7 @@ For spam1 and spam4 above the Java null gets translat The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.

    -

    21.3.11 C++ overloaded functions

    +

    20.3.11 C++ overloaded functions

    @@ -1784,7 +1784,7 @@ void spam(unsigned short); // Ignored -

    21.3.12 C++ default arguments

    +

    20.3.12 C++ default arguments

    @@ -1827,7 +1827,7 @@ Further details on default arguments and how to restore this approach are given

    -

    21.3.13 C++ namespaces

    +

    20.3.13 C++ namespaces

    @@ -1887,7 +1887,7 @@ symbols separate, consider wrapping them as separate SWIG modules. Each SWIG module can be placed into a separate package.

    -

    21.3.14 C++ templates

    +

    20.3.14 C++ templates

    @@ -1936,7 +1936,7 @@ Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter.

    -

    21.3.15 C++ Smart Pointers

    +

    20.3.15 C++ Smart Pointers

    @@ -2020,7 +2020,7 @@ Foo f = p.__deref__(); // Returns underlying Foo * -

    21.4 Further details on the generated Java classes

    +

    20.4 Further details on the generated Java classes

    @@ -2035,7 +2035,7 @@ Finally enum classes are covered. First, the crucial intermediary JNI class is considered.

    -

    21.4.1 The intermediary JNI class

    +

    20.4.1 The intermediary JNI class

    @@ -2155,7 +2155,7 @@ If name is the same as modulename then the module class name g from modulename to modulenameModule.

    -

    21.4.1.1 The intermediary JNI class pragmas

    +

    20.4.1.1 The intermediary JNI class pragmas

    @@ -2234,7 +2234,7 @@ For example, let's change the intermediary JNI class access to public. All the methods in the intermediary JNI class will then be callable outside of the package as the method modifiers are public by default.

    -

    21.4.2 The Java module class

    +

    20.4.2 The Java module class

    @@ -2265,7 +2265,7 @@ example.egg(new Foo()); The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.

    -

    21.4.2.1 The Java module class pragmas

    +

    20.4.2.1 The Java module class pragmas

    @@ -2316,7 +2316,7 @@ See The intermediary JNI class pragmas section fo

    -

    21.4.3 Java proxy classes

    +

    20.4.3 Java proxy classes

    @@ -2392,7 +2392,7 @@ int y = f.spam(5, new Foo()); -

    21.4.3.1 Memory management

    +

    20.4.3.1 Memory management

    @@ -2554,7 +2554,7 @@ and

    -

    21.4.3.2 Inheritance

    +

    20.4.3.2 Inheritance

    @@ -2670,7 +2670,7 @@ However, true cross language polymorphism can be achieved using the 21.4.3.3 Proxy classes and garbage collection +

    20.4.3.3 Proxy classes and garbage collection

    @@ -2753,7 +2753,7 @@ The section on Java typemaps details how to specify See the How to Handle Java Finalization's Memory-Retention Issues article for alternative approaches to managing memory by avoiding finalizers altogether.

    -

    21.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    +

    20.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling

    @@ -2857,11 +2857,7 @@ and therefore there is no possibility of premature garbage collection. In practi

    The premature garbage collection prevention parameter for proxy classes is generated by default whenever proxy classes are passed by value, reference or with a pointer. -The implementation for this extra parameter generation requires the "jtype" typemap to contain long and the "jstype" typemap to contain the name of a proxy class. -

    - -

    -The additional parameter does impose a slight performance overhead and the parameter generation can be suppressed globally with the -nopgcpp commandline option. +The additional parameters do impose a slight performance overhead and the parameter generation can be suppressed globally with the -nopgcpp commandline option. More selective suppression is possible with the 'nopgcpp' attribute in the "jtype" Java typemap. The attribute is a flag and so should be set to "1" to enable the suppression, or it can be omitted or set to "0" to disable. For example: @@ -2875,7 +2871,7 @@ For example: Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.

    -

    21.4.3.5 Single threaded applications and thread safety

    +

    20.4.3.5 Single threaded applications and thread safety

    @@ -2963,7 +2959,7 @@ for (int i=0; i<100000; i++) { -

    21.4.4 Type wrapper classes

    +

    20.4.4 Type wrapper classes

    @@ -3050,7 +3046,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... } -

    21.4.5 Enum classes

    +

    20.4.5 Enum classes

    @@ -3059,7 +3055,7 @@ The Enumerations section discussed these but omitted The following sub-sections detail the various types of enum classes that can be generated.

    -

    21.4.5.1 Typesafe enum classes

    +

    20.4.5.1 Typesafe enum classes

    @@ -3143,7 +3139,7 @@ The swigValue method is used for marshalling in the other direction. The toString method is overridden so that the enum name is available.

    -

    21.4.5.2 Proper Java enum classes

    +

    20.4.5.2 Proper Java enum classes

    @@ -3221,7 +3217,7 @@ These needn't be generated if the enum being wrapped does not have any initializ Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.

    -

    21.4.5.3 Type unsafe enum classes

    +

    20.4.5.3 Type unsafe enum classes

    @@ -3252,7 +3248,7 @@ public final class Beverage { -

    21.5 Cross language polymorphism using directors

    +

    20.5 Cross language polymorphism using directors

    @@ -3274,7 +3270,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.

    -

    21.5.1 Enabling directors

    +

    20.5.1 Enabling directors

    @@ -3345,7 +3341,7 @@ public: -

    21.5.2 Director classes

    +

    20.5.2 Director classes

    @@ -3372,7 +3368,7 @@ If the correct implementation is in Java, the Java API is used to call the metho

    -

    21.5.3 Overhead and code bloat

    +

    20.5.3 Overhead and code bloat

    @@ -3390,7 +3386,7 @@ This situation can be optimized by selectively enabling director methods (using

    -

    21.5.4 Simple directors example

    +

    20.5.4 Simple directors example

    @@ -3455,7 +3451,7 @@ DirectorDerived::upcall_method() invoked. -

    21.5.5 Director threading issues

    +

    20.5.5 Director threading issues

    @@ -3475,7 +3471,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern -

    21.6 Accessing protected members

    +

    20.6 Accessing protected members

    @@ -3571,7 +3567,7 @@ class MyProtectedBase extends ProtectedBase -

    21.7 Common customization features

    +

    20.7 Common customization features

    @@ -3583,7 +3579,7 @@ be awkward. This section describes some common SWIG features that are used to improve the interface to existing C/C++ code.

    -

    21.7.1 C/C++ helper functions

    +

    20.7.1 C/C++ helper functions

    @@ -3649,7 +3645,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps, customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.

    -

    21.7.2 Class extension with %extend

    +

    20.7.2 Class extension with %extend

    @@ -3712,7 +3708,7 @@ Vector(2,3,4) in any way---the extensions only show up in the Java interface.

    -

    21.7.3 Exception handling with %exception and %javaexception

    +

    20.7.3 Exception handling with %exception and %javaexception

    @@ -3760,7 +3756,7 @@ will produce a familiar looking Java exception: Exception in thread "main" java.lang.OutOfMemoryError: Not enough memory at exampleJNI.malloc(Native Method) at example.malloc(example.java:16) - at runme.main(runme.java:112) + at main.main(main.java:112) @@ -3820,9 +3816,7 @@ public: In the example above, java.lang.Exception is a checked exception class and so ought to be declared in the throws clause of getitem. Classes can be specified for adding to the throws clause using %javaexception(classes) instead of %exception, where classes is a string containing one or more comma separated Java classes. -The %clearjavaexception feature is the equivalent to %clearexception and clears previously declared exception handlers. -The %nojavaexception feature is the equivalent to %noexception and disables the exception handler. -See Clearing features for the difference on disabling and clearing features. +The %nojavaexception feature is the equivalent to %noexception and clears previously declared exception handlers.

    @@ -3871,7 +3865,7 @@ to raise exceptions. See the SWIG Library ch The typemap example Handling C++ exception specifications as Java exceptions provides further exception handling capabilities.

    -

    21.7.4 Method access with %javamethodmodifiers

    +

    20.7.4 Method access with %javamethodmodifiers

    @@ -3897,7 +3891,7 @@ protected static void protect_me() {

    -

    21.8 Tips and techniques

    +

    20.8 Tips and techniques

    @@ -3907,7 +3901,7 @@ strings and arrays. This chapter discusses the common techniques for solving these problems.

    -

    21.8.1 Input and output parameters using primitive pointers and references

    +

    20.8.1 Input and output parameters using primitive pointers and references

    @@ -4081,7 +4075,7 @@ void foo(Bar *OUTPUT); will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

    -

    21.8.2 Simple pointers

    +

    20.8.2 Simple pointers

    @@ -4147,7 +4141,7 @@ System.out.println("3 + 4 = " + result); See the SWIG Library chapter for further details.

    -

    21.8.3 Wrapping C arrays with Java arrays

    +

    20.8.3 Wrapping C arrays with Java arrays

    @@ -4214,7 +4208,7 @@ Please be aware that the typemaps in this library are not efficient as all the e There is an alternative approach using the SWIG array library and this is covered in the next section.

    -

    21.8.4 Unbounded C Arrays

    +

    20.8.4 Unbounded C Arrays

    @@ -4359,7 +4353,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

    -

    21.8.5 Overriding new and delete to allocate from Java heap

    +

    20.8.5 Overriding new and delete to allocate from Java heap

    @@ -4476,7 +4470,7 @@ model and use these functions in place of malloc and free in your own code.

    -

    21.9 Java typemaps

    +

    20.9 Java typemaps

    @@ -4497,7 +4491,7 @@ Before proceeding, it should be stressed that typemaps are not a required part of using SWIG---the default wrapping behavior is enough in most cases. Typemaps are only used if you want to change some aspect of the generated code. -

    21.9.1 Default primitive type mappings

    +

    20.9.1 Default primitive type mappings

    @@ -4649,7 +4643,7 @@ However, the mappings allow the full range of values for each C type from Java.

    -

    21.9.2 Default typemaps for non-primitive types

    +

    20.9.2 Default typemaps for non-primitive types

    @@ -4664,7 +4658,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit The Java type is either the proxy class or type wrapper class.

    -

    21.9.3 Sixty four bit JVMs

    +

    20.9.3 Sixty four bit JVMs

    @@ -4677,7 +4671,7 @@ Unfortunately it won't of course hold true for JNI code.

    -

    21.9.4 What is a typemap?

    +

    20.9.4 What is a typemap?

    @@ -4800,7 +4794,7 @@ int c = example.count('e',"Hello World"); -

    21.9.5 Typemaps for mapping C/C++ types to Java types

    +

    20.9.5 Typemaps for mapping C/C++ types to Java types

    @@ -5060,7 +5054,7 @@ These are listed below: -

    21.9.6 Java typemap attributes

    +

    20.9.6 Java typemap attributes

    @@ -5106,7 +5100,7 @@ The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes. Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.

    -

    21.9.7 Java special variables

    +

    20.9.7 Java special variables

    @@ -5249,7 +5243,7 @@ This special variable expands to the intermediary class name. Usually this is th unless the jniclassname attribute is specified in the %module directive.

    -

    21.9.8 Typemaps for both C and C++ compilation

    +

    20.9.8 Typemaps for both C and C++ compilation

    @@ -5286,7 +5280,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps

    -

    21.9.9 Java code typemaps

    +

    20.9.9 Java code typemaps

    @@ -5482,7 +5476,7 @@ For the typemap to be used in all type wrapper classes, all the different types Again this is the same that is in "java.swg", barring the method modifier for getCPtr.

    -

    21.9.10 Director specific typemaps

    +

    20.9.10 Director specific typemaps

    @@ -5707,7 +5701,7 @@ The basic strategy here is to provide a default package typemap for the majority -

    21.10 Typemap Examples

    +

    20.10 Typemap Examples

    @@ -5717,7 +5711,7 @@ the SWIG library.

    -

    21.10.1 Simpler Java enums for enums without initializers

    +

    20.10.1 Simpler Java enums for enums without initializers

    @@ -5796,7 +5790,7 @@ This would be done by using the original versions of these typemaps in "enums.sw

    -

    21.10.2 Handling C++ exception specifications as Java exceptions

    +

    20.10.2 Handling C++ exception specifications as Java exceptions

    @@ -5921,7 +5915,7 @@ We could alternatively have used %rename to rename what() into

    -

    21.10.3 NaN Exception - exception handling for a particular type

    +

    20.10.3 NaN Exception - exception handling for a particular type

    @@ -6076,7 +6070,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.

    -

    21.10.4 Converting Java String arrays to char **

    +

    20.10.4 Converting Java String arrays to char **

    @@ -6170,9 +6164,9 @@ When this module is compiled, our wrapped C functions can be used by the followi

    -// File runme.java
    +// File main.java
     
    -public class runme {
    +public class main {
     
       static {
         try {
    @@ -6198,7 +6192,7 @@ When compiled and run we get:
     

    -$ java runme
    +$ java main
     argv[0] = Cat
     argv[1] = Dog
     argv[2] = Cow
    @@ -6220,7 +6214,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify
     what Java types to use.
     

    -

    21.10.5 Expanding a Java object to multiple arguments

    +

    20.10.5 Expanding a Java object to multiple arguments

    @@ -6302,7 +6296,7 @@ example.foo(new String[]{"red", "green", "blue", "white"});

    -

    21.10.6 Using typemaps to return arguments

    +

    20.10.6 Using typemaps to return arguments

    @@ -6389,9 +6383,9 @@ The following Java program demonstrates this:

    -// File: runme.java
    +// File: main.java
     
    -public class runme {
    +public class main {
     
       static {
         try {
    @@ -6416,11 +6410,11 @@ When compiled and run we get:
     

    -$ java runme
    +$ java main
     1 12.0  340.0
     
    -

    21.10.7 Adding Java downcasts to polymorphic return types

    +

    20.10.7 Adding Java downcasts to polymorphic return types

    @@ -6476,7 +6470,7 @@ We get:

     Ambulance started
     java.lang.ClassCastException
    -        at runme.main(runme.java:16)
    +        at main.main(main.java:16)
     

    @@ -6626,7 +6620,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.

    -

    21.10.8 Adding an equals method to the Java classes

    +

    20.10.8 Adding an equals method to the Java classes

    @@ -6670,7 +6664,7 @@ System.out.println("foo1? " + foo1.equals(foo2));

    -

    21.10.9 Void pointers and a common Java base class

    +

    20.10.9 Void pointers and a common Java base class

    @@ -6729,7 +6723,7 @@ This example contains some useful functionality which you may want in your code.

  • It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer. -

    21.10.10 Struct pointer to pointer

    +

    20.10.10 Struct pointer to pointer

    @@ -6909,7 +6903,7 @@ The C functional interface has been completely morphed into an object-oriented i the Butler class would behave much like any pure Java class and feel more natural to Java users.

    -

    21.10.11 Memory management when returning references to member variables

    +

    20.10.11 Memory management when returning references to member variables

    @@ -7032,7 +7026,7 @@ public class Bike { Note the addReference call.

    -

    21.10.12 Memory management for objects passed to the C++ layer

    +

    20.10.12 Memory management for objects passed to the C++ layer

    @@ -7148,7 +7142,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla

  • -

    21.10.13 Date marshalling using the javain typemap and associated attributes

    +

    20.10.13 Date marshalling using the javain typemap and associated attributes

    @@ -7325,7 +7319,7 @@ A few things to note: -

    21.11 Living with Java Directors

    +

    20.11 Living with Java Directors

    @@ -7506,10 +7500,10 @@ public abstract class UserVisibleFoo extends Foo {

  • -

    21.12 Odds and ends

    +

    20.12 Odds and ends

    -

    21.12.1 JavaDoc comments

    +

    20.12.1 JavaDoc comments

    @@ -7565,7 +7559,7 @@ public class Barmy { -

    21.12.2 Functional interface without proxy classes

    +

    20.12.2 Functional interface without proxy classes

    @@ -7626,7 +7620,7 @@ All destructors have to be called manually for example the delete_Foo(foo) -

    21.12.3 Using your own JNI functions

    +

    20.12.3 Using your own JNI functions

    @@ -7676,7 +7670,7 @@ This directive is only really useful if you want to mix your own hand crafted JN

    -

    21.12.4 Performance concerns and hints

    +

    20.12.4 Performance concerns and hints

    @@ -7697,7 +7691,7 @@ However, you will have to be careful about memory management and make sure that This method normally calls the C++ destructor or free() for C code.

    -

    21.12.5 Debugging

    +

    20.12.5 Debugging

    @@ -7719,7 +7713,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh

    -

    21.13 Examples

    +

    20.13 Examples

    diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index 7293f31fe..586e1ecab 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -14,7 +14,7 @@

  • C Arrays and Pointers @@ -316,7 +316,7 @@ In this example, the function int_to_uint() would be used to cast type Note: When working with simple pointers, typemaps can often be used to provide more seamless operation.

    -

    8.2.2 carrays.i

    +

    8.2.2 carrays.i

    @@ -419,9 +419,7 @@ delete_doubleArray(a) # Destroy array -

    %array_class(type,name) -

    diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html index 53cddab83..ca2d0414e 100644 --- a/Doc/Manual/Lisp.html +++ b/Doc/Manual/Lisp.html @@ -6,7 +6,7 @@ -

    22 SWIG and Common Lisp

    +

    21 SWIG and Common Lisp

      @@ -41,7 +41,7 @@ Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI foreign function interfaces.

      -

      22.1 Allegro Common Lisp

      +

      21.1 Allegro Common Lisp

      @@ -50,7 +50,7 @@ here

      -

      22.2 Common Foreign Function Interface(CFFI)

      +

      21.2 Common Foreign Function Interface(CFFI)

      @@ -77,7 +77,7 @@ swig -cffi -module module-name file-name files and the various things which you can do with them.

      -

      22.2.1 Additional Commandline Options

      +

      21.2.1 Additional Commandline Options

      @@ -118,7 +118,7 @@ swig -cffi -help -

      22.2.2 Generating CFFI bindings

      +

      21.2.2 Generating CFFI bindings

      As we mentioned earlier the ideal way to use SWIG is to use interface @@ -392,7 +392,7 @@ The feature intern_function ensures that all C names are
    -

    22.2.3 Generating CFFI bindings for C++ code

    +

    21.2.3 Generating CFFI bindings for C++ code

    This feature to SWIG (for CFFI) is very new and still far from @@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI module feel free to contact us on the SWIG mailing list, and also please add a "[CFFI]" tag in the subject line. -

    22.2.4 Inserting user code into generated files

    +

    21.2.4 Inserting user code into generated files

    @@ -583,7 +583,7 @@ using the SWIG %insert(section) %{ ...code... %} directive:

     %module example
     
    -%{
    +%insert("runtime") %{
     #include "header.h"
     %}
     
    @@ -604,11 +604,11 @@ generated lisp interface file:
     
     

    Note that the block %{ ... %} is effectively a shortcut for -%insert("header") %{ ... %}. +%insert("runtime") %{ ... %}.

    -

    22.3 CLISP

    +

    21.3 CLISP

    @@ -638,7 +638,7 @@ swig -clisp -module module-name file-name interface file for the CLISP module. The CLISP module tries to produce code which is both human readable and easily modifyable.

    -

    22.3.1 Additional Commandline Options

    +

    21.3.1 Additional Commandline Options

    @@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for
    -

    22.3.2 Details on CLISP bindings

    +

    21.3.2 Details on CLISP bindings

    @@ -795,7 +795,7 @@ struct bar {

    -

    22.4 UFFI

    +

    21.4 UFFI

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index e66c1c7f3..4ebf02349 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -6,7 +6,7 @@ -

    23 SWIG and Lua

    +

    22 SWIG and Lua

  • Typemaps +
  • Details on the Lua binding -
  • Writing typemaps - -
  • Customization of your Bindings - -
  • Details on the Lua binding - @@ -67,13 +52,13 @@

    Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org

    -

    23.1 Preliminaries

    +

    22.1 Preliminaries

    The current SWIG implementation is designed to work with Lua 5.0.x and Lua 5.1.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. ((Currently SWIG generated code has only been tested on Windows with MingW, though given the nature of Lua, is should not have problems on other OS's)). It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms).

    -

    23.2 Running SWIG

    +

    22.2 Running SWIG

    @@ -105,7 +90,7 @@ This creates a C/C++ source file example_wrap.c or example_wrap.cxx

    The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrappered module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.

    -

    23.2.1 Compiling and Linking and Interpreter

    +

    22.2.1 Compiling and Linking and Interpreter

    @@ -152,7 +137,7 @@ $ gcc -c example.c -o example.o $ gcc -I/usr/include/lua -L/usr/lib/lua min.o example_wrap.o example.o -o my_lua -

    23.2.2 Compiling a dynamic module

    +

    22.2.2 Compiling a dynamic module

    @@ -220,7 +205,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib -

    23.2.3 Using your module

    +

    22.2.3 Using your module

    @@ -238,19 +223,19 @@ $ ./my_lua > -

    23.3 A tour of basic C/C++ wrapping

    +

    22.3 A tour of basic C/C++ wrapping

    By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.

    -

    23.3.1 Modules

    +

    22.3.1 Modules

    The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.

    -

    23.3.2 Functions

    +

    22.3.2 Functions

    @@ -288,7 +273,7 @@ It is also possible to rename the module with an assignment. 24 -

    23.3.3 Global variables

    +

    22.3.3 Global variables

    @@ -362,7 +347,7 @@ nil 3.142 -

    23.3.4 Constants and enums

    +

    22.3.4 Constants and enums

    @@ -385,7 +370,7 @@ example.SUNDAY=0

    Constants are not guaranteed to remain constant in Lua. The name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

    -

    23.3.5 Pointers

    +

    22.3.5 Pointers

    @@ -423,7 +408,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor nil -

    23.3.6 Structures

    +

    22.3.6 Structures

    @@ -509,7 +494,7 @@ Because the pointer points inside the structure, you can modify the contents and > x.a = 3 -- Modifies the same structure -

    23.3.7 C++ classes

    +

    22.3.7 C++ classes

    @@ -570,7 +555,7 @@ It is not (currently) possible to access static members of an instance: -- does NOT work -

    23.3.8 C++ inheritance

    +

    22.3.8 C++ inheritance

    @@ -595,7 +580,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas

    It is safe to use multiple inheritance with SWIG.

    -

    23.3.9 Pointers, references, values, and arrays

    +

    22.3.9 Pointers, references, values, and arrays

    @@ -626,7 +611,7 @@ Foo spam7();

    then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.

    -

    23.3.10 C++ overloaded functions

    +

    22.3.10 C++ overloaded functions

    @@ -712,7 +697,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin

    Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.

    -

    23.3.11 C++ operators

    +

    22.3.11 C++ operators

    @@ -824,7 +809,7 @@ It is also possible to overload the operator[], but currently this cann }; -

    23.3.12 Class extension with %extend

    +

    22.3.12 Class extension with %extend

    @@ -879,7 +864,7 @@ true

    Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).

    -

    23.3.13 C++ templates

    +

    22.3.13 C++ templates

    @@ -914,7 +899,7 @@ In Lua:

    Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.

    -

    23.3.14 C++ Smart Pointers

    +

    22.3.14 C++ Smart Pointers

    @@ -966,7 +951,7 @@ If you ever need to access the underlying pointer returned by operator->( > f = p:__deref__() -- Returns underlying Foo * -

    23.3.15 C++ Exceptions

    +

    22.3.15 C++ Exceptions

    @@ -1018,9 +1003,8 @@ stack traceback:

    -SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem. It has also written typemaps for std::exception and its derived classes, which convert the exception into and error string.

    -

    -However its not so simple for to throw other types of objects. +SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem. +However its not so simple for to throw objects. Thrown objects are not valid outside the 'catch' block. Therefore they cannot be returned to the interpreter. The obvious ways to overcome this would be to either return a copy of the object, or so convert the object to a string and @@ -1054,6 +1038,10 @@ To get a more useful behaviour out of SWIG you must either: provide a way to con throw objects which can be copied.

    +SWIG has typemaps for std::exception and its children already written, so a function which throws any of these will +automatically have its exception converted into an error string. +

    +

    If you have your own class which you want output as a string you will need to add a typemap something like this:

    @@ -1110,271 +1098,7 @@ add exception specification to functions or globally (respectively).
     

    -

    23.4 Typemaps

    - - -

    This section explains what typemaps are and the usage of them. The default wrappering behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrappering. This section will be explaining how to use typemaps to best effect

    - -

    23.4.1 What is a typemap?

    - - -

    A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:

    - -
    %module example
    -
    -%typemap(in) int {
    -	$1 = (int) lua_tonumber(L,$input);
    -	printf("Received an integer : %d\n",$1);
    -}
    -%inline %{
    -extern int fact(int n);
    -%}
    -
    - -

    Note: you shouldn't use this typemap, as SWIG already has a typemap for this task. This is purely for example.

    - -

    Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variable prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input is the index on the Lua stack for the value to be used.

    - -

    When this example is compiled into a Lua module, it operates as follows:

    - -
    > require "example"
    -> print(example.fact(6))
    -Received an integer : 6
    -720
    -
    - -

    23.4.2 Using typemaps

    - - -

    There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.

    - -

    However for more complex functions which use input/output parameters or arrays, you will need to make use of <typemaps.i>, which contains typemaps for these situations. For example, consider these functions:

    - -
    void add(int x, int y, int *result) {
    -   *result = x + y;
    -}
    -
    -int sub(int *x1, int *y1) {
    -   return *x1-*y1;
    -}
    -
    -void swap(int *sx, int *sy) {
    -   int t=*sx;
    -   *sx=*sy;
    -   *sy=t;
    -}
    -
    - -

    It is clear to the programmer, that 'result' is an output parameter, 'x1' and 'y1' are input parameters and 'sx' and 'sy' are input/output parameters. However is not apparent to SWIG, so SWIG must to informed about which kind they are, so it can wrapper accordingly.

    - -

    One means would be to rename the argument name to help SWIG, eg void add(int x, int y, int *OUTPUT), however it is easier to use the %apply to achieve the same result, as shown below.

    - -
    %include <typemaps.i>
    -%apply int* OUTPUT {int *result}; // int *result is output
    -%apply int* INPUT {int *x1, int *y1}; // int *x1 and int *y1 are input
    -%apply int* INOUT {int *sx, int *sy}; // int *sx and int *sy are input and output
    -
    -void add(int x, int y, int *result);
    -int sub(int *x1, int *y1);
    -void swap(int *sx, int *sy);
    -
    - -

    When wrapped, it gives the following results:

    - -
    > require "example"
    -> print(example.add(1,2))
    -3
    -> print(demo.sub(1,2))
    --1
    -> a,b=1,2
    -> c,d=demo.swap(a,b)
    -> print(a,b,c,d)
    -1       2       2       1
    -
    - -

    Notice, that 'result' is not required in the arguments to call the function, as it an output parameter only. For 'sx' and 'sy' they must be passed in (as they are input), but the original value is not modified (Lua does not have a pass by reference feature). The modified results are then returned as two return values. All INPUT/OUTPUT/INOUT arguments will behave in a similar manner.

    - -

    Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a const int& as an input parameter (since that it obviously input).

    - -

    23.4.3 Typemaps and arrays

    - - -

    Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor -does SWIG have any indication of how large an array should be. However with the proper guidance SWIG can easily wrapper -arrays for convenient usage.

    - -

    Given the functions:

    -
    extern void sort_int(int* arr, int len);
    -extern void sort_double(double* arr, int len);
    -
    - -

    There are basically two ways that SWIG can deal with this. The first way, uses the <carrays.i> library -to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but its a bit tedious. -More details can be found in the carrays.i documention.

    - -

    The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %appy in the correct manner.

    - -

    The wrapper file below, shows both the use of carrays as well as the use of the typemap to wrap arrays.

    - -
    // using the C-array
    -%include <carrays.i>
    -// this declares a batch of function for manipulating C integer arrays
    -%array_functions(int,int)
    -
    -extern void sort_int(int* arr, int len); // the function to wrap
    -
    -// using typemaps
    -%include <typemaps.i>
    -%apply (double *INOUT,int) {(double* arr,int len)};
    -
    -extern void sort_double(double* arr, int len); // the function to wrap
    -
    - -

    Once wrappered, the functions can both be called, though with different ease of use:

    - -
    require "example"
    -ARRAY_SIZE=10
    -
    --- passing a C array to the sort_int()
    -arr=example.new_int(ARRAY_SIZE) -- create the array
    -for i=0,ARRAY_SIZE-1 do -- index 0..9 (just like C)
    -    example.int_setitem(arr,i,math.random(1000))
    -end
    -example.sort_int(arr,ARRAY_SIZE)  -- call the function
    -example.delete_int(arr) -- must delete the allocated memory
    -
    --- use a typemap to call with a Lua-table
    --- one item of note: the typemap creates a copy, rather than edit-in-place
    -t={} -- a Lua table
    -for i=1,ARRAY_SIZE do -- index 1..10 (Lua style)
    -    t[i]=math.random(1000)/10
    -end
    -t=example.sort_double(t) -- replace t with the result
    -
    - -

    Obviously the first version could be made less tedious by writing a Lua function to perform the conversion from a table -to a C-array. The %luacode directive is good for this. See SWIG\Examples\lua\arrays for an example of this.

    - -

    Warning: in C indexes start at ZERO, in Lua indexes start at ONE. SWIG expects C-arrays to be filled for 0..N-1 -and Lua tables to be 1..N, (the indexing follows the norm for the language). In the typemap when it converts the table to an array it quietly changes the indexing accordingly. Take note of this behaviour if you have a C function which returns indexes.

    - -

    Note: SWIG also can support arrays of pointers in a similar manner.

    - -

    23.4.4 Typemaps and pointer-pointer functions

    - - -

    Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:

    - -
    struct iMath;    // some structure
    -int Create_Math(iMath** pptr); // its creator (assume it mallocs)
    -
    - -

    Which would be used with the following C code:

    - -
    iMath* ptr;
    -int ok;
    -ok=Create_Math(&ptr);
    -// do things with ptr
    -//...
    -free(ptr); // dispose of iMath
    -
    - -

    SWIG has a ready written typemap to deal with such a kind of function in <typemaps.i>. It provides the correct wrappering as well as setting the flag to inform Lua that the object in question should be garbage collected. Therefore the code is simply:

    - -
    %include <typemaps.i>
    -%apply SWIGTYPE** OUTPUT{iMath **pptr }; // tell SWIG its an output
    -
    -struct iMath;    // some structure
    -int Create_Math(iMath** pptr); // its creator (assume it mallocs)
    -
    - -

    The usage is as follows:

    - -
    ok,ptr=Create_Math() -- ptr is a iMath* which is returned with the int (ok)
    -ptr=nil -- the iMath* will be GC'ed as normal
    -
    - -

    23.5 Writing typemaps

    - - -

    This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "Typemaps" chapter.

    - -

    Before proceeding, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrappering, or to achieve an effect which in not available with the default bindings.

    - -

    Before proceeding, you should read the previous section on using typemaps, as well as read the ready written typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you a idea to base your worn on).

    - -

    23.5.1 Typemaps you can write

    - - -

    There are many different types of typemap that can be written, the full list can be found in the "Typemaps" chapter. However the following are the most commonly used ones.

    - -
      -
    • in this is for input arguments to functions
    • -
    • out this is for return types from functions
    • -
    • argout this is for a function argument which is actually returning something
    • -
    • typecheck this is used to determine which overloaded function should be called -(the syntax for the typecheck is different from the typemap, see typemaps for details).
    • -
    - -

    23.5.2 SWIG's Lua-C API

    - - -

    This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.

    - -

    int SWIG_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags);

    - -
    -This is the standard function used for converting a Lua userdata to a void*. It takes the value at the given index in the Lua state and converts it to a userdata. It will then provide the neccesary type checks, confirming that the pointer is compatible with the type given in 'type'. Then finally setting '*ptr' to the pointer. -If flags is set to SWIG_POINTER_DISOWN, this is will clear any ownership flag set on the object.
    -The returns a value which can be checked with the macro SWIG_IsOK() -
    - -

    void SWIG_NewPointerObj(lua_State* L,void* ptr,swig_type_info *type,int own);

    - -
    -This is the opposite of SWIG_ConvertPtr, as it pushes a new userdata which wrappers the pointer 'ptr' of type 'type'. -The parameter 'own' specifies if the object is owned be Lua and if it is 1 then Lua will GC the object when the userdata is disposed of. -
    - -

    void* SWIG_MustGetPtr(lua_State* L,int index,swig_type_info *type,int flags,int argnum,const char* func_name);

    - -
    -This function is a version of SWIG_ConvertPtr(), except that it will either work, or it will trigger a lua_error() with a text error message. This function is rarely used, and may be deprecated in the future. -
    - -

    SWIG_fail

    - -
    -This macro, when called within the context of a SWIG wrappered function, will jump to the error handler code. This will call any cleanup code (freeing any temp variables) and then triggers a lua_error.
    -A common use for this code is:
    -if (!SWIG_IsOK(SWIG_ConvertPtr( .....)){
    - lua_pushstring(L,"something bad happened");
    - SWIG_fail;
    -}
    - -

    SWIG_fail_arg(char* func_name,int argnum,char* type)

    - -
    -This macro, when called within the context of a SWIG wrappered function, will display the error message and jump to the error handler code. The error message is of the form -
    -"Error in func_name (arg argnum), expected 'type' got 'whatever the type was'"
    -
    - -

    SWIG_fail_ptr(const char* fn_name,int argnum,swig_type_info* type);

    - -
    -Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
    - -

    23.6 Customization of your Bindings

    - - -

    -This section covers adding of some small extra bits to your module to add the last finishing touches. -

    - - - -

    23.6.1 Writing your own custom wrappers

    +

    22.3.16 Writing your own custom wrappers

    @@ -1393,7 +1117,7 @@ int native_function(lua_State*L) // my native code The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.

    -

    23.6.2 Adding additional Lua code

    +

    22.3.17 Adding additional Lua code

    @@ -1431,7 +1155,7 @@ Good uses for this feature is adding of new code, or writing helper functions to See Examples/lua/arrays for an example of this code.

    -

    23.7 Details on the Lua binding

    +

    22.4 Details on the Lua binding

    @@ -1442,7 +1166,7 @@ See Examples/lua/arrays for an example of this code.

    -

    23.7.1 Binding global data into the module.

    +

    22.4.1 Binding global data into the module.

    @@ -1502,7 +1226,7 @@ end

    That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.

    -

    23.7.2 Userdata and Metatables

    +

    22.4.2 Userdata and Metatables

    @@ -1582,7 +1306,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s

    Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.

    -

    23.7.3 Memory management

    +

    22.4.3 Memory management

    diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile index 4c907791b..1923c2c48 100644 --- a/Doc/Manual/Makefile +++ b/Doc/Manual/Makefile @@ -18,19 +18,15 @@ HTMLDOC_OPTIONS = "--book --toclevels 4 --no-numbered --toctitle \"Table of Cont all: maketoc check generate -maketoc: CCache.html +maketoc: python maketoc.py -CCache.html: ../../CCache/ccache.yo - yodl2html -o CCache.html ../../CCache/ccache.yo - # Use htmltidy to warn about some HTML errors. Note that it is not used to clean/tidy the HTML, # it is just used as a primitive HTML checker. -# CCache.html is generated by yodl2html and has a few insignificant problems, so we don't put it through tidy check: tidy -errors --gnu-emacs yes -quiet index.html tidy -errors --gnu-emacs yes -quiet Sections.html - all=`sed '/^#/d' chapters | grep -v CCache.html`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done; + all=`sed '/^#/d' chapters`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done; generate: swightml.book swigpdf.book htmldoc --batch swightml.book || true @@ -49,14 +45,11 @@ swightml.book: echo "Sections.html" >> swightml.book cat chapters >> swightml.book -clean: clean-baks +clean: rm -f swightml.book rm -f swigpdf.book - rm -f CCache.html rm -f SWIGDocumentation.html rm -f SWIGDocumentation.pdf - -clean-baks: rm -f *.bak test: diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html index c4e485202..ff70fc143 100644 --- a/Doc/Manual/Modula3.html +++ b/Doc/Manual/Modula3.html @@ -5,7 +5,7 @@ -

    24 SWIG and Modula-3

    +

    23 SWIG and Modula-3

      @@ -57,7 +57,7 @@ especially typemaps.

      -

      24.1 Overview

      +

      23.1 Overview

      @@ -90,7 +90,7 @@ So the introduction got a bit longer than it should ... ;-)

      -

      24.1.1 Why not scripting ?

      +

      23.1.1 Why not scripting ?

      @@ -126,7 +126,7 @@ are not advantages of the language itself but can be provided by function libraries.

      -

      24.1.2 Why Modula-3 ?

      +

      23.1.2 Why Modula-3 ?

      @@ -166,7 +166,7 @@ it's statically typed, too.

      -

      24.1.3 Why C / C++ ?

      +

      23.1.3 Why C / C++ ?

      @@ -179,7 +179,7 @@ Even more fortunately even non-C libraries may provide C header files. This is where SWIG becomes helpful.

      -

      24.1.4 Why SWIG ?

      +

      23.1.4 Why SWIG ?

      @@ -252,10 +252,10 @@ integrate Modula-3 code into a C / C++ project.

      -

      24.2 Conception

      +

      23.2 Conception

      -

      24.2.1 Interfaces to C libraries

      +

      23.2.1 Interfaces to C libraries

      @@ -404,7 +404,7 @@ and the principal type must be renamed (%typemap).

      -

      24.2.2 Interfaces to C++ libraries

      +

      23.2.2 Interfaces to C++ libraries

      @@ -505,10 +505,10 @@ There is no C++ library I wrote a SWIG interface for, so I'm not sure if this is possible or sensible, yet.

      -

      24.3 Preliminaries

      +

      23.3 Preliminaries

      -

      24.3.1 Compilers

      +

      23.3.1 Compilers

      @@ -522,7 +522,7 @@ For testing examples I use Critical Mass cm3.

      -

      24.3.2 Additional Commandline Options

      +

      23.3.2 Additional Commandline Options

      @@ -599,10 +599,10 @@ Instead generate templates for some basic typemaps. -

      24.4 Modula-3 typemaps

      +

      23.4 Modula-3 typemaps

      -

      24.4.1 Inputs and outputs

      +

      23.4.1 Inputs and outputs

      @@ -818,7 +818,7 @@ consist of the following parts: -

      24.4.2 Subranges, Enumerations, Sets

      +

      23.4.2 Subranges, Enumerations, Sets

      @@ -860,8 +860,8 @@ that split the task up into converting the C bit patterns (integer or bit set) into Modula-3 bit patterns (integer or bit set) and change the type as requested. -See the corresponding example in the -Examples/modula3/enum/example.i file. +See the corresponding +example. This is quite messy and not satisfying. So the best what you can currently do is to rewrite constant definitions manually. @@ -870,20 +870,20 @@ that I'd like to automate.

      -

      24.4.3 Objects

      +

      23.4.3 Objects

      Declarations of C++ classes are mapped to OBJECT types while it is tried to retain the access hierarchy "public - protected - private" using partial revelation. -Though the example in -Examples/modula3/class/example.i +Though the +implementation is not really useful, yet.

      -

      24.4.4 Imports

      +

      23.4.4 Imports

      @@ -918,7 +918,7 @@ IMPORT M3toC;

    -

    24.4.5 Exceptions

    +

    23.4.5 Exceptions

    @@ -942,7 +942,7 @@ you should declare %typemap("m3wrapinconv:throws") blah * %{OSError.E%}.

    -

    24.4.6 Example

    +

    23.4.6 Example

    @@ -989,10 +989,10 @@ where almost everything is generated by a typemap: -

    24.5 More hints to the generator

    +

    23.5 More hints to the generator

    -

    24.5.1 Features

    +

    23.5.1 Features

    @@ -1029,7 +1029,7 @@ where almost everything is generated by a typemap:
    -

    24.5.2 Pragmas

    +

    23.5.2 Pragmas

    @@ -1052,7 +1052,7 @@ where almost everything is generated by a typemap:
    -

    24.6 Remarks

    +

    23.6 Remarks

      diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html index 5ac66dc2e..8971324fb 100644 --- a/Doc/Manual/Modules.html +++ b/Doc/Manual/Modules.html @@ -50,90 +50,41 @@ scripting language runtime as you would do for the single module case.

      A bit more complex is the case in which modules need to share information. -For example, when one module extends the class of another by deriving from +For example, when one module extends the class of the another by deriving from it:

      -// File: base.h
      +%module base
      +
      +%inline %{
       class base {
       public:
      -  int foo();
      +       int foo(void);
       };
      -
      -  - -
      -// File: base_module.i
      -%module base_module
      -
      -%{
      -#include "base.h"
       %}
      -%include "base.h"
       
        -
      -// File: derived_module.i
      -%module derived_module
      +%module derived
       
      -%import "base_module.i"
      +%import "base.i"
       
       %inline %{
       class derived : public base {
       public:
      -  int bar();
      +       int bar(void);
       };
       %}
       
      -

      To create the wrapper properly, module derived_module needs to know about the -base class and that its interface is covered in another module. The -line %import "base_module.i" lets SWIG know exactly that. Oftentimes -the .h file is passed to %import instead of the .i, -which unfortunately doesn't work for all language modules. For example, Python requires the -name of module that the base class exists in so that the proxy classes can fully inherit the -base class's methods. Typically you will get a warning when the module name is missing, eg: -

      - -
      -derived_module.i:8: Warning(401): Base class 'base' ignored - unknown module name for base. Either import 
      -the appropriate module interface file or specify the name of the module in the %import directive.
      -
      - -

      -It is sometimes desirable to import the header file rather than the interface file and overcome -the above warning. -For example in the case of the imported interface being quite large, it may be desirable to -simplify matters and just import a small header file of dependent types. -This can be done by specifying the optional module attribute in the %import directive. -The derived_module.i file shown above could be replaced with the following: - -

      -// File: derived_module.i
      -%module derived_module
      -
      -%import(module="base_module") "base.h"
      -
      -%inline %{
      -class derived : public base {
      -public:
      -  int bar();
      -};
      -
      - -

      -Note that "base_module" is the module name and is the same as that specified in %module -in base_module.i as well as the %import in derived_module.i. -

      - -

      -Another issue -to beware of is that multiple dependent wrappers should not be linked/loaded +

      To create the wrapper properly, module derived needs to know the +base class and that it's interface is covered in another module. The +line %import "base.i" lets SWIG know exactly that. The common mistake here is +to %import the .h file instead of the .i, which sadly won't do the trick. Another issue +to take care of is that multiple dependent wrappers should not be linked/loaded in parallel from multiple threads as SWIG provides no locking - for more on that -issue, read on. -

      +issue, read on.

      15.2 The SWIG runtime code

      diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html index 9413bb010..699168322 100644 --- a/Doc/Manual/Mzscheme.html +++ b/Doc/Manual/Mzscheme.html @@ -8,7 +8,7 @@ -

      25 SWIG and MzScheme

      +

      24 SWIG and MzScheme

        @@ -22,7 +22,7 @@

        This section contains information on SWIG's support of MzScheme. -

        25.1 Creating native MzScheme structures

        +

        24.1 Creating native MzScheme structures

        diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index 6dbf24c11..79ede443f 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -6,7 +6,7 @@ -

        26 SWIG and Ocaml

        +

        25 SWIG and Ocaml

          @@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit The Ocaml Website.

          -

          26.1 Preliminaries

          +

          25.1 Preliminaries

          @@ -99,7 +99,7 @@ file Examples/Makefile illustrate how to compile and link SWIG modules that will be loaded dynamically. This has only been tested on Linux so far.

          -

          26.1.1 Running SWIG

          +

          25.1.1 Running SWIG

          @@ -122,7 +122,7 @@ you will compile the file example_wrap.c with ocamlc or the resulting .ml and .mli files as well, and do the final link with -custom (not needed for native link).

          -

          26.1.2 Compiling the code

          +

          25.1.2 Compiling the code

          @@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.

        -

        26.1.3 The camlp4 module

        +

        25.1.3 The camlp4 module

        @@ -234,7 +234,7 @@ let b = C_string (getenv "PATH") -

        26.1.4 Using your module

        +

        25.1.4 Using your module

        @@ -248,7 +248,7 @@ When linking any ocaml bytecode with your module, use the -custom option is not needed when you build native code.

        -

        26.1.5 Compilation problems and compiling with C++

        +

        25.1.5 Compilation problems and compiling with C++

        @@ -259,7 +259,7 @@ liberal with pointer types may not compile under the C++ compiler. Most code meant to be compiled as C++ will not have problems.

        -

        26.2 The low-level Ocaml/C interface

        +

        25.2 The low-level Ocaml/C interface

        @@ -360,7 +360,7 @@ is that you must append them to the return list with swig_result = caml_list_a signature for a function that uses value in this way.

        -

        26.2.1 The generated module

        +

        25.2.1 The generated module

        @@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions. -

        26.2.2 Enums

        +

        25.2.2 Enums

        @@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a

      -

      26.2.2.1 Enum typing in Ocaml

      +

      25.2.2.1 Enum typing in Ocaml

      @@ -470,10 +470,10 @@ functions imported from different modules. You must convert values to master values using the swig_val function before sharing them with another module.

      -

      26.2.3 Arrays

      +

      25.2.3 Arrays

      -

      26.2.3.1 Simple types of bounded arrays

      +

      25.2.3.1 Simple types of bounded arrays

      @@ -494,7 +494,7 @@ arrays of simple types with known bounds in your code, but this only works for arrays whose bounds are completely specified.

      -

      26.2.3.2 Complex and unbounded arrays

      +

      25.2.3.2 Complex and unbounded arrays

      @@ -507,7 +507,7 @@ SWIG can't predict which of these methods will be used in the array, so you have to specify it for yourself in the form of a typemap.

      -

      26.2.3.3 Using an object

      +

      25.2.3.3 Using an object

      @@ -521,7 +521,7 @@ Consider writing an object when the ending condition of your array is complex, such as using a required sentinel, etc.

      -

      26.2.3.4 Example typemap for a function taking float * and int

      +

      25.2.3.4 Example typemap for a function taking float * and int

      @@ -572,7 +572,7 @@ void printfloats( float *tab, int len ); -

      26.2.4 C++ Classes

      +

      25.2.4 C++ Classes

      @@ -615,7 +615,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the returned value for the same object.

      -

      26.2.4.1 STL vector and string Example

      +

      25.2.4.1 STL vector and string Example

      @@ -695,7 +695,7 @@ baz # -

      26.2.4.2 C++ Class Example

      +

      25.2.4.2 C++ Class Example

      @@ -725,7 +725,7 @@ public: }; -

      26.2.4.3 Compiling the example

      +

      25.2.4.3 Compiling the example

      @@ -743,7 +743,7 @@ bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
         -L$QTPATH/lib -cclib -lqt
       
      -

      26.2.4.4 Sample Session

      +

      25.2.4.4 Sample Session

      @@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window
       containing the string "hi" in a button.  
       

      -

      26.2.5 Director Classes

      +

      25.2.5 Director Classes

      -

      26.2.5.1 Director Introduction

      +

      25.2.5.1 Director Introduction

      @@ -800,7 +800,7 @@ class foo { };

      -

      26.2.5.2 Overriding Methods in Ocaml

      +

      25.2.5.2 Overriding Methods in Ocaml

      @@ -828,7 +828,7 @@ In this example, I'll examine the objective caml code involved in providing an overloaded class. This example is contained in Examples/ocaml/shapes.

      -

      26.2.5.3 Director Usage Example

      +

      25.2.5.3 Director Usage Example

      @@ -887,7 +887,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the program in C++.

      -

      26.2.5.4 Creating director objects

      +

      25.2.5.4 Creating director objects

      @@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed properly.

      -

      26.2.5.5 Typemaps for directors, directorin, directorout, directorargout

      +

      25.2.5.5 Typemaps for directors, directorin, directorout, directorargout

      @@ -939,7 +939,7 @@ well as a function return value in the same way you provide function arguments, and to receive arguments the same way you normally receive function returns.

      -

      26.2.5.6 directorin typemap

      +

      25.2.5.6 directorin typemap

      @@ -950,7 +950,7 @@ code receives when you are called. In general, a simple directorin typ can use the same body as a simple out typemap.

      -

      26.2.5.7 directorout typemap

      +

      25.2.5.7 directorout typemap

      @@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object ownership, etc.

      -

      26.2.5.8 directorargout typemap

      +

      25.2.5.8 directorargout typemap

      @@ -978,7 +978,7 @@ In the event that you don't specify all of the necessary values, integral values will read zero, and struct or object returns have undefined results.

      -

      26.2.6 Exceptions

      +

      25.2.6 Exceptions

      diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index 7409d78f1..97e1be17c 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -8,7 +8,7 @@ -

      27 SWIG and Octave

      +

      26 SWIG and Octave

        @@ -54,14 +54,14 @@ More information can be found at www.octave.org< Also, there are a dozen or so examples in the Examples/octave directory, and hundreds in the test suite (Examples/test-suite and Examples/test-suite/octave).

        -

        27.1 Preliminaries

        +

        26.1 Preliminaries

        The current SWIG implemention is based on Octave 2.9.12. Support for other versions (in particular the recent 3.0) has not been tested, nor has support for any OS other than Linux.

        -

        27.2 Running SWIG

        +

        26.2 Running SWIG

        @@ -89,7 +89,7 @@ This creates a C/C++ source file example_wrap.cxx. The generated C++ so The swig command line has a number of options you can use, like to redirect it's output. Use swig --help to learn about these.

        -

        27.2.1 Compiling a dynamic module

        +

        26.2.1 Compiling a dynamic module

        @@ -116,7 +116,7 @@ $ mkoctfile example_wrap.cxx example.c

        octave:1> example
        -

        27.2.2 Using your module

        +

        26.2.2 Using your module

        @@ -134,10 +134,10 @@ octave:4> example.cvar.Foo=4; octave:5> example.cvar.Foo ans = 4

      -

      27.3 A tour of basic C/C++ wrapping

      +

      26.3 A tour of basic C/C++ wrapping

      -

      27.3.1 Modules

      +

      26.3.1 Modules

      @@ -179,7 +179,7 @@ One can also rename it by simple assignment, e.g., octave:1> some_vars = cvar; -

      27.3.2 Functions

      +

      26.3.2 Functions

      @@ -196,7 +196,7 @@ int fact(int n);

      octave:1> example.fact(4)
       24 
      -

      27.3.3 Global variables

      +

      26.3.3 Global variables

      @@ -249,7 +249,7 @@ octave:2> example.PI=3.142; octave:3> example.PI ans = 3.1420 -

      27.3.4 Constants and enums

      +

      26.3.4 Constants and enums

      @@ -271,7 +271,7 @@ example.SCONST="Hello World" example.SUNDAY=0 .... -

      27.3.5 Pointers

      +

      26.3.5 Pointers

      @@ -318,7 +318,7 @@ octave:2> f=example.fopen("not there","r"); error: value on right hand side of assignment is undefined error: evaluating assignment expression near line 2, column 2 -

      27.3.6 Structures and C++ classes

      +

      26.3.6 Structures and C++ classes

      @@ -453,7 +453,7 @@ ans = 1 Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.

      -

      27.3.7 C++ inheritance

      +

      26.3.7 C++ inheritance

      @@ -462,7 +462,7 @@ This information contains the full class hierarchy. When an indexing operation ( the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.

      -

      27.3.8 C++ overloaded functions

      +

      26.3.8 C++ overloaded functions

      @@ -472,7 +472,7 @@ The dispatch function selects which overload to call (if any) based on the passe typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.

      -

      27.3.9 C++ operators

      +

      26.3.9 C++ operators

      @@ -572,7 +572,7 @@ On the C++ side, the default mappings are as follows: %rename(__brace) *::operator[]; -

      27.3.10 Class extension with %extend

      +

      26.3.10 Class extension with %extend

      @@ -602,7 +602,7 @@ octave:3> printf("%s\n",a); octave:4> a.__str() 4 -

      27.3.11 C++ templates

      +

      26.3.11 C++ templates

      @@ -679,14 +679,14 @@ ans = -

      27.3.12 C++ Smart Pointers

      +

      26.3.12 C++ Smart Pointers

      C++ smart pointers are fully supported as in other modules.

      -

      27.3.13 Directors (calling Octave from C++ code)

      +

      26.3.13 Directors (calling Octave from C++ code)

      @@ -766,14 +766,14 @@ c-side routine called octave-side routine called -

      27.3.14 Threads

      +

      26.3.14 Threads

      The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.

      -

      27.3.15 Memory management

      +

      26.3.15 Memory management

      @@ -807,14 +807,14 @@ The %newobject directive may be used to control this behavior for pointers retur In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).

      -

      27.3.16 STL support

      +

      26.3.16 STL support

      This is some skeleton support for various STL containers.

      -

      27.3.17 Matrix typemaps

      +

      26.3.17 Matrix typemaps

      diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html index 1dc8e7d2f..b7cdaf0e5 100644 --- a/Doc/Manual/Perl5.html +++ b/Doc/Manual/Perl5.html @@ -6,7 +6,7 @@ -

      28 SWIG and Perl5

      +

      27 SWIG and Perl5

        @@ -87,7 +87,7 @@ later. Earlier versions are problematic and SWIG generated extensions may not compile or run correctly.

        -

        28.1 Overview

        +

        27.1 Overview

        @@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other options are found near the end of the chapter.

        -

        28.2 Preliminaries

        +

        27.2 Preliminaries

        @@ -133,7 +133,7 @@ To build the module, you will need to compile the file example_wrap.c and link it with the rest of your program.

        -

        28.2.1 Getting the right header files

        +

        27.2.1 Getting the right header files

        @@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.

      -

      28.2.2 Compiling a dynamic module

      +

      27.2.2 Compiling a dynamic module

      @@ -198,7 +198,7 @@ the target should be named `example.so', `example.sl', or the appropriate dynamic module name on your system.

      -

      28.2.3 Building a dynamic module with MakeMaker

      +

      27.2.3 Building a dynamic module with MakeMaker

      @@ -232,7 +232,7 @@ the preferred approach to compilation. More information about MakeMaker can be found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen, and Randal Schwartz.

      -

      28.2.4 Building a static version of Perl

      +

      27.2.4 Building a static version of Perl

      @@ -301,7 +301,7 @@ added to it. Depending on your machine, you may need to link with additional libraries such as -lsocket, -lnsl, -ldl, etc.

      -

      28.2.5 Using the module

      +

      27.2.5 Using the module

      @@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to read the man pages).

      -

      28.2.6 Compilation problems and compiling with C++

      +

      27.2.6 Compilation problems and compiling with C++

      @@ -599,7 +599,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas any conflicting macros you find to swig-user mailing list.

      -

      28.2.7 Compiling for 64-bit platforms

      +

      27.2.7 Compiling for 64-bit platforms

      @@ -626,7 +626,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

      -

      28.3 Building Perl Extensions under Windows

      +

      27.3 Building Perl Extensions under Windows

      @@ -637,7 +637,7 @@ section assumes you are using SWIG with Microsoft Visual C++ although the procedure may be similar with other compilers.

      -

      28.3.1 Running SWIG from Developer Studio

      +

      27.3.1 Running SWIG from Developer Studio

      @@ -700,7 +700,7 @@ print "$a\n"; -

      28.3.2 Using other compilers

      +

      27.3.2 Using other compilers

      @@ -708,7 +708,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows. For general hints and suggestions refer to the Windows chapter.

      -

      28.4 The low-level interface

      +

      27.4 The low-level interface

      @@ -718,7 +718,7 @@ can be used to control your application. However, it is also used to construct more user-friendly proxy classes as described in the next section.

      -

      28.4.1 Functions

      +

      27.4.1 Functions

      @@ -741,7 +741,7 @@ use example; $a = &example::fact(2); -

      28.4.2 Global variables

      +

      27.4.2 Global variables

      @@ -811,7 +811,7 @@ extern char *path; // Declared later in the input -

      28.4.3 Constants

      +

      27.4.3 Constants

      @@ -838,7 +838,7 @@ $example::FOO = 2; # Error -

      28.4.4 Pointers

      +

      27.4.4 Pointers

      @@ -947,7 +947,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the SWIG and XS, this is no longer supported.

      -

      28.4.5 Structures

      +

      27.4.5 Structures

      @@ -1081,7 +1081,7 @@ void Bar_f_set(Bar *b, Foo *val) { -

      28.4.6 C++ classes

      +

      27.4.6 C++ classes

      @@ -1146,7 +1146,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox can be built using these low-level accessors. This is described shortly.

      -

      28.4.7 C++ classes and type-checking

      +

      27.4.7 C++ classes and type-checking

      @@ -1182,7 +1182,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece multiple inheritance is used).

      -

      28.4.8 C++ overloaded functions

      +

      27.4.8 C++ overloaded functions

      @@ -1226,7 +1226,7 @@ example::Spam_foo_d($s,3.14); Please refer to the "SWIG Basics" chapter for more information.

      -

      28.4.9 Operators

      +

      27.4.9 Operators

      @@ -1253,7 +1253,7 @@ The following C++ operators are currently supported by the Perl module:

    • operator or
    • -

      28.4.10 Modules and packages

      +

      27.4.10 Modules and packages

      @@ -1348,7 +1348,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar --> -

      28.5 Input and output parameters

      +

      27.5 Input and output parameters

      @@ -1567,7 +1567,7 @@ print "$c\n"; Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).

      -

      28.6 Exception handling

      +

      27.6 Exception handling

      @@ -1732,7 +1732,7 @@ This is still supported, but it is deprecated. The newer %exception di functionality, but it has additional capabilities that make it more powerful.

      -

      28.7 Remapping datatypes with typemaps

      +

      27.7 Remapping datatypes with typemaps

      @@ -1749,7 +1749,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Perl interface.

      -

      28.7.1 A simple typemap example

      +

      27.7.1 A simple typemap example

      @@ -1853,7 +1853,7 @@ example::count("e","Hello World"); -

      28.7.2 Perl5 typemaps

      +

      27.7.2 Perl5 typemaps

      @@ -1958,7 +1958,7 @@ Return of C++ member data (all languages). Check value of input parameter. -

      28.7.3 Typemap variables

      +

      27.7.3 Typemap variables

      @@ -2029,7 +2029,7 @@ properly assigned. The Perl name of the wrapper function being created. -

      28.7.4 Useful functions

      +

      27.7.4 Useful functions

      @@ -2098,7 +2098,7 @@ int sv_isa(SV *, char *0; -

      28.8 Typemap Examples

      +

      27.8 Typemap Examples

      @@ -2107,7 +2107,7 @@ might look at the files "perl5.swg" and "typemaps.i" in the SWIG library.

      -

      28.8.1 Converting a Perl5 array to a char **

      +

      27.8.1 Converting a Perl5 array to a char **

      @@ -2199,7 +2199,7 @@ print @$b,"\n"; # Print it out -

      28.8.2 Return values

      +

      27.8.2 Return values

      @@ -2228,7 +2228,7 @@ can be done using the EXTEND() macro as in : } -

      28.8.3 Returning values from arguments

      +

      27.8.3 Returning values from arguments

      @@ -2282,7 +2282,7 @@ print "multout(7,13) = @r\n"; ($x,$y) = multout(7,13); -

      28.8.4 Accessing array structure members

      +

      27.8.4 Accessing array structure members

      @@ -2345,7 +2345,7 @@ the "in" typemap in the previous section would be used to convert an to copy the converted array into a C data structure.

      -

      28.8.5 Turning Perl references into C pointers

      +

      27.8.5 Turning Perl references into C pointers

      @@ -2410,7 +2410,7 @@ print "$c\n"; -

      28.8.6 Pointer handling

      +

      27.8.6 Pointer handling

      @@ -2489,7 +2489,7 @@ For example: -

      28.9 Proxy classes

      +

      27.9 Proxy classes

      @@ -2505,7 +2505,7 @@ to the underlying code. This section describes the implementation details of the proxy interface.

      -

      28.9.1 Preliminaries

      +

      27.9.1 Preliminaries

      @@ -2527,7 +2527,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil high level wrappers. The wrappers, in turn, interact with the low-level procedural module.

      -

      28.9.2 Structure and class wrappers

      +

      27.9.2 Structure and class wrappers

      @@ -2653,7 +2653,7 @@ $v->DESTROY(); -

      28.9.3 Object Ownership

      +

      27.9.3 Object Ownership

      @@ -2740,7 +2740,7 @@ counting, garbage collection, or advanced features one might find in sophisticated languages.

      -

      28.9.4 Nested Objects

      +

      27.9.4 Nested Objects

      @@ -2793,7 +2793,7 @@ $p->{f}->{x} = 0.0; %${$p->{v}} = ( x=>0, y=>0, z=>0); -

      28.9.5 Proxy Functions

      +

      27.9.5 Proxy Functions

      @@ -2827,7 +2827,7 @@ This function replaces the original function, but operates in an identical manner.

      -

      28.9.6 Inheritance

      +

      27.9.6 Inheritance

      @@ -2903,7 +2903,7 @@ particular, inheritance of data members is extremely tricky (and I'm not even sure if it really works).

      -

      28.9.7 Modifying the proxy methods

      +

      27.9.7 Modifying the proxy methods

      @@ -2931,7 +2931,7 @@ public: }; -

      28.10 Adding additional Perl code

      +

      27.10 Adding additional Perl code

      diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html index d56edcb5f..6b654fde5 100644 --- a/Doc/Manual/Php.html +++ b/Doc/Manual/Php.html @@ -7,13 +7,14 @@ -

      29 SWIG and PHP

      +

      28 SWIG and PHP

      • Generating PHP Extensions
      • Basic PHP interface @@ -42,24 +43,21 @@ Caution: This chapter (and module!) is still under construction

        -

        -SWIG supports generating wrappers for PHP5. Support for PHP4 has been removed -as of SWIG 1.3.37. The PHP developers are no longer making new PHP4 releases, -and won't even be patching critical security issues after 2008-08-08, so it -doesn't make much sense for SWIG to continue to support PHP4 at this point. -If you need to continue to use PHP4, stick with SWIG 1.3.36. -

        -

        In this chapter, we discuss SWIG's support of PHP. The PHP module -was extensively rewritten in release 1.3.26, and support for generating -OO wrappers for PHP5 was added in 1.3.30. The PHP module works fairly -well, but currently does not implement all the +was extensively rewritten in release 1.3.26, and although it is +significantly more functional, it still does not implement all the features available in some of the other languages.

        -In order to use this module, you will need to have a copy of the PHP5 +The examples and test cases have been developed with PHP4. Release +1.3.30 added support for generating PHP5 class wrappers for C++ +libraries. +

        + +

        +In order to use this module, you will need to have a copy of the PHP4 or PHP5 include files to compile the SWIG generated files. If you installed PHP from a binary package, you may need to install a "php-dev" or "php-devel" package for these to be installed. You can find out where these files are @@ -69,7 +67,7 @@ your extension into php directly, you will need the complete PHP source tree available.

        -

        29.1 Generating PHP Extensions

        +

        28.1 Generating PHP Extensions

        @@ -90,7 +88,7 @@ you wish to statically link the extension into the php interpreter. The third file, example.php can be included by PHP scripts. It attempts to dynamically load the extension and contains extra php code specified -in the interface file. If wrapping C++ code with PHP classes, it will +in the interface file. If wrapping C++ code for PHP5, it will also contain PHP5 class wrappers.

        @@ -102,8 +100,7 @@ more detail in section 27.2.6.

        The usual (and recommended) way is to build the extension as a separate -dynamically loaded module (which is supported by all modern operating -systems). You can then specify that this be loaded +dynamically loaded module. You can then specify that this be loaded automatically in php.ini or load it explicitly for any script which needs it.

        @@ -113,16 +110,17 @@ It is also possible to rebuild PHP from source so that your module is statically linked into the php executable/library. This is a lot more work, and also requires a full rebuild of PHP to update your module, and it doesn't play nicely with package system. We don't recommend -this approach, or provide explicit support for it. +this approach, but if you really want to do this, the -phpfull +command line argument to swig may be of use - see below for details.

        -

        29.1.1 Building a loadable extension

        +

        28.1.1 Building a loadable extension

        To build your module as a dynamically loadable extension, use compilation commands like these (if you aren't using GCC, the commands will be different, -and there may be some variation between platforms - these commands should at +and there may be so variation between platforms - these commands should at least work for Linux though):

        @@ -131,7 +129,135 @@ least work for Linux though): gcc -shared example_wrap.o -o example.so
      -

      29.1.2 Using PHP Extensions

      +

      +There is a deprecated -make command line argument to swig which will +generate an additional file makefile which can usually build the +extension (at least on some UNIX platforms), but the Makefile generated isn't +very flexible, and the commands required are trivial so it is simpler to just +add them to your Makefile or other build system directly. We recommend that +you don't use -make and it's likely to be removed at some point. +

      + +

      28.1.2 Building extensions into PHP

      + + +

      +Note that we don't recommend this approach - it's cleaner and simpler to +use dynamically loadable modules, which are supported by all modern OSes. +Support for this may be discontinued entirely in the future. +

      + +

      +It is possible to rebuild PHP itself with your module statically linked +in. To do this, you can use the -phpfull command line option to +swig. Using this option will generate three additional files. The first +extra file, config.m4 contains the m4 and shell code needed to +enable the extension as part of the PHP build process. The second +extra file, Makefile.in contains the information needed to +build the final Makefile after substitutions. The third and final +extra file, CREDITS should contain the credits for the +extension. +

      + +

      +To build with phpize, after you have run swig you will need to run the +'phpize' command (installed as part of php) in the same +directory. This re-creates the php build environment in that +directory. It also creates a configure file which includes the shell +code from the config.m4 that was generated by SWIG, this configure +script will accept a command line argument to enable the extension to +be run (by default the command line argument is --enable-modulename, +however you can edit the config.m4 file before running phpize to +accept --with-modulename. You can also add extra tests in config.m4 to +check that a correct library version is installed or correct header +files are included, etc, but you must edit this file before running +phpize.) You can also get SWIG to generate simple extra tests for +libraries and header files for you. +

      + +
      +	swig -php -phpfull
      +
      + +

      +If you depend on source files not generated by SWIG, before generating +the configure file, you may need to edit the Makefile.in +file. This contains the names of the source files to compile (just the +wrapper file by default) and any additional libraries needed to be +linked in. If there are extra C files to compile, you will need to add +them to the Makefile.in, or add the names of libraries if they are +needed. In simple cases SWIG is pretty good at generating a complete +Makefile.in and config.m4 which need no further editing. +

      + +

      +You then run the configure script with the command line argument needed +to enable the extension. Then run make, which builds the extension. +The extension object file will be left in the modules sub directory, you can +move it to wherever it is convenient to call from your php script. +

      + +

      +When using -phpfull, swig also accepts the following +additional optional arguments: +

      +
        +
      • -withincs "<incs>" Adds include files to the config.m4 file. +
      • -withlibs "<libs>" Links with the specified libraries. +
      • -withc "<files>" Compiles and links the additional specified C files. +
      • -withcxx "<files>" Compiles and links the additional specified C++ files. +
      + +

      +After running swig with the -phpfull switch, you will be left with a shockingly +similar set of files to the previous build process. However you will then need +to move these files to a subdirectory within the php source tree, this subdirectory you will need to create under the ext directory, with the name of the extension (e.g. mkdir php-4.0.6/ext/modulename). +

      + +

      +After moving the files into this directory, you will need to run the 'buildall' +script in the php source directory. This rebuilds the configure script +and includes the extra command line arguments from the module you have added. +

      + +

      +Before running the generated configure file, you may need to edit the +Makefile.in. This contains the names of the source files to compile ( +just the wrapper file by default) and any additional libraries needed to +link in. If there are extra C files to compile you will need to add them +to the Makefile, or add the names of libraries if they are needed. +In most cases Makefile.in will be complete, especially if you +make use of -withlibs and -withincs +

      + +
      +	swig -php -phpfull -withlibs "xapian omquery" --withincs "om.h"
      +
      + +

      +Will include in the config.m4 and Makefile.in search for +libxapian.a or libxapian.so and search for +libomquery.a or libomquery.so as well as a +search for om.h. +

      + +

      +You then need to run the configure command and pass the necessary command +line arguments to enable your module (by default this is --enable-modulename, +but this can be changed by editing the config.m4 file in the modules directory +before running the buildall script. In addition, extra tests can be added to +the config.m4 file to ensure the correct libraries and header files are +installed.) +

      + +

      +Once configure has completed, you can run make to build php. If this all +compiles correctly, you should end up with a php executable/library +which contains your new module. You can test it with a php script which +does not have the 'dl' command as used above. +

      + +

      28.1.3 Using PHP Extensions

      @@ -162,7 +288,7 @@ attempts to do the dl() call for you: include("example.php"); -

      29.2 Basic PHP interface

      +

      28.2 Basic PHP interface

      @@ -172,7 +298,7 @@ possible for names of symbols in one extension module to clash with other symbols unless care is taken to %rename them.

      -

      29.2.1 Constants

      +

      28.2.1 Constants

      @@ -297,7 +423,7 @@ both point to the same value, without the case test taking place. ( Apologies, this paragraph needs rewriting to make some sense. )

      -

      29.2.2 Global Variables

      +

      28.2.2 Global Variables

      @@ -346,7 +472,7 @@ undefined. At this time SWIG does not support custom accessor methods.

      -

      29.2.3 Functions

      +

      28.2.3 Functions

      @@ -399,7 +525,7 @@ print $s; # The value of $s was not changed. --> -

      29.2.4 Overloading

      +

      28.2.4 Overloading

      @@ -413,7 +539,7 @@ Overloaded Functions and Methods. -

      29.2.5 Pointers and References

      +

      28.2.5 Pointers and References

      @@ -587,13 +713,24 @@ PHP in a number of ways: by using unset on an existing variable, or assigning NULL to a variable.

      -

      29.2.6 Structures and C++ classes

      +

      28.2.6 Structures and C++ classes

      -SWIG defaults to wrapping C++ structs and classes with PHP classes -unless "-noproxy" is specified. For PHP5, a PHP wrapper +SWIG defaults to wrapping C++ structs and classes with PHP classes. This +requires SWIG to generate different code for PHP4 and PHP5, so you must +specify which you want using -php4 or -php5 (currently +-php generates PHP4 class wrappers for compatibility with +SWIG 1.3.29 and earlier, but this may change in the future). +

      + +

      +PHP4 classes are implemented entirely using the Zend C API so +no additional php code is generated. For PHP5, a PHP wrapper class is generated which calls a set of flat functions wrapping the C++ class. +In many cases the PHP4 and PHP5 wrappers will behave the same way, +but the PHP5 ones make use of better PHP5's better OO functionality +where appropriate.

      @@ -617,7 +754,7 @@ struct Complex {

      -Would be used in the following way from PHP5: +Would be used in the following way from either PHP4 or PHP5:

      @@ -646,7 +783,7 @@ Would be used in the following way from PHP5:
       Member variables and methods are accessed using the -> operator.
       

      -

      29.2.6.1 Using -noproxy

      +

      28.2.6.1 Using -noproxy

      @@ -672,7 +809,7 @@ Complex_im_set($obj,$d); Complex_im_get($obj);

      -

      29.2.6.2 Constructors and Destructors

      +

      28.2.6.2 Constructors and Destructors

      @@ -713,13 +850,13 @@ the programmer can either reassign the variable or call unset($v)

      -

      29.2.6.3 Static Member Variables

      +

      28.2.6.3 Static Member Variables

      -Static member variables in C++ are not wrapped as such in PHP -as it does not appear to be possible to intercept accesses to such variables. -Therefore, static member variables are +Static member variables are not supported in PHP4, and it does not +appear to be possible to intercept accesses to static member variables +in PHP5. Therefore, static member variables are wrapped using a class function with the same name, which returns the current value of the class variable. For example

      @@ -756,7 +893,7 @@ Ko::threats(10); echo "There has now been " . Ko::threats() . " threats\n"; -

      29.2.6.4 Static Member Functions

      +

      28.2.6.4 Static Member Functions

      @@ -778,12 +915,12 @@ Ko::threats(); -

      29.2.7 PHP Pragmas, Startup and Shutdown code

      +

      28.2.7 PHP Pragmas, Startup and Shutdown code

      Note: Currently pragmas for PHP need to be specified using -%pragma(php) but also apply for PHP5! This is just a historical +%pragma(php4) but also apply for PHP5! This is just a historical oddity because SWIG's PHP support predates PHP5.

      @@ -795,7 +932,7 @@ object.
       %module example
      -%pragma(php) code="
      +%pragma(php4) code="
       # This code is inserted into example.php
       echo \"example.php execution\\n\";
       "
      @@ -817,7 +954,7 @@ the example.php file.
       
       
       %module example
      -%pragma(php) code="
      +%pragma(php4) code="
       include \"include.php\";
       "
       %pragma(php) include="include.php"   // equivalent.
      @@ -831,7 +968,7 @@ phpinfo() function.
       
       
       %module example;
      -%pragma(php) phpinfo="
      +%pragma(php4) phpinfo="
         zend_printf("An example of PHP support through SWIG\n");
         php_info_print_table_start();
         php_info_print_table_header(2, \"Directive\", \"Value\");
      diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html
      index a47d07865..3e39d4062 100644
      --- a/Doc/Manual/Pike.html
      +++ b/Doc/Manual/Pike.html
      @@ -6,7 +6,7 @@
       
       
       
      -

      30 SWIG and Pike

      +

      29 SWIG and Pike

        @@ -46,10 +46,10 @@ least, make sure you read the "SWIG Basics" chapter.

        -

        30.1 Preliminaries

        +

        29.1 Preliminaries

        -

        30.1.1 Running SWIG

        +

        29.1.1 Running SWIG

        @@ -94,7 +94,7 @@ can use the -o option:

        $ swig -pike -o pseudonym.c example.i
        -

        30.1.2 Getting the right header files

        +

        29.1.2 Getting the right header files

        @@ -114,7 +114,7 @@ You're looking for files with the names global.h, program.h and so on.

        -

        30.1.3 Using your module

        +

        29.1.3 Using your module

        @@ -129,10 +129,10 @@ Pike v7.4 release 10 running Hilfe v3.5 (Incremental Pike Frontend) (1) Result: 24

      -

      30.2 Basic C/C++ Mapping

      +

      29.2 Basic C/C++ Mapping

      -

      30.2.1 Modules

      +

      29.2.1 Modules

      @@ -143,7 +143,7 @@ concerned), SWIG's %module directive doesn't really have any significance.

      -

      30.2.2 Functions

      +

      29.2.2 Functions

      @@ -168,7 +168,7 @@ exactly as you'd expect it to: (1) Result: 24

      -

      30.2.3 Global variables

      +

      29.2.3 Global variables

      @@ -197,7 +197,7 @@ will result in two functions, Foo_get() and Foo_set(): (3) Result: 3.141590

      -

      30.2.4 Constants and enumerated types

      +

      29.2.4 Constants and enumerated types

      @@ -205,7 +205,7 @@ Enumerated types in C/C++ declarations are wrapped as Pike constants, not as Pike enums.

      -

      30.2.5 Constructors and Destructors

      +

      29.2.5 Constructors and Destructors

      @@ -213,7 +213,7 @@ Constructors are wrapped as create() methods, and destructors are wrapped as destroy() methods, for Pike classes.

      -

      30.2.6 Static Members

      +

      29.2.6 Static Members

      diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 5afa59243..a454c8124 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -81,7 +81,7 @@ Such information generally includes type declarations (e.g., typedef) a C++ classes that might be used as base-classes for class declarations in the interface. The use of %import is also important when SWIG is used to generate extensions as a collection of related modules. This is an advanced topic and is described -in later in the Working with Modules chapter. +in a later chapter.

      @@ -107,10 +107,7 @@ SWIGWIN Defined when running SWIG under Windows SWIG_VERSION Hexadecimal number containing SWIG version, such as 0x010311 (corresponding to SWIG-1.3.11). -SWIGALLEGROCL Defined when using Allegro CL -SWIGCFFI Defined when using CFFI SWIGCHICKEN Defined when using CHICKEN -SWIGCLISP Defined when using CLISP SWIGCSHARP Defined when using C# SWIGGUILE Defined when using Guile SWIGJAVA Defined when using Java @@ -118,15 +115,17 @@ SWIGLUA Defined when using Lua SWIGMODULA3 Defined when using Modula-3 SWIGMZSCHEME Defined when using Mzscheme SWIGOCAML Defined when using Ocaml -SWIGOCTAVE Defined when using Octave SWIGPERL Defined when using Perl +SWIGPERL5 Defined when using Perl5 SWIGPHP Defined when using PHP +SWIGPHP4 Defined when using PHP4 +SWIGPHP5 Defined when using PHP5 SWIGPIKE Defined when using Pike SWIGPYTHON Defined when using Python -SWIGR Defined when using R SWIGRUBY Defined when using Ruby SWIGSEXP Defined when using S-expressions SWIGTCL Defined when using Tcl +SWIGTCL8 Defined when using Tcl8.0 SWIGXML Defined when using XML diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index f4867b69d..62b72fabf 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -6,7 +6,7 @@ -

      31 SWIG and Python

      +

      30 SWIG and Python

      @@ -119,9 +113,9 @@

      This chapter describes SWIG's support of Python. SWIG is compatible -with most recent Python versions including Python 3.0 and Python 2.6, -as well as older versions dating back to Python 2.0. For the best results, -consider using Python 2.3 or newer. +with most recent Python versions including Python 2.2 as well as older +versions dating back to Python 1.5.2. For the best results, consider using Python +2.0 or newer.

      @@ -131,7 +125,7 @@ very least, make sure you read the "SWIG Basics" chapter.

      -

      31.1 Overview

      +

      30.1 Overview

      @@ -158,10 +152,10 @@ described followed by a discussion of low-level implementation details.

      -

      31.2 Preliminaries

      +

      30.2 Preliminaries

      -

      31.2.1 Running SWIG

      +

      30.2.1 Running SWIG

      @@ -259,7 +253,7 @@ The following sections have further practical examples and details on how you might go about compiling and using the generated files.

      -

      31.2.2 Using distutils

      +

      30.2.2 Using distutils

      @@ -351,7 +345,7 @@ This same approach works on all platforms if the appropriate compiler is install can even build extensions to the standard Windows Python using MingGW)

      -

      31.2.3 Hand compiling a dynamic module

      +

      30.2.3 Hand compiling a dynamic module

      @@ -399,7 +393,7 @@ module actually consists of two files; socket.py and

      -

      31.2.4 Static linking

      +

      30.2.4 Static linking

      @@ -478,7 +472,7 @@ If using static linking, you might want to rely on a different approach (perhaps using distutils).

      -

      31.2.5 Using your module

      +

      30.2.5 Using your module

      @@ -635,7 +629,7 @@ system configuration (this requires root access and you will need to read the man pages).

      -

      31.2.6 Compilation of C++ extensions

      +

      30.2.6 Compilation of C++ extensions

      @@ -734,7 +728,7 @@ erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

      -

      31.2.7 Compiling for 64-bit platforms

      +

      30.2.7 Compiling for 64-bit platforms

      @@ -771,7 +765,7 @@ and -m64 allow you to choose the desired binary format for your python extension.

      -

      31.2.8 Building Python Extensions under Windows

      +

      30.2.8 Building Python Extensions under Windows

      @@ -880,7 +874,7 @@ SWIG Wiki.

      -

      31.3 A tour of basic C/C++ wrapping

      +

      30.3 A tour of basic C/C++ wrapping

      @@ -889,7 +883,7 @@ to your C/C++ code. Functions are wrapped as functions, classes are wrapped as This section briefly covers the essential aspects of this wrapping.

      -

      31.3.1 Modules

      +

      30.3.1 Modules

      @@ -902,7 +896,7 @@ module name, make sure you don't use the same name as a built-in Python command or standard module name.

      -

      31.3.2 Functions

      +

      30.3.2 Functions

      @@ -926,7 +920,7 @@ like you think it does: >>> -

      31.3.3 Global variables

      +

      30.3.3 Global variables

      @@ -1064,7 +1058,7 @@ that starts with a leading underscore. SWIG does not create cvar if there are no global variables in a module.

      -

      31.3.4 Constants and enums

      +

      30.3.4 Constants and enums

      @@ -1104,7 +1098,7 @@ other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.

      -

      31.3.5 Pointers

      +

      30.3.5 Pointers

      @@ -1245,7 +1239,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

      -

      31.3.6 Structures

      +

      30.3.6 Structures

      @@ -1434,7 +1428,7 @@ everything works just like you would expect. For example: -

      31.3.7 C++ classes

      +

      30.3.7 C++ classes

      @@ -1523,7 +1517,7 @@ they are accessed through cvar like this: -

      31.3.8 C++ inheritance

      +

      30.3.8 C++ inheritance

      @@ -1578,7 +1572,7 @@ then the function spam() accepts Foo * or a pointer to any cla It is safe to use multiple inheritance with SWIG.

      -

      31.3.9 Pointers, references, values, and arrays

      +

      30.3.9 Pointers, references, values, and arrays

      @@ -1639,7 +1633,7 @@ treated as a returning value, and it will follow the same allocation/deallocation process.

      -

      31.3.10 C++ overloaded functions

      +

      30.3.10 C++ overloaded functions

      @@ -1762,7 +1756,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

      -

      31.3.11 C++ operators

      +

      30.3.11 C++ operators

      @@ -1851,7 +1845,7 @@ Also, be aware that certain operators don't map cleanly to Python. For instance overloaded assignment operators don't map to Python semantics and will be ignored.

      -

      31.3.12 C++ namespaces

      +

      30.3.12 C++ namespaces

      @@ -1918,7 +1912,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

      -

      31.3.13 C++ templates

      +

      30.3.13 C++ templates

      @@ -1972,7 +1966,7 @@ Some more complicated examples will appear later.

      -

      31.3.14 C++ Smart Pointers

      +

      30.3.14 C++ Smart Pointers

      @@ -2057,7 +2051,7 @@ simply use the __deref__() method. For example: -

      31.3.15 C++ Reference Counted Objects (ref/unref)

      +

      30.3.15 C++ Reference Counted Objects (ref/unref)

      @@ -2219,7 +2213,7 @@ python releases the proxy instance.

      -

      31.4 Further details on the Python class interface

      +

      30.4 Further details on the Python class interface

      @@ -2232,7 +2226,7 @@ of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

      -

      31.4.1 Proxy classes

      +

      30.4.1 Proxy classes

      @@ -2321,7 +2315,7 @@ you can attach new Python methods to the class and you can even inherit from it by Python built-in types until Python 2.2).

      -

      31.4.2 Memory management

      +

      30.4.2 Memory management

      @@ -2513,7 +2507,7 @@ It is also possible to deal with situations like this using typemaps--an advanced topic discussed later.

      -

      31.4.3 Python 2.2 and classic classes

      +

      30.4.3 Python 2.2 and classic classes

      @@ -2550,7 +2544,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global function or through an instance (see the earlier section).

      -

      31.5 Cross language polymorphism

      +

      30.5 Cross language polymorphism

      @@ -2584,7 +2578,7 @@ proxy classes, director classes, and C wrapper functions takes care of all the cross-language method routing transparently.

      -

      31.5.1 Enabling directors

      +

      30.5.1 Enabling directors

      @@ -2677,7 +2671,7 @@ class MyFoo(mymodule.Foo): -

      31.5.2 Director classes

      +

      30.5.2 Director classes

      @@ -2759,7 +2753,7 @@ so there is no need for the extra overhead involved with routing the calls through Python.

      -

      31.5.3 Ownership and object destruction

      +

      30.5.3 Ownership and object destruction

      @@ -2826,7 +2820,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard references to the Foo objects remain in Python.

      -

      31.5.4 Exception unrolling

      +

      30.5.4 Exception unrolling

      @@ -2885,7 +2879,7 @@ Swig::DirectorMethodException is thrown, Python will register the exception as soon as the C wrapper function returns.

      -

      31.5.5 Overhead and code bloat

      +

      30.5.5 Overhead and code bloat

      @@ -2919,7 +2913,7 @@ directive) for only those methods that are likely to be extended in Python.

      -

      31.5.6 Typemaps

      +

      30.5.6 Typemaps

      @@ -2933,7 +2927,7 @@ need to be supported.

      -

      31.5.7 Miscellaneous

      +

      30.5.7 Miscellaneous

      @@ -2980,7 +2974,7 @@ methods that return const references.

      -

      31.6 Common customization features

      +

      30.6 Common customization features

      @@ -2993,7 +2987,7 @@ This section describes some common SWIG features that are used to improve your the interface to an extension module.

      -

      31.6.1 C/C++ helper functions

      +

      30.6.1 C/C++ helper functions

      @@ -3074,7 +3068,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps, customization features as covered in later sections.

      -

      31.6.2 Adding additional Python code

      +

      30.6.2 Adding additional Python code

      @@ -3223,7 +3217,7 @@ public: -

      31.6.3 Class extension with %extend

      +

      30.6.3 Class extension with %extend

      @@ -3312,7 +3306,7 @@ Vector(12,14,16) in any way---the extensions only show up in the Python interface.

      -

      31.6.4 Exception handling with %exception

      +

      30.6.4 Exception handling with %exception

      @@ -3438,7 +3432,7 @@ The language-independent exception.i library file can also be used to raise exceptions. See the SWIG Library chapter.

      -

      31.7 Tips and techniques

      +

      30.7 Tips and techniques

      @@ -3448,7 +3442,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques solving these problems.

      -

      31.7.1 Input and output parameters

      +

      30.7.1 Input and output parameters

      @@ -3661,7 +3655,7 @@ void foo(Bar *OUTPUT); may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.

      -

      31.7.2 Simple pointers

      +

      30.7.2 Simple pointers

      @@ -3730,7 +3724,7 @@ If you replace %pointer_functions() by %pointer_class(type,name)SWIG Library chapter for further details.

      -

      31.7.3 Unbounded C Arrays

      +

      30.7.3 Unbounded C Arrays

      @@ -3792,7 +3786,7 @@ well suited for applications in which you need to create buffers, package binary data, etc.

      -

      31.7.4 String handling

      +

      30.7.4 String handling

      @@ -3861,16 +3855,16 @@ If you need to return binary data, you might use the also be used to extra binary data from arbitrary pointers.

      -

      31.7.5 Arrays

      +

      30.7.5 Arrays

      -

      31.7.6 String arrays

      +

      30.7.6 String arrays

      -

      31.7.7 STL wrappers

      +

      30.7.7 STL wrappers

      -

      31.8 Typemaps

      +

      30.8 Typemaps

      @@ -3887,7 +3881,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Python interface or if you want to elevate your guru status.

      -

      31.8.1 What is a typemap?

      +

      30.8.1 What is a typemap?

      @@ -4003,7 +3997,7 @@ parameter is omitted): -

      31.8.2 Python typemaps

      +

      30.8.2 Python typemaps

      @@ -4044,7 +4038,7 @@ a look at the SWIG library version 1.3.20 or so.

      -

      31.8.3 Typemap variables

      +

      30.8.3 Typemap variables

      @@ -4115,7 +4109,7 @@ properly assigned. The Python name of the wrapper function being created. -

      31.8.4 Useful Python Functions

      +

      30.8.4 Useful Python Functions

      @@ -4243,7 +4237,7 @@ write me -

      31.9 Typemap Examples

      +

      30.9 Typemap Examples

      @@ -4252,7 +4246,7 @@ might look at the files "python.swg" and "typemaps.i" in the SWIG library.

      -

      31.9.1 Converting Python list to a char **

      +

      30.9.1 Converting Python list to a char **

      @@ -4332,7 +4326,7 @@ memory allocation is used to allocate memory for the array, the the C function.

      -

      31.9.2 Expanding a Python object into multiple arguments

      +

      30.9.2 Expanding a Python object into multiple arguments

      @@ -4411,7 +4405,7 @@ to supply the argument count. This is automatically set by the typemap code. F -

      31.9.3 Using typemaps to return arguments

      +

      30.9.3 Using typemaps to return arguments

      @@ -4500,7 +4494,7 @@ function can now be used as follows: >>> -

      31.9.4 Mapping Python tuples into small arrays

      +

      30.9.4 Mapping Python tuples into small arrays

      @@ -4549,7 +4543,7 @@ array, such an approach would not be recommended for huge arrays, but for small structures, this approach works fine.

      -

      31.9.5 Mapping sequences to C arrays

      +

      30.9.5 Mapping sequences to C arrays

      @@ -4638,7 +4632,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) { -

      31.9.6 Pointer handling

      +

      30.9.6 Pointer handling

      @@ -4735,7 +4729,7 @@ class object (if applicable). -

      31.10 Docstring Features

      +

      30.10 Docstring Features

      @@ -4763,7 +4757,7 @@ of your users much simpler.

      -

      31.10.1 Module docstring

      +

      30.10.1 Module docstring

      @@ -4797,7 +4791,7 @@ layout of controls on a panel, etc. to be loaded from an XML file." -

      31.10.2 %feature("autodoc")

      +

      30.10.2 %feature("autodoc")

      @@ -4824,7 +4818,7 @@ names, default values if any, and return type if any. There are also three options for autodoc controlled by the value given to the feature, described below. -

      31.10.2.1 %feature("autodoc", "0")

      +

      30.10.2.1 %feature("autodoc", "0")

      @@ -4853,7 +4847,7 @@ def function_name(*args, **kwargs): -

      31.10.2.2 %feature("autodoc", "1")

      +

      30.10.2.2 %feature("autodoc", "1")

      @@ -4878,7 +4872,7 @@ def function_name(*args, **kwargs): -

      31.10.2.3 %feature("autodoc", "docstring")

      +

      30.10.2.3 %feature("autodoc", "docstring")

      @@ -4897,7 +4891,7 @@ void GetPosition(int* OUTPUT, int* OUTPUT); -

      31.10.3 %feature("docstring")

      +

      30.10.3 %feature("docstring")

      @@ -4929,13 +4923,13 @@ with more than one line. -

      31.11 Python Packages

      +

      30.11 Python Packages

      Using the package option of the %module directive allows you to specify what Python package that the module will be -living in when installed. +living in when installed.

      @@ -4956,256 +4950,6 @@ and also in base class declarations, etc. if the package name is different than its own.

      -

      31.12 Python 3 Support

      - - -

      -SWIG is able to support Python 3.0. The wrapper code generated by -SWIG can be compiled with both Python 2.x or 3.0. Further more, by -passing the -py3 command line option to SWIG, wrapper code -with some Python 3 specific features can be generated (see below -subsections for details of these features). The -py3 option also -disables some incompatible features for Python 3, such as --classic. - -

      -There is a list of known-to-be-broken features in Python 3: -

      -
        -
      • No more support for FILE* typemaps, because PyFile_AsFile has been dropped - in Python 3.
      • -
      • The -apply command line option is removed and generating - code using apply() is no longer supported.
      • -
      - -

      -The following are Python 3.0 new features that are currently supported by -SWIG. -

      - -

      31.12.1 Function annotation

      - - -

      -The -py3 option will enable function annotation support. When used -SWIG is able to generate proxy method definitions like this: -

      - -
      -  def foo(self, bar : "int" = 0) -> "void" : ...
      -
      - -

      -Also, even if without passing SWIG the -py3 option, the parameter list -still could be generated: -

      - -
      -  def foo(self, bar = 0): ...
      -
      - -

      -But for overloaded function or method, the parameter list would fallback to -*args or self, *args, and **kwargs may be append -depend on whether you enabled the keyword argument. This fallback is due to -all overloaded functions share the same function in SWIG generated proxy class. -

      - -

      -For detailed usage of function annotation, see PEP 3107. -

      - -

      31.12.2 Buffer interface

      - - -

      -Buffer protocols were revised in Python 3. SWIG also gains a series of -new typemaps to support buffer interfaces. These typemap macros are -defined in pybuffer.i, which must be included in order to use them. -By using these typemaps, your wrapped function will be able to -accept any Python object that exposes a suitable buffer interface. -

      - -

      -For example, the get_path() function puts the path string -into the memory pointed to by its argument: -

      - -
      -void get_path(char *s);
      -
      - -

      -Then you can write a typemap like this: (the following example is -applied to both Python 3.0 and 2.6, since the bytearray type -is backported to 2.6. -

      - - -
      -%include <pybuffer.i>
      -%pybuffer_mutable_string(char *str);
      -void get_path(char *s);
      -
      - -

      -And then on the Python side the wrapped get_path could be used in this -way: -

      - -
      ->>> p = bytearray(10)
      ->>> get_path(p)
      ->>> print(p)
      -bytearray(b'/Foo/Bar/\x00')
      -
      - -

      -The macros defined in pybuffer.i are similar to those in -cstring.i: -

      - -

      -%pybuffer_mutable_binary(parm, size_parm) -

      - -
      - -

      -The macro can be used to generate a typemap which maps a buffer of an -object to a pointer provided by parm and a size argument -provided by size_parm. For example: -

      - -
      -%pybuffer_mutable_binary(char *str, size_t size);
      -...
      -int snprintf(char *str, size_t size, const char *format, ...);
      -
      - -

      -In Python: -

      - -
      ->>> buf = bytearray(6)
      ->>> snprintf(buf, "Hello world!")
      ->>> print(buf)
      -bytearray(b'Hello\x00')
      ->>> 
      -
      - -
      - -

      -%pybuffer_mutable_string(parm) -

      - -
      - -

      -This typemap macro requires the buffer to be a zero terminated string, -and maps the pointer of the buffer to parm. For example: -

      - -
      -%pybuffer_mutable_string(char *str);
      -...
      -size_t make_upper(char *str);
      -
      - -

      -In Python: -

      - -
      ->>> buf = bytearray(b'foo\x00')
      ->>> make_upper(buf)
      ->>> print(buf)
      -bytearray(b'FOO\x00')
      ->>>
      -
      - -

      -Both %pybuffer_mutable_binary and %pybuffer_mutable_string -require the provided buffer to be mutable, eg. they can accept a -bytearray type but can't accept an immutable byte -type. -

      - -
      - -

      -%pybuffer_binary(parm, size_parm) -

      - -
      - -

      -This macro maps an object's buffer to a pointer parm and a -size size_parm. It is similar to -%pybuffer_mutable_binary, except the -%pybuffer_binary an accept both mutable and immutable -buffers. As a result, the wrapped function should not modify the buffer. -

      - -
      - -

      -%pybuffer_string(parm) -

      - -
      - -

      -This macro maps an object's buffer as a string pointer parm. -It is similar to %pybuffer_mutable_string but the buffer -could be both mutable and immutable. And your function should not -modify the buffer. -

      - -
      - - -

      31.12.3 Abstract base classes

      - - -

      -By including pyabc.i and using the -py3 command -line option when calling SWIG, the proxy classes of the STL containers -will automatically gain an appropriate abstract base class. For -example, the following SWIG interface: -

      - -
      -%include <pyabc.i>
      -%include <std_map.i>
      -%include <std_list.i>
      -
      -namespace std {
      -  %template(Mapii) map<int, int>;
      -  %template(IntList) list<int>;
      -}
      -
      - -

      -will generate a Python proxy class Mapii inheriting from -collections.MutableMap and a proxy class IntList -inheriting from collections.MutableSequence. -

      - -

      -pyabc.i also provides a macro %pythonabc that could be -used to define an abstract base class for your own C++ class: -

      - -
      -%pythonabc(MySet, collections.MutableSet);
      -
      - -

      -For details of abstract base class, please see PEP 3119. -

      diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html index 0ed43fc52..3b37d53a0 100644 --- a/Doc/Manual/R.html +++ b/Doc/Manual/R.html @@ -6,7 +6,7 @@ -

      34 SWIG and R

      +

      33 SWIG and R

        @@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux with gcc. The R bindings also work on Microsoft Windows using Visual C++.

        -

        34.1 Bugs

        +

        33.1 Bugs

        @@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:

      • C Array wrappings
      -

      34.2 Using R and SWIG

      +

      33.2 Using R and SWIG

      @@ -99,7 +99,7 @@ Without it, inheritance of wrapped objects may fail. These two files can be loaded in any order

      -

      34.3 Precompiling large R files

      +

      33.3 Precompiling large R files

      In cases where the R file is large, one make save a lot of loading @@ -117,7 +117,7 @@ will save a large amount of loading time. -

      34.4 General policy

      +

      33.4 General policy

      @@ -126,7 +126,7 @@ wrapping over the underlying functions and rely on the R type system to provide R syntax.

      -

      34.5 Language conventions

      +

      33.5 Language conventions

      @@ -135,7 +135,7 @@ and [ are overloaded to allow for R syntax (one based indices and slices)

      -

      34.6 C++ classes

      +

      33.6 C++ classes

      @@ -147,7 +147,7 @@ keep track of the pointer object which removes the necessity for a lot of the proxy class baggage you see in other languages.

      -

      34.7 Enumerations

      +

      33.7 Enumerations

      diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 2070db0c0..9cd83d494 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -26,7 +26,7 @@ -

      32 SWIG and Ruby

      +

      31 SWIG and Ruby

        @@ -167,7 +167,7 @@ -

        32.1 Preliminaries

        +

        31.1 Preliminaries

        SWIG 1.3 is known to work with Ruby versions 1.6 and later. @@ -190,7 +190,7 @@ of Ruby.

        -

        32.1.1 Running SWIG

        +

        31.1.1 Running SWIG

        To build a Ruby module, run SWIG using the -ruby @@ -244,7 +244,7 @@ to compile this file and link it with the rest of your program.

        -

        32.1.2 Getting the right header files

        +

        31.1.2 Getting the right header files

        In order to compile the wrapper code, the compiler needs the ruby.h @@ -288,7 +288,7 @@ installed, you can run Ruby to find out. For example:

        -

        32.1.3 Compiling a dynamic module

        +

        31.1.3 Compiling a dynamic module

        Ruby extension modules are typically compiled into shared @@ -443,7 +443,7 @@ manual pages for your compiler and linker to determine the correct set of options. You might also check the SWIG Wiki for additional information.

        -

        32.1.4 Using your module

        +

        31.1.4 Using your module

        Ruby module names must be capitalized, @@ -498,7 +498,7 @@ begins with:

        -

        32.1.5 Static linking

        +

        31.1.5 Static linking

        An alternative approach to dynamic linking is to rebuild the @@ -519,7 +519,7 @@ finally rebuilding Ruby.

        -

        32.1.6 Compilation of C++ extensions

        +

        31.1.6 Compilation of C++ extensions

        On most machines, C++ extension modules should be linked @@ -571,7 +571,7 @@ extension, e.g.

        -

        32.2 Building Ruby Extensions under Windows 95/NT

        +

        31.2 Building Ruby Extensions under Windows 95/NT

        Building a SWIG extension to Ruby under Windows 95/NT is @@ -610,7 +610,7 @@ files.

        -

        32.2.1 Running SWIG from Developer Studio

        +

        31.2.1 Running SWIG from Developer Studio

        If you are developing your application within Microsoft @@ -752,7 +752,7 @@ directory, then run the Ruby script from the DOS/Command prompt:

        -

        32.3 The Ruby-to-C/C++ Mapping

        +

        31.3 The Ruby-to-C/C++ Mapping

        This section describes the basics of how SWIG maps C or C++ @@ -762,7 +762,7 @@ declarations in your SWIG interface files to Ruby constructs.

        -

        32.3.1 Modules

        +

        31.3.1 Modules

        The SWIG %module directive specifies @@ -931,7 +931,7 @@ Ruby's built-in names.

        -

        32.3.2 Functions

        +

        31.3.2 Functions

        Global functions are wrapped as Ruby module methods. For @@ -994,7 +994,7 @@ module that can be used like so:

        -

        32.3.3 Variable Linking

        +

        31.3.3 Variable Linking

        C/C++ global variables are wrapped as a pair of singleton @@ -1094,7 +1094,7 @@ effect until it is explicitly disabled using %mutable. -

        32.3.4 Constants

        +

        31.3.4 Constants

        C/C++ constants are wrapped as module constants initialized @@ -1138,7 +1138,7 @@ constant values, e.g.

        -

        32.3.5 Pointers

        +

        31.3.5 Pointers

        "Opaque" pointers to arbitrary C/C++ types (i.e. types that @@ -1190,7 +1190,7 @@ the Ruby nil object.

        -

        32.3.6 Structures

        +

        31.3.6 Structures

        C/C++ structs are wrapped as Ruby classes, with accessor @@ -1365,7 +1365,7 @@ pointers. For example,

        -

        32.3.7 C++ classes

        +

        31.3.7 C++ classes

        Like structs, C++ classes are wrapped by creating a new Ruby @@ -1451,7 +1451,7 @@ class. -

        32.3.8 C++ Inheritance

        +

        31.3.8 C++ Inheritance

        The SWIG type-checker is fully aware of C++ inheritance. @@ -1682,7 +1682,7 @@ Typing").

        -

        32.3.9 C++ Overloaded Functions

        +

        31.3.9 C++ Overloaded Functions

        C++ overloaded functions, methods, and constructors are @@ -1878,7 +1878,7 @@ and C++" chapter for more information about overloading.

        -

        32.3.10 C++ Operators

        +

        31.3.10 C++ Operators

        For the most part, overloaded operators are handled @@ -1959,7 +1959,7 @@ on operator overloading.

        -

        32.3.11 C++ namespaces

        +

        31.3.11 C++ namespaces

        SWIG is aware of C++ namespaces, but namespace names do not @@ -2035,7 +2035,7 @@ identical symbol names, well, then you get what you deserve.

        -

        32.3.12 C++ templates

        +

        31.3.12 C++ templates

        C++ templates don't present a huge problem for SWIG. However, @@ -2079,7 +2079,7 @@ directive. For example:

        -

        32.3.13 C++ Standard Template Library (STL)

        +

        31.3.13 C++ Standard Template Library (STL)

        On a related note, the standard SWIG library contains a @@ -2332,7 +2332,7 @@ chapter.

        -

        32.3.14 C++ STL Functors

        +

        31.3.14 C++ STL Functors

        Some containers in the STL allow you to modify their default @@ -2532,7 +2532,7 @@ b
        -

        32.3.15 C++ STL Iterators

        +

        31.3.15 C++ STL Iterators

        The STL is well known for the use of iterators.  There @@ -2743,7 +2743,7 @@ i
        -

        32.3.16 C++ Smart Pointers

        +

        31.3.16 C++ Smart Pointers

        In certain C++ programs, it is common to use classes that @@ -2868,7 +2868,7 @@ method. For example:

        -

        32.3.17 Cross-Language Polymorphism

        +

        31.3.17 Cross-Language Polymorphism

        SWIG's Ruby module supports cross-language polymorphism @@ -2881,7 +2881,7 @@ using this feature with Ruby.

        -

        32.3.17.1 Exception Unrolling

        +

        31.3.17.1 Exception Unrolling

        Whenever a C++ director class routes one of its virtual @@ -2919,7 +2919,7 @@ caught here and a C++ exception is raised in its place.

        -

        32.4 Naming

        +

        31.4 Naming

        Ruby has several common naming conventions. Constants are @@ -3015,7 +3015,7 @@ planned to become the default option in future releases.

        -

        32.4.1 Defining Aliases

        +

        31.4.1 Defining Aliases

        It's a fairly common practice in the Ruby built-ins and @@ -3107,7 +3107,7 @@ Features") for more details).

        -

        32.4.2 Predicate Methods

        +

        31.4.2 Predicate Methods

        Ruby methods that return a boolean value and end in a @@ -3196,7 +3196,7 @@ Features") for more details).

        -

        32.4.3 Bang Methods

        +

        31.4.3 Bang Methods

        Ruby methods that modify an object in-place and end in an @@ -3260,7 +3260,7 @@ Features") for more details).

        -

        32.4.4 Getters and Setters

        +

        31.4.4 Getters and Setters

        Often times a C++ library will expose properties through @@ -3330,7 +3330,7 @@ methods to be exposed in Ruby as value and value=. -

        32.5 Input and output parameters

        +

        31.5 Input and output parameters

        A common problem in some C programs is handling parameters @@ -3581,10 +3581,10 @@ of %apply

        -

        32.6 Exception handling

        +

        31.6 Exception handling

        -

        32.6.1 Using the %exception directive

        +

        31.6.1 Using the %exception directive

        The SWIG %exception directive can be @@ -3679,7 +3679,7 @@ Features for more examples.

        -

        32.6.2 Handling Ruby Blocks

        +

        31.6.2 Handling Ruby Blocks

        One of the highlights of Ruby and most of its standard library @@ -3860,7 +3860,7 @@ RUBY_YIELD_SELF );

        For more information on typemaps, see Typemaps.

        -

        32.6.3 Raising exceptions

        +

        31.6.3 Raising exceptions

        There are three ways to raise exceptions from C++ code to @@ -4621,7 +4621,7 @@ the built-in Ruby exception types.

        -

        32.6.4 Exception classes

        +

        31.6.4 Exception classes

        Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass @@ -4679,7 +4679,7 @@ providing for a more natural integration between C++ code and Ruby code.

        -

        32.7 Typemaps

        +

        31.7 Typemaps

        This section describes how you can modify SWIG's default @@ -4702,7 +4702,7 @@ of the primitive C-Ruby interface.

        -

        32.7.1 What is a typemap?

        +

        31.7.1 What is a typemap?

        A typemap is nothing more than a code generation rule that is @@ -4964,7 +4964,7 @@ to be used as follows (notice how the length parameter is omitted):

        -

        32.7.2 Typemap scope

        +

        31.7.2 Typemap scope

        Once defined, a typemap remains in effect for all of the @@ -5012,7 +5012,7 @@ where the class itself is defined. For example:

        -

        32.7.3 Copying a typemap

        +

        31.7.3 Copying a typemap

        A typemap is copied by using assignment. For example:

        @@ -5114,7 +5114,7 @@ rules as for -

        32.7.4 Deleting a typemap

        +

        31.7.4 Deleting a typemap

        A typemap can be deleted by simply defining no code. For @@ -5166,7 +5166,7 @@ typemaps immediately after the clear operation.

        -

        32.7.5 Placement of typemaps

        +

        31.7.5 Placement of typemaps

        Typemap declarations can be declared in the global scope, @@ -5250,7 +5250,7 @@ string -

        32.7.6 Ruby typemaps

        +

        31.7.6 Ruby typemaps

        The following list details all of the typemap methods that @@ -5260,7 +5260,7 @@ can be used by the Ruby module:

        -

        32.7.6.1  "in" typemap

        +

        31.7.6.1  "in" typemap

        Converts Ruby objects to input @@ -5503,7 +5503,7 @@ arguments to be specified. For example:

        -

        32.7.6.2 "typecheck" typemap

        +

        31.7.6.2 "typecheck" typemap

        The "typecheck" typemap is used to support overloaded @@ -5544,7 +5544,7 @@ on "Typemaps and Overloading."

        -

        32.7.6.3  "out" typemap

        +

        31.7.6.3  "out" typemap

        Converts return value of a C function @@ -5776,7 +5776,7 @@ version of the C datatype matched by the typemap. -

        32.7.6.4 "arginit" typemap

        +

        31.7.6.4 "arginit" typemap

        The "arginit" typemap is used to set the initial value of a @@ -5801,7 +5801,7 @@ applications. For example:

        -

        32.7.6.5 "default" typemap

        +

        31.7.6.5 "default" typemap

        The "default" typemap is used to turn an argument into a @@ -5843,7 +5843,7 @@ default argument wrapping.

        -

        32.7.6.6 "check" typemap

        +

        31.7.6.6 "check" typemap

        The "check" typemap is used to supply value checking code @@ -5867,7 +5867,7 @@ arguments have been converted. For example:

        -

        32.7.6.7 "argout" typemap

        +

        31.7.6.7 "argout" typemap

        The "argout" typemap is used to return values from arguments. @@ -6025,7 +6025,7 @@ some function like SWIG_Ruby_AppendOutput.

        -

        32.7.6.8 "freearg" typemap

        +

        31.7.6.8 "freearg" typemap

        The "freearg" typemap is used to cleanup argument data. It is @@ -6061,7 +6061,7 @@ abort prematurely.

        -

        32.7.6.9 "newfree" typemap

        +

        31.7.6.9 "newfree" typemap

        The "newfree" typemap is used in conjunction with the %newobject @@ -6092,7 +6092,7 @@ ownership and %newobject for further details.

        -

        32.7.6.10 "memberin" typemap

        +

        31.7.6.10 "memberin" typemap

        The "memberin" typemap is used to copy data from an @@ -6125,7 +6125,7 @@ other objects.

        -

        32.7.6.11 "varin" typemap

        +

        31.7.6.11 "varin" typemap

        The "varin" typemap is used to convert objects in the target @@ -6136,7 +6136,7 @@ This is implementation specific.

        -

        32.7.6.12 "varout" typemap

        +

        31.7.6.12 "varout" typemap

        The "varout" typemap is used to convert a C/C++ object to an @@ -6147,7 +6147,7 @@ This is implementation specific.

        -

        32.7.6.13 "throws" typemap

        +

        31.7.6.13 "throws" typemap

        The "throws" typemap is only used when SWIG parses a C++ @@ -6206,7 +6206,7 @@ handling with %exception section.

        -

        32.7.6.14 directorin typemap

        +

        31.7.6.14 directorin typemap

        Converts C++ objects in director @@ -6460,7 +6460,7 @@ referring to the class itself. -

        32.7.6.15 directorout typemap

        +

        31.7.6.15 directorout typemap

        Converts Ruby objects in director @@ -6720,7 +6720,7 @@ exception.
        -

        32.7.6.16 directorargout typemap

        +

        31.7.6.16 directorargout typemap

        Output argument processing in director @@ -6960,7 +6960,7 @@ referring to the instance of the class itself -

        32.7.6.17 ret typemap

        +

        31.7.6.17 ret typemap

        Cleanup of function return values @@ -6970,7 +6970,7 @@ referring to the instance of the class itself -

        32.7.6.18 globalin typemap

        +

        31.7.6.18 globalin typemap

        Setting of C global variables @@ -6980,7 +6980,7 @@ referring to the instance of the class itself -

        32.7.7 Typemap variables

        +

        31.7.7 Typemap variables

        @@ -7090,7 +7090,7 @@ being created.

      -

      32.7.8 Useful Functions

      +

      31.7.8 Useful Functions

      When you write a typemap, you usually have to work directly @@ -7114,7 +7114,7 @@ across multiple languages.

      -

      32.7.8.1 C Datatypes to Ruby Objects

      +

      31.7.8.1 C Datatypes to Ruby Objects

      @@ -7170,7 +7170,7 @@ SWIG_From_float(float) -

      32.7.8.2 Ruby Objects to C Datatypes

      +

      31.7.8.2 Ruby Objects to C Datatypes

      Here, while the Ruby versions return the value directly, the SWIG @@ -7259,7 +7259,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -

      32.7.8.3 Macros for VALUE

      +

      31.7.8.3 Macros for VALUE

      RSTRING_LEN(str)

      @@ -7322,7 +7322,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input -

      32.7.8.4 Exceptions

      +

      31.7.8.4 Exceptions

      void rb_raise(VALUE exception, const char *fmt, @@ -7489,7 +7489,7 @@ arguments are interpreted as with printf().

      -

      32.7.8.5 Iterators

      +

      31.7.8.5 Iterators

      void rb_iter_break()

      @@ -7591,7 +7591,7 @@ VALUE), VALUE value)

      -

      32.7.9 Typemap Examples

      +

      31.7.9 Typemap Examples

      This section includes a few examples of typemaps. For more @@ -7602,7 +7602,7 @@ directory.

      -

      32.7.10 Converting a Ruby array to a char **

      +

      31.7.10 Converting a Ruby array to a char **

      A common problem in many C programs is the processing of @@ -7657,7 +7657,7 @@ after the execution of the C function.

      -

      32.7.11 Collecting arguments in a hash

      +

      31.7.11 Collecting arguments in a hash

      Ruby's solution to the "keyword arguments" capability of some @@ -7936,7 +7936,7 @@ directory of the SWIG distribution.

      -

      32.7.12 Pointer handling

      +

      31.7.12 Pointer handling

      Occasionally, it might be necessary to convert pointer values @@ -8035,7 +8035,7 @@ For example:

      -

      32.7.12.1 Ruby Datatype Wrapping

      +

      31.7.12.1 Ruby Datatype Wrapping

      VALUE Data_Wrap_Struct(VALUE class, void @@ -8086,7 +8086,7 @@ and assigns that pointer to ptr.

      -

      32.7.13 Example: STL Vector to Ruby Array

      +

      31.7.13 Example: STL Vector to Ruby Array

      Another use for macros and type maps is to create a Ruby array @@ -8195,7 +8195,7 @@ the C++ Standard Template Library.
      -

      32.8 Docstring Features

      +

      31.8 Docstring Features

      @@ -8256,7 +8256,7 @@ generate ri documentation from a c wrap file, you could do:

      -

      32.8.1 Module docstring

      +

      31.8.1 Module docstring

      @@ -8307,7 +8307,7 @@ macro. For example: -

      32.8.2 %feature("autodoc")

      +

      31.8.2 %feature("autodoc")

      Since SWIG does know everything about the function it wraps, @@ -8336,7 +8336,7 @@ feature, described below. -

      32.8.2.1 %feature("autodoc", "0")

      +

      31.8.2.1 %feature("autodoc", "0")

      @@ -8384,7 +8384,7 @@ Then Ruby code like this will be generated: -

      32.8.2.2 %feature("autodoc", "1")

      +

      31.8.2.2 %feature("autodoc", "1")

      @@ -8416,7 +8416,7 @@ this: -

      32.8.2.3 %feature("autodoc", "2")

      +

      31.8.2.3 %feature("autodoc", "2")

      @@ -8432,7 +8432,7 @@ this: -

      32.8.2.4 %feature("autodoc", "3")

      +

      31.8.2.4 %feature("autodoc", "3")

      @@ -8460,7 +8460,7 @@ this: -

      32.8.2.5 %feature("autodoc", "docstring")

      +

      31.8.2.5 %feature("autodoc", "docstring")

      @@ -8488,7 +8488,7 @@ generated string. For example: -

      32.8.3 %feature("docstring")

      +

      31.8.3 %feature("docstring")

      @@ -8503,10 +8503,10 @@ docstring and they are output together.

      -

      32.9 Advanced Topics

      +

      31.9 Advanced Topics

      -

      32.9.1 Operator overloading

      +

      31.9.1 Operator overloading

      SWIG allows operator overloading with, by using the %extend @@ -9523,7 +9523,7 @@ parses the expression a != b as !(a == b). -

      32.9.2 Creating Multi-Module Packages

      +

      31.9.2 Creating Multi-Module Packages

      The chapter on Working @@ -9704,7 +9704,7 @@ initialized:

      -

      32.9.3 Specifying Mixin Modules

      +

      31.9.3 Specifying Mixin Modules

      The Ruby language doesn't support multiple inheritance, but @@ -9802,7 +9802,7 @@ Features") for more details).

      -

      32.10 Memory Management

      +

      31.10 Memory Management

      One of the most common issues in generating SWIG bindings for @@ -9849,7 +9849,7 @@ understanding of how the underlying library manages memory.

      -

      32.10.1 Mark and Sweep Garbage Collector

      +

      31.10.1 Mark and Sweep Garbage Collector

      Ruby uses a mark and sweep garbage collector. When the garbage @@ -9897,7 +9897,7 @@ this memory.

      -

      32.10.2 Object Ownership

      +

      31.10.2 Object Ownership

      As described above, memory management depends on clearly @@ -10124,7 +10124,7 @@ classes is:

      -

      32.10.3 Object Tracking

      +

      31.10.3 Object Tracking

      The remaining parts of this section will use the class library @@ -10338,7 +10338,7 @@ methods.

      -

      32.10.4 Mark Functions

      +

      31.10.4 Mark Functions

      With a bit more testing, we see that our class library still @@ -10456,7 +10456,7 @@ test suite.

      -

      32.10.5 Free Functions

      +

      31.10.5 Free Functions

      By default, SWIG creates a "free" function that is called when @@ -10567,7 +10567,7 @@ existing Ruby object to the destroyed C++ object and raise an exception.

      -
      %module example

      %{
      #include "example.h"
      %}

      /* Specify that ownership is transferred to the zoo
      when calling add_animal */
      %apply SWIGTYPE *DISOWN { Animal* animal };

      /* Track objects */
      %trackobjects;

      /* Specify the mark function */
      %freefunc Zoo "free_Zoo";

      %include "example.h"

      %header %{
      static void free_Zoo(void* ptr) {
      Zoo* zoo = (Zoo*) ptr;

      /* Loop over each animal */
      int count = zoo->get_num_animals();

      for(int i = 0; i < count; ++i) {
      /* Get an animal */
      Animal* animal = zoo->get_animal(i);

      /* Unlink the Ruby object from the C++ object */
      SWIG_RubyUnlinkObjects(animal);

      /* Now remove the tracking for this animal */
      SWIG_RubyRemoveTracking(animal);
      }

      /* Now call SWIG_RubyRemoveTracking for the zoo */
      SWIG_RubyRemoveTracking(ptr);

      /* Now free the zoo which will free the animals it contains */
      delete zoo;
      }
      %}
      +
      %module example

      %{
      #include "example.h"
      %}

      /* Specify that ownership is transferred to the zoo
      when calling add_animal */
      %apply SWIGTYPE *DISOWN { Animal* animal };

      /* Track objects */
      %trackobjects;

      /* Specify the mark function */
      %freefunc Zoo "free_Zoo";

      %include "example.h"

      %header %{
      static void free_Zoo(void* ptr) {
      Zoo* zoo = (Zoo*) ptr;

      /* Loop over each animal */
      int count = zoo->get_num_animals();

      for(int i = 0; i < count; ++i) {
      /* Get an animal */
      Animal* animal = zoo->get_animal(i);

      /* Unlink the Ruby object from the C++ object */
      SWIG_RubyUnlinkObjects(animal);

      /* Now remove the tracking for this animal */
      SWIG_RubyRemoveTracking(animal);
      }

      /* Now call SWIG_RemoveMapping for the zoo */
      SWIG_RemoveMapping(ptr);

      /* Now free the zoo which will free the animals it contains */
      delete zoo;
      }
      %}
      @@ -10611,7 +10611,7 @@ been freed, and thus raises a runtime exception.

      -

      32.10.6 Embedded Ruby and the C++ Stack

      +

      31.10.6 Embedded Ruby and the C++ Stack

      As has been said, the Ruby GC runs and marks objects before diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index d52f0441c..c22d81c07 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -53,7 +53,7 @@

    • Character strings and structures
    • Array members
    • Structure data members -
    • C constructors and destructors +
    • C constructors and destructors
    • Adding member functions to C structures
    • Nested structures
    • Other things to note about structure wrapping @@ -120,7 +120,8 @@ can be obtained by typing swig -help or swig -mzscheme Generate Mzscheme wrappers -ocaml Generate Ocaml wrappers -perl Generate Perl wrappers --php Generate PHP wrappers +-php4 Generate PHP4 wrappers +-php5 Generate PHP5 wrappers -pike Generate Pike wrappers -python Generate Python wrappers -r Generate R (aka GNU S) wrappers @@ -139,7 +140,6 @@ can be obtained by typing swig -help or swig -lfile Include a SWIG library file. -module name Set the name of the SWIG module -o outfile Name of output file --outcurrentdir Set default output dir to current dir instead of input file's path -outdir dir Set language specific files output directory -swiglib Show location of SWIG library -version Show SWIG version number @@ -224,7 +224,7 @@ The C/C++ output file created by SWIG often contains everything that is needed to construct a extension module for the target scripting language. SWIG is not a stub compiler nor is it usually necessary to edit the output file (and if you look at the output, -you probably won't want to). To build the final extension module, the +you probably won't want to). To build the final extension module, the SWIG output file is compiled and linked with the rest of your C/C++ program to create a shared library.

      @@ -232,7 +232,7 @@ program to create a shared library.

      Many target languages will also generate proxy class files in the target language. The default output directory for these language -specific files is the same directory as the generated C/C++ file. This +specific files is the same directory as the generated C/C++ file. This can can be modified using the -outdir option. For example:

      @@ -247,17 +247,6 @@ cppfiles/example_wrap.cpp pyfiles/example.py
    • -

      -If the -outcurrentdir option is used (without -o) -then SWIG behaves like a typical C/C++ -compiler and the default output directory is then the current directory. Without -this option the default output directory is the path to the input file. -If -o and --outcurrentdir are used together, -outcurrentdir is effectively ignored -as the output directory for the language files is the same directory as the -generated C/C++ file if not overidden with -outdir. -

      -

      5.1.3 Comments

      @@ -2230,13 +2219,13 @@ void Foo_w_set(FOO *f, WORD value) {

      -Compatibility Note: SWIG-1.3.11 and earlier releases transformed all non-primitive member datatypes -to pointers. Starting in SWIG-1.3.12, this transformation only occurs if a datatype is known to be a structure, -class, or union. This is unlikely to break existing code. However, if you need to tell SWIG that an undeclared +Compatibility Note: SWIG-1.3.11 and earlier releases transformed all non-primitive member datatypes +to pointers. Starting in SWIG-1.3.12, this transformation only occurs if a datatype is known to be a structure, +class, or union. This is unlikely to break existing code. However, if you need to tell SWIG that an undeclared datatype is really a struct, simply use a forward struct declaration such as "struct Foo;".

      -

      5.5.5 C constructors and destructors

      +

      5.5.5 C constructors and destructors

      @@ -2293,7 +2282,7 @@ struct Bar { // Default constructor generated. Since ignoring the implicit or default destructors most of the times produce memory leaks, SWIG will always try to generate them. If needed, however, you can selectively disable the generation of the -default/implicit destructor by using %nodefaultdtor +default/implicit destructor by using %nodefaultdtor

      @@ -2737,16 +2726,11 @@ the module upon loading.

      Code is inserted into the appropriate code section by using one -of the code insertion directives listed below. The order of the sections in -the wrapper file is as shown: +of the following code insertion directives:

      -%begin %{
      -   ... code in begin section ...
      -%}
      -
       %runtime %{
          ... code in runtime section ...
       %}
      @@ -2767,12 +2751,10 @@ the wrapper file is as shown:
       
       

      The bare %{ ... %} directive is a shortcut that is the same as -%header %{ ... %}. +%header %{ ... %}.

      -The %begin section is effectively empty as it just contains the SWIG banner by default. -This section is provided as a way for users to insert code at the top of the wrapper file before any other code is generated. Everything in a code insertion block is copied verbatim into the output file and is not parsed by SWIG. Most SWIG input files have at least one such block to include header files and support C code. Additional code blocks may be placed anywhere in a diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 789efc129..5406f44ea 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

      SWIG-1.3 Development Documentation

      -Last update : SWIG-1.3.40 (in progress) +Last update : SWIG-1.3.37 (in progress)

      Sections

      @@ -35,7 +35,6 @@ to help!).
    • Variable length arguments
    • Warning messages
    • Working with Modules
    • -
    • Using SWIG with ccache
    • Language Module Documentation

      diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index b36395cab..e837a5b17 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -6,7 +6,7 @@ -

      33 SWIG and Tcl

      +

      32 SWIG and Tcl

        @@ -82,7 +82,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but this is no longer supported.

        -

        33.1 Preliminaries

        +

        32.1 Preliminaries

        @@ -108,7 +108,7 @@ build a Tcl extension module. To finish building the module, you need to compile this file and link it with the rest of your program.

        -

        33.1.1 Getting the right header files

        +

        32.1.1 Getting the right header files

        @@ -126,7 +126,7 @@ this is the case, you should probably make a symbolic link so that tcl.h -

        33.1.2 Compiling a dynamic module

        +

        32.1.2 Compiling a dynamic module

        @@ -161,7 +161,7 @@ The name of the module is specified using the %module directive or the -module command line option.

        -

        33.1.3 Static linking

        +

        32.1.3 Static linking

        @@ -227,7 +227,7 @@ minimal in most situations (and quite frankly not worth the extra hassle in the opinion of this author).

        -

        33.1.4 Using your module

        +

        32.1.4 Using your module

        @@ -355,7 +355,7 @@ to the default system configuration (this requires root access and you will need the man pages).

        -

        33.1.5 Compilation of C++ extensions

        +

        32.1.5 Compilation of C++ extensions

        @@ -438,7 +438,7 @@ erratic program behavior. If working with lots of software components, you might want to investigate using a more formal standard such as COM.

        -

        33.1.6 Compiling for 64-bit platforms

        +

        32.1.6 Compiling for 64-bit platforms

        @@ -465,7 +465,7 @@ also introduce problems on platforms that support more than one linking standard (e.g., -o32 and -n32 on Irix).

        -

        33.1.7 Setting a package prefix

        +

        32.1.7 Setting a package prefix

        @@ -484,7 +484,7 @@ option will append the prefix to the name when creating a command and call it "Foo_bar".

        -

        33.1.8 Using namespaces

        +

        32.1.8 Using namespaces

        @@ -506,7 +506,7 @@ When the -namespace option is used, objects in the module are always accessed with the namespace name such as Foo::bar.

        -

        33.2 Building Tcl/Tk Extensions under Windows 95/NT

        +

        32.2 Building Tcl/Tk Extensions under Windows 95/NT

        @@ -517,7 +517,7 @@ covers the process of using SWIG with Microsoft Visual C++. although the procedure may be similar with other compilers.

        -

        33.2.1 Running SWIG from Developer Studio

        +

        32.2.1 Running SWIG from Developer Studio

        @@ -575,7 +575,7 @@ MSDOS > tclsh80 %

      -

      33.2.2 Using NMAKE

      +

      32.2.2 Using NMAKE

      @@ -638,7 +638,7 @@ to get you started. With a little practice, you'll be making lots of Tcl extensions.

      -

      33.3 A tour of basic C/C++ wrapping

      +

      32.3 A tour of basic C/C++ wrapping

      @@ -649,7 +649,7 @@ classes. This section briefly covers the essential aspects of this wrapping.

      -

      33.3.1 Modules

      +

      32.3.1 Modules

      @@ -683,7 +683,7 @@ To fix this, supply an extra argument to load like this:

      -

      33.3.2 Functions

      +

      32.3.2 Functions

      @@ -708,7 +708,7 @@ like you think it does: %

      -

      33.3.3 Global variables

      +

      32.3.3 Global variables

      @@ -788,7 +788,7 @@ extern char *path; // Read-only (due to %immutable) -

      33.3.4 Constants and enums

      +

      32.3.4 Constants and enums

      @@ -872,7 +872,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l conversion. This allows the global statement to be omitted.

      -

      33.3.5 Pointers

      +

      32.3.5 Pointers

      @@ -968,7 +968,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return None if the conversion can't be performed.

      -

      33.3.6 Structures

      +

      32.3.6 Structures

      @@ -1250,7 +1250,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the memory management section that appears shortly.

      -

      33.3.7 C++ classes

      +

      32.3.7 C++ classes

      @@ -1317,7 +1317,7 @@ In Tcl, the static member is accessed as follows: -

      33.3.8 C++ inheritance

      +

      32.3.8 C++ inheritance

      @@ -1366,7 +1366,7 @@ For instance: It is safe to use multiple inheritance with SWIG.

      -

      33.3.9 Pointers, references, values, and arrays

      +

      32.3.9 Pointers, references, values, and arrays

      @@ -1420,7 +1420,7 @@ to hold the result and a pointer is returned (Tcl will release this memory when the return value is garbage collected).

      -

      33.3.10 C++ overloaded functions

      +

      32.3.10 C++ overloaded functions

      @@ -1543,7 +1543,7 @@ first declaration takes precedence. Please refer to the "SWIG and C++" chapter for more information about overloading.

      -

      33.3.11 C++ operators

      +

      32.3.11 C++ operators

      @@ -1645,7 +1645,7 @@ There are ways to make this operator appear as part of the class using the % Keep reading.

      -

      33.3.12 C++ namespaces

      +

      32.3.12 C++ namespaces

      @@ -1709,7 +1709,7 @@ utilizes thousands of small deeply nested namespaces each with identical symbol names, well, then you get what you deserve.

      -

      33.3.13 C++ templates

      +

      32.3.13 C++ templates

      @@ -1761,7 +1761,7 @@ More details can be found in the SWIG and C++ -

      33.3.14 C++ Smart Pointers

      +

      32.3.14 C++ Smart Pointers

      @@ -1845,7 +1845,7 @@ simply use the __deref__() method. For example: -

      33.4 Further details on the Tcl class interface

      +

      32.4 Further details on the Tcl class interface

      @@ -1858,7 +1858,7 @@ of low-level details were omitted. This section provides a brief overview of how the proxy classes work.

      -

      33.4.1 Proxy classes

      +

      32.4.1 Proxy classes

      @@ -1923,7 +1923,7 @@ function. This allows objects to be encapsulated objects that look a lot like as shown in the last section.

      -

      33.4.2 Memory management

      +

      32.4.2 Memory management

      @@ -2111,7 +2111,7 @@ typemaps--an advanced topic discussed later.

      -

      33.5 Input and output parameters

      +

      32.5 Input and output parameters

      @@ -2299,7 +2299,7 @@ set c [lindex $dim 1] -

      33.6 Exception handling

      +

      32.6 Exception handling

      @@ -2433,7 +2433,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex See the chapter on "Customization Features" for more examples.

      -

      33.7 Typemaps

      +

      32.7 Typemaps

      @@ -2450,7 +2450,7 @@ Typemaps are only used if you want to change some aspect of the primitive C-Tcl interface.

      -

      33.7.1 What is a typemap?

      +

      32.7.1 What is a typemap?

      @@ -2567,7 +2567,7 @@ parameter is omitted): -

      33.7.2 Tcl typemaps

      +

      32.7.2 Tcl typemaps

      @@ -2705,7 +2705,7 @@ Initialize an argument to a value before any conversions occur. Examples of these methods will appear shortly.

      -

      33.7.3 Typemap variables

      +

      32.7.3 Typemap variables

      @@ -2776,7 +2776,7 @@ properly assigned. The Tcl name of the wrapper function being created. -

      33.7.4 Converting a Tcl list to a char **

      +

      32.7.4 Converting a Tcl list to a char **

      @@ -2838,7 +2838,7 @@ argv[2] = Larry 3 -

      33.7.5 Returning values in arguments

      +

      32.7.5 Returning values in arguments

      @@ -2880,7 +2880,7 @@ result, a Tcl function using these typemaps will work like this : % -

      33.7.6 Useful functions

      +

      32.7.6 Useful functions

      @@ -2957,7 +2957,7 @@ int Tcl_IsShared(Tcl_Obj *obj); -

      33.7.7 Standard typemaps

      +

      32.7.7 Standard typemaps

      @@ -3041,7 +3041,7 @@ work) -

      33.7.8 Pointer handling

      +

      32.7.8 Pointer handling

      @@ -3117,7 +3117,7 @@ For example: -

      33.8 Turning a SWIG module into a Tcl Package.

      +

      32.8 Turning a SWIG module into a Tcl Package.

      @@ -3189,7 +3189,7 @@ As a final note, most SWIG examples do not yet use the to use the load command instead.

      -

      33.9 Building new kinds of Tcl interfaces (in Tcl)

      +

      32.9 Building new kinds of Tcl interfaces (in Tcl)

      @@ -3288,7 +3288,7 @@ danger of blowing something up (although it is easily accomplished with an out of bounds array access).

      -

      33.9.1 Proxy classes

      +

      32.9.1 Proxy classes

      diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index 777184069..8f3035dc8 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -75,7 +75,6 @@

    • More about %apply and %clear
    • Reducing wrapper code size
    • Passing data between typemaps -
    • C++ "this" pointer
    • Where to go for more information? @@ -3900,66 +3899,7 @@ sure that the typemaps sharing information have exactly the same types and names

      -

      10.15 C++ "this" pointer

      - - -

      -All the rules discussed for Typemaps apply to C++ as well as C. -However in addition C++ passes an extra parameter into every -non-static class method -- the this pointer. Occasionally it can be -useful to apply a typemap to this pointer (for example to check -and make sure this is non-null before deferencing). -Actually, C also has an the equivalent of the this pointer which is used -when accessing variables in a C struct. -

      -

      -In order to customise the this pointer handling, target a variable named self in your typemaps. -self is the name SWIG uses to refer to the extra parameter in wrapped functions. -

      -

      -For example, if wrapping for Java generation: -

      - -
      -
      -%typemap(check) SWIGTYPE *self %{
      -if (!$1) {
      -  SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "swigCPtr null");
      -  return $null;
      -}
      -%}
      -
      -
      - -

      -In the above case, the $1 variable is expanded into the argument -name that SWIG is using as the this pointer. - -SWIG will then insert the check code before the actual C++ class method -is called, and will raise an exception rather than crash -the Java virtual machine. - -The generated code will look something like: -

      - -
      -
      -  if (!arg1) {
      -    SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException,
      -      "invalid native object; delete() likely already called");
      -    return ;
      -  }
      -  (arg1)->wrappedFunction(...);
      -
      -
      - -

      -Note that if you have a parameter named self then it -will also match the typemap. One work around is to create an interface file that wraps -the method, but give the argument a name other than self. -

      - -

      10.16 Where to go for more information?

      +

      10.15 Where to go for more information?

      diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 95af1ec6b..0b3cb37e9 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -558,7 +558,7 @@ example.i(4): Syntax error in input.

        -
      • 870. Warning for classname: Base baseclass ignored. Multiple inheritance is not supported in PHP. +
      • 870. Warning for classname: Base baseclass ignored. Multiple inheritance is not supported in Php4. (Php).
      • 871. Unrecognized pragma pragma. (Php).
      diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index bc8c8fa51..8a718ffad 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -281,7 +281,7 @@ Execute the steps in the order shown and don't use spaces in path names. In fact
    • - Copy the following to the MSYS install folder (C:\msys\1.0 is default): + Copy the followig to the MSYS install folder (C:\msys\1.0 is default):
      • msys-automake-1.8.2.tar.bz2
      • msys-autoconf-2.59.tar.bz2
      • diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters index bf180f1b4..840709d89 100644 --- a/Doc/Manual/chapters +++ b/Doc/Manual/chapters @@ -13,8 +13,8 @@ Contract.html Varargs.html Warnings.html Modules.html -CCache.html Allegrocl.html +C.html CSharp.html Chicken.html Guile.html diff --git a/Doc/Manual/swig16.png b/Doc/Manual/swig16.png old mode 100644 new mode 100755 diff --git a/Doc/README b/Doc/README index f7a493933..110428199 100644 --- a/Doc/README +++ b/Doc/README @@ -2,5 +2,4 @@ Doc/Manual - Latest version of the SWIG user manual Doc/Devel - Developer documentation concerning SWIG internals. (not necessarily up to date) -Open the index.html file in each of these directories with a web browser. - + \ No newline at end of file diff --git a/Examples/GIFPlot/Java/full/README b/Examples/GIFPlot/Java/full/README index 93463ea30..f536864de 100644 --- a/Examples/GIFPlot/Java/full/README +++ b/Examples/GIFPlot/Java/full/README @@ -1,8 +1,8 @@ This example runs the entire gifplot.h header file through SWIG without -any changes. The program 'runme.java' does something a little more -interesting. After doing a make, run it using 'java runme'. You'll have to go +any changes. The program 'main.java' does something a little more +interesting. After doing a make, run it using 'java main'. You'll have to go look at the header file to get a complete listing of the functions. -Note the differences in the runme.java files between this example and the +Note the differences in the main.java files between this example and the 'full' example. This example does not use shadow classes. diff --git a/Examples/GIFPlot/Java/full/runme.java b/Examples/GIFPlot/Java/full/main.java similarity index 99% rename from Examples/GIFPlot/Java/full/runme.java rename to Examples/GIFPlot/Java/full/main.java index c47c1e672..8fb65c86d 100644 --- a/Examples/GIFPlot/Java/full/runme.java +++ b/Examples/GIFPlot/Java/full/main.java @@ -1,7 +1,7 @@ // Plot a 3D function import java.lang.Math; -public class runme { +public class main { static { try { diff --git a/Examples/GIFPlot/Java/shadow/Makefile b/Examples/GIFPlot/Java/shadow/Makefile index 8062c2700..e513b9b5a 100644 --- a/Examples/GIFPlot/Java/shadow/Makefile +++ b/Examples/GIFPlot/Java/shadow/Makefile @@ -1,9 +1,8 @@ TOP = ../../.. SWIG = $(TOP)/../swig -SWIGOPT = -outcurrentdir +SWIGOPT = -I../../Interface SRCS = TARGET = gifplot -INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot INCLUDES = -I../../Include @@ -11,7 +10,7 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' java + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java javac *.java clean:: diff --git a/Examples/GIFPlot/Java/shadow/README b/Examples/GIFPlot/Java/shadow/README index b06c5a8f1..4adbde306 100644 --- a/Examples/GIFPlot/Java/shadow/README +++ b/Examples/GIFPlot/Java/shadow/README @@ -1,5 +1,5 @@ This example uses the file in ../../Interface/gifplot.i to build -an interface with shadow classes. After doing a make, run the program runme, ie: 'java runme'. +an interface with shadow classes. After doing a make, run the program main, ie: 'java main'. -Note the differences in the runme.java files between this example and the +Note the differences in the main.java files between this example and the 'full' example. This example uses the shadow classes. diff --git a/Examples/GIFPlot/Java/shadow/runme.java b/Examples/GIFPlot/Java/shadow/main.java similarity index 99% rename from Examples/GIFPlot/Java/shadow/runme.java rename to Examples/GIFPlot/Java/shadow/main.java index 91db03898..fbcf6e792 100644 --- a/Examples/GIFPlot/Java/shadow/runme.java +++ b/Examples/GIFPlot/Java/shadow/main.java @@ -2,7 +2,7 @@ import java.lang.Math; -public class runme { +public class main { static { try { diff --git a/Examples/GIFPlot/Java/simple/README b/Examples/GIFPlot/Java/simple/README index 13ff49611..1fb8453f0 100644 --- a/Examples/GIFPlot/Java/simple/README +++ b/Examples/GIFPlot/Java/simple/README @@ -1,5 +1,5 @@ This is a very minimalistic example in which just a few functions and constants from library are wrapped and used to draw some simple -shapes. After doing a make, run the java program, ie 'java runme'. +shapes. After doing a make, run the java program, ie 'java main'. diff --git a/Examples/GIFPlot/Java/simple/runme.java b/Examples/GIFPlot/Java/simple/main.java similarity index 98% rename from Examples/GIFPlot/Java/simple/runme.java rename to Examples/GIFPlot/Java/simple/main.java index 2d8d2bb48..b165a4baa 100644 --- a/Examples/GIFPlot/Java/simple/runme.java +++ b/Examples/GIFPlot/Java/simple/main.java @@ -1,5 +1,5 @@ -public class runme { +public class main { static { try { diff --git a/Examples/GIFPlot/Lib/color.c b/Examples/GIFPlot/Lib/color.c index 7d79baca9..a4eaf285e 100644 --- a/Examples/GIFPlot/Lib/color.c +++ b/Examples/GIFPlot/Lib/color.c @@ -132,10 +132,7 @@ int ColorMap_write(ColorMap *cm, char *filename) { f = fopen(filename,"w"); - if (fwrite(cm->cmap,768,1,f) != 1) { - fclose(f); - return -1; - } + fwrite(cm->cmap,768,1,f); fclose(f); return 0; } diff --git a/Examples/GIFPlot/Lib/gif.c b/Examples/GIFPlot/Lib/gif.c index 7953e5ce9..a0cfca1d5 100644 --- a/Examples/GIFPlot/Lib/gif.c +++ b/Examples/GIFPlot/Lib/gif.c @@ -268,7 +268,7 @@ static int maxmaxcode = 1 << GP_BITS; /* NEVER generate this */ static count_int *htab; static unsigned short *codetab; -static int GIFOutBufSize; +static GIFOutBufSize; /* static count_int htab [HSIZE]; static unsigned short codetab [HSIZE]; */ @@ -656,11 +656,7 @@ int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename) { fclose(file); return -1; } - if (fwrite(buffer,nbytes,1,file) != 1) { - free(buffer); - fclose(file); - return -1; - } + fwrite(buffer,nbytes,1,file); fclose(file); free(buffer); return 0; diff --git a/Examples/GIFPlot/Perl5/shadow/Makefile b/Examples/GIFPlot/Perl5/shadow/Makefile index c39eac52c..c5cb7aec4 100644 --- a/Examples/GIFPlot/Perl5/shadow/Makefile +++ b/Examples/GIFPlot/Perl5/shadow/Makefile @@ -1,9 +1,8 @@ TOP = ../../.. SWIG = $(TOP)/../swig -SWIGOPT = -outcurrentdir +SWIGOPT = -I../../Interface SRCS = TARGET = gifplot -INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot -lm INCLUDES = -I../../Include @@ -11,12 +10,12 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5 + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myperl' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5_static + TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static clean:: $(MAKE) -f $(TOP)/Makefile perl5_clean diff --git a/Examples/GIFPlot/Php/check.list b/Examples/GIFPlot/Php4/check.list similarity index 100% rename from Examples/GIFPlot/Php/check.list rename to Examples/GIFPlot/Php4/check.list diff --git a/Examples/GIFPlot/Php/full/Makefile b/Examples/GIFPlot/Php4/full/Makefile similarity index 81% rename from Examples/GIFPlot/Php/full/Makefile rename to Examples/GIFPlot/Php4/full/Makefile index e33e7a730..3aa632b99 100644 --- a/Examples/GIFPlot/Php/full/Makefile +++ b/Examples/GIFPlot/Php4/full/Makefile @@ -10,10 +10,10 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f *.gif rm -f php_gifplot.h diff --git a/Examples/GIFPlot/Php/full/README b/Examples/GIFPlot/Php4/full/README similarity index 100% rename from Examples/GIFPlot/Php/full/README rename to Examples/GIFPlot/Php4/full/README diff --git a/Examples/GIFPlot/Php/full/cmap b/Examples/GIFPlot/Php4/full/cmap similarity index 100% rename from Examples/GIFPlot/Php/full/cmap rename to Examples/GIFPlot/Php4/full/cmap diff --git a/Examples/GIFPlot/Php/full/gifplot.i b/Examples/GIFPlot/Php4/full/gifplot.i similarity index 100% rename from Examples/GIFPlot/Php/full/gifplot.i rename to Examples/GIFPlot/Php4/full/gifplot.i diff --git a/Examples/GIFPlot/Php/full/runme.php b/Examples/GIFPlot/Php4/full/runme.php4 similarity index 100% rename from Examples/GIFPlot/Php/full/runme.php rename to Examples/GIFPlot/Php4/full/runme.php4 diff --git a/Examples/GIFPlot/Php/shadow/Makefile b/Examples/GIFPlot/Php4/shadow/Makefile similarity index 80% rename from Examples/GIFPlot/Php/shadow/Makefile rename to Examples/GIFPlot/Php4/shadow/Makefile index df8ee30c0..5627e53a0 100644 --- a/Examples/GIFPlot/Php/shadow/Makefile +++ b/Examples/GIFPlot/Php4/shadow/Makefile @@ -10,10 +10,10 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f *.gif check: all diff --git a/Examples/GIFPlot/Php/shadow/README b/Examples/GIFPlot/Php4/shadow/README similarity index 100% rename from Examples/GIFPlot/Php/shadow/README rename to Examples/GIFPlot/Php4/shadow/README diff --git a/Examples/GIFPlot/Php/shadow/cmap b/Examples/GIFPlot/Php4/shadow/cmap similarity index 100% rename from Examples/GIFPlot/Php/shadow/cmap rename to Examples/GIFPlot/Php4/shadow/cmap diff --git a/Examples/GIFPlot/Php/shadow/runme.php b/Examples/GIFPlot/Php4/shadow/runme.php4 similarity index 100% rename from Examples/GIFPlot/Php/shadow/runme.php rename to Examples/GIFPlot/Php4/shadow/runme.php4 diff --git a/Examples/GIFPlot/Php/simple/Makefile b/Examples/GIFPlot/Php4/simple/Makefile similarity index 80% rename from Examples/GIFPlot/Php/simple/Makefile rename to Examples/GIFPlot/Php4/simple/Makefile index e60b641fa..6903bec0b 100644 --- a/Examples/GIFPlot/Php/simple/Makefile +++ b/Examples/GIFPlot/Php4/simple/Makefile @@ -10,10 +10,10 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f *.gif rm -f php_simple.h diff --git a/Examples/GIFPlot/Php/simple/README b/Examples/GIFPlot/Php4/simple/README similarity index 100% rename from Examples/GIFPlot/Php/simple/README rename to Examples/GIFPlot/Php4/simple/README diff --git a/Examples/GIFPlot/Php/simple/runme.php b/Examples/GIFPlot/Php4/simple/runme.php4 similarity index 100% rename from Examples/GIFPlot/Php/simple/runme.php rename to Examples/GIFPlot/Php4/simple/runme.php4 diff --git a/Examples/GIFPlot/Php/simple/simple.i b/Examples/GIFPlot/Php4/simple/simple.i similarity index 100% rename from Examples/GIFPlot/Php/simple/simple.i rename to Examples/GIFPlot/Php4/simple/simple.i diff --git a/Examples/GIFPlot/Python/full/Makefile b/Examples/GIFPlot/Python/full/Makefile index 83a7c864b..ae927b72b 100644 --- a/Examples/GIFPlot/Python/full/Makefile +++ b/Examples/GIFPlot/Python/full/Makefile @@ -1,5 +1,5 @@ TOP = ../../.. -SWIG = $(TOP)/../preinst-swig +SWIG = $(TOP)/../swig SWIGOPT = -I../../Include SRCS = TARGET = gifplot @@ -23,4 +23,3 @@ clean:: rm -f *.gif check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/shadow/Makefile b/Examples/GIFPlot/Python/shadow/Makefile index 3ae9a9897..1f5014895 100644 --- a/Examples/GIFPlot/Python/shadow/Makefile +++ b/Examples/GIFPlot/Python/shadow/Makefile @@ -1,9 +1,8 @@ TOP = ../../.. -SWIG = $(TOP)/../preinst-swig -SWIGOPT = -outcurrentdir +SWIG = $(TOP)/../swig +SWIGOPT = -I../../Interface SRCS = TARGET = gifplot -INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot INCLUDES = -I../../Include @@ -11,12 +10,12 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypython' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python_static + TARGET='mypython' INTERFACE='$(INTERFACE)' python_static clean:: $(MAKE) -f $(TOP)/Makefile python_clean @@ -24,4 +23,3 @@ clean:: rm -f *.gif check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/simple/Makefile b/Examples/GIFPlot/Python/simple/Makefile index 9fc9a6c72..5eb0344e8 100644 --- a/Examples/GIFPlot/Python/simple/Makefile +++ b/Examples/GIFPlot/Python/simple/Makefile @@ -1,5 +1,5 @@ TOP = ../../.. -SWIG = $(TOP)/../preinst-swig +SWIG = $(TOP)/../swig SWIGOPT = SRCS = TARGET = simple @@ -23,4 +23,3 @@ clean:: rm -f *.gif check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Ruby/shadow/Makefile b/Examples/GIFPlot/Ruby/shadow/Makefile index 8cbea2a57..ea382ea88 100644 --- a/Examples/GIFPlot/Ruby/shadow/Makefile +++ b/Examples/GIFPlot/Ruby/shadow/Makefile @@ -1,9 +1,8 @@ TOP = ../../.. SWIG = $(TOP)/../swig -SWIGOPT = -outcurrentdir +SWIGOPT = -I../../Interface SRCS = TARGET = gifplot -INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot INCLUDES = -I../../Include @@ -11,12 +10,12 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myruby' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby_static + TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static clean:: $(MAKE) -f $(TOP)/Makefile ruby_clean diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 63ca787d6..c47bb6a7b 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -12,11 +12,11 @@ # certain packages have been installed. Set the prefixes # accordingly. # -# 2. To use this makefile, set required varibles, eg SRCS, INTERFACE, -# INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a +# 2. To use this makefile, simply set SRCS, INTERFACE, INCLUDES, LIBS, +# TARGET, and do a # $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \ # INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \ -# INTERFACEDIR='$(INTERFACEDIR)' TARGET='$(TARGET)' method +# TARGET='$(TARGET)' method # # 'method' describes what is being built. #--------------------------------------------------------------- @@ -31,8 +31,6 @@ SRCS = INCLUDES = LIBS = INTERFACE = -INTERFACEDIR = -INTERFACEPATH = $(INTERFACEDIR)$(INTERFACE) SWIGOPT = SWIG = swig @@ -98,8 +96,6 @@ TK_OPTS = -ltk -ltcl @LIBS@ # Extra Tcl specific dynamic linking options TCL_DLNK = @TCLDYNAMICLINKING@ TCL_SO = @TCL_SO@ -TCLLDSHARED = @TCLLDSHARED@ -TCLCXXSHARED = @TCLCXXSHARED@ # ----------------------------------------------------------- # Build a new version of the tclsh shell @@ -107,12 +103,12 @@ TCLCXXSHARED = @TCLCXXSHARED@ tclsh: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH) + $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACE) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) tclsh_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH) + $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACE) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) @@ -121,13 +117,13 @@ tclsh_cpp: $(SRCS) # ----------------------------------------------------------- wish: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) + $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACE) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) wish_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) + $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACE) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) @@ -136,18 +132,18 @@ wish_cpp: $(SRCS) # ----------------------------------------------------------- tcl: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH) + $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) - $(TCLLDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------- # Build a Tcl7.5 dynamic loadable module for C++ # ----------------------------------------------------------- tcl_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH) + $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) - $(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) # ----------------------------------------------------------------- # Cleaning the Tcl examples @@ -177,7 +173,7 @@ PERL5_CCFLAGS = @PERL5CCFLAGS@ # ---------------------------------------------------------------- perl5: $(SRCS) - $(SWIG) -perl5 $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -perl5 $(SWIGOPT) $(INTERFACE) $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -186,7 +182,7 @@ perl5: $(SRCS) # ---------------------------------------------------------------- perl5_cpp: $(SRCS) - $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -204,11 +200,11 @@ perl5_xs: $(SRCS) PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) perl5_static: $(SRCS) - $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACE) $(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) perl5_static_cpp: $(SRCS) - $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACE) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) # ----------------------------------------------------------------- @@ -225,39 +221,19 @@ perl5_clean: ################################################################## # Make sure these locate your Python installation -ifeq (,$(PY3)) - PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ - PYTHON_LIB = @PYLIB@ - PYTHON = @PYTHON@ -else - PYTHON_INCLUDE= $(DEFS) @PY3INCLUDE@ - PYTHON_LIB = @PY3LIB@ - PYTHON = @PYTHON3@ -endif +PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ +PYTHON_LIB = @PYLIB@ -# Extra Python specific linking options -ifeq (,$(PY3)) - PYTHON_DLNK = @PYTHONDYNAMICLINKING@ - PYTHON_LINK = @PYLINK@ -else - PYTHON_DLNK = @PYTHON3DYNAMICLINKING@ - PYTHON_LINK = @PY3LINK@ -endif +# Extra Python specific dynamic linking options +PYTHON_DLNK = @PYTHONDYNAMICLINKING@ PYTHON_SO = @PYTHON_SO@ -# SWIG option for Python -ifeq (,$(PY3)) - SWIGPYTHON = $(SWIG) -python -else - SWIGPYTHON = $(SWIG) -python -py3 -endif - # ---------------------------------------------------------------- # Build a C dynamically loadable module # ---------------------------------------------------------------- python: $(SRCS) - $(SWIGPYTHON) $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -python $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) @@ -266,7 +242,7 @@ python: $(SRCS) # ----------------------------------------------------------------- python_cpp: $(SRCS) - $(SWIGPYTHON) -c++ $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -python $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) @@ -279,37 +255,18 @@ python_cpp: $(SRCS) #TKINTER = -L/usr/X11R6.3/lib -L/usr/local/compat/lib -ltk4.0 -ltcl7.4 -lX11 TKINTER = -PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS) +PYTHON_LIBOPTS = @PYLINK@ @LIBS@ $(TKINTER) $(SYSLIBS) python_static: $(SRCS) - $(SWIGPYTHON) -lembed.i $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -python -lembed.i $(SWIGOPT) $(INTERFACE) $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) python_static_cpp: $(SRCS) - $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -python -lembed.i $(SWIGOPT) $(INTERFACE) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) -# ----------------------------------------------------------------- -# Running a Python example -# ----------------------------------------------------------------- - -ifeq (,$(PY3)) - PYSCRIPT = runme.py -else - PYSCRIPT = runme3.py -endif - -PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` - -python_run: $(PYSCRIPT) - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) >/dev/null - -runme3.py: runme.py - cp $< $@ - $(PY2TO3) -w $@ >/dev/null 2>&1 - # ----------------------------------------------------------------- # Cleaning the python examples # ----------------------------------------------------------------- @@ -318,8 +275,6 @@ python_clean: rm -f *_wrap* *~ .~* mypython@EXEEXT@ *.pyc rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@ - if [ -f runme.py ]; then (rm -f runme3.py runme3.py.bak;) fi; - ################################################################## ##### OCTAVE ###### @@ -338,7 +293,7 @@ OCTAVE_SO = @OCTAVE_SO@ # ---------------------------------------------------------------- octave: $(SRCS) - $(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -octave $(SWIGOPT) $(INTERFACE) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) $(OCTAVE_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) @@ -348,7 +303,7 @@ octave: $(SRCS) # ----------------------------------------------------------------- octave_cpp: $(SRCS) - $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACE) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) $(CXXSHARED) -g $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) @@ -375,12 +330,12 @@ GUILE_LIBPREFIX = lib # Build a dynamically loaded module with passive linkage and the scm interface #------------------------------------------------------------------ guile: $(SRCS) - $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_cpp: $(SRCS) - $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) @@ -391,12 +346,12 @@ guile_externalhdr: # Build a dynamically loaded module with passive linkage and the gh interface #------------------------------------------------------------------ guile_gh: $(SRCS) - $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_gh_cpp: $(SRCS) - $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) @@ -405,12 +360,12 @@ guile_gh_cpp: $(SRCS) # ----------------------------------------------------------------- guile_passive: $(SRCS) - $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_passive_cpp: $(SRCS) - $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) @@ -421,24 +376,24 @@ guile_passive_cpp: $(SRCS) GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS) guile_static: $(SRCS) - $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACE) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_static_cpp: $(SRCS) - $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACE) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple: $(SRCS) - $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACE) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple_cpp: $(SRCS) - $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACE) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile @@ -473,7 +428,7 @@ JAVACFLAGS = @JAVACFLAGS@ # ---------------------------------------------------------------- java: $(SRCS) - $(SWIG) -java $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -java $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVALDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) @@ -482,7 +437,7 @@ java: $(SRCS) # ---------------------------------------------------------------- java_cpp: $(SRCS) - $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVACXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) @@ -491,7 +446,7 @@ java_cpp: $(SRCS) # ----------------------------------------------------------------- java_clean: - rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v runme.java` + rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v main.java` rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@JAVASO@ @@ -506,12 +461,12 @@ MODULA3_INCLUDE= @MODULA3INC@ # ---------------------------------------------------------------- modula3: $(SRCS) - $(SWIG) -modula3 $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -modula3 $(SWIGOPT) $(INTERFACE) # $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) \ # $(OBJS) $(IOBJS) $(LIBS) modula3_cpp: $(SRCS) - $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACE) # ----------------------------------------------------------------- # Cleaning the modula3 examples @@ -526,7 +481,7 @@ modula3_clean: ##### MZSCHEME ###### ################################################################## -MZC = @MZC@ +MZC = test -n "@MZC@" && @MZC@ MZDYNOBJ = @MZDYNOBJ@ MZSCHEME_SO = @MZSCHEME_SO@ @@ -535,13 +490,13 @@ MZSCHEME_SO = @MZSCHEME_SO@ # ---------------------------------------------------------------- mzscheme: $(SRCS) - $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACEPATH) - $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS) - $(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) + $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACE) + $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS) + $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) mzscheme_cpp: $(SRCS) - $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH) - $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE) + $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) # ----------------------------------------------------------------- @@ -563,7 +518,6 @@ OCAMLFIND=@OCAMLFIND@ OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE) NOLINK ?= false OCAMLPP= -pp "camlp4o ./swigp4.cmo" -OCAMLP4WHERE=`$(COMPILETOOL) camlp4 -where` OCAMLCORE=\ rm -rf swig.mli swig.ml swigp4.ml && \ $(SWIG) -ocaml -co swig.mli 2>/dev/null && \ @@ -571,12 +525,12 @@ OCAMLCORE=\ $(SWIG) -ocaml -co swigp4.ml 2>/dev/null && \ $(OCC) -c swig.mli && \ $(OCC) -c swig.ml && \ - $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" \ + $(OCC) -I `camlp4 -where` -pp "camlp4o pa_extend.cmo q_MLast.cmo" \ -c swigp4.ml ocaml_static: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -g -c $(INTERFACE:%.i=%.ml) @@ -590,7 +544,7 @@ ocaml_static: $(SRCS) ocaml_dynamic: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS) $(CXXSHARED) $(CFLAGS) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS) @@ -609,7 +563,7 @@ ocaml_dynamic: $(SRCS) ocaml_static_toplevel: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -g -c $(INTERFACE:%.i=%.ml) @@ -617,14 +571,14 @@ ocaml_static_toplevel: $(SRCS) $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) \ swig.cmo \ - -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \ + -I `camlp4 -where` camlp4o.cma swigp4.cmo \ -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \ $(INTERFACE:%.i=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" ocaml_static_cpp: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) @@ -641,7 +595,7 @@ ocaml_static_cpp: $(SRCS) ocaml_static_cpp_toplevel: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) @@ -651,7 +605,7 @@ ocaml_static_cpp_toplevel: $(SRCS) $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) \ swig.cmo \ - -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \ + -I `camlp4 -where` camlp4o.cma swigp4.cmo \ -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \ $(INTERFACE:%.i=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \ @@ -659,7 +613,7 @@ ocaml_static_cpp_toplevel: $(SRCS) ocaml_dynamic_cpp: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC @@ -700,7 +654,7 @@ RUBY_DLNK = @RUBYDYNAMICLINKING@ # ---------------------------------------------------------------- ruby: $(SRCS) - $(SWIG) -ruby $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -ruby $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -709,7 +663,7 @@ ruby: $(SRCS) # ----------------------------------------------------------------- ruby_cpp: $(SRCS) - $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -723,12 +677,12 @@ ruby_cpp: $(SRCS) RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) ruby_static: $(SRCS) - $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACE) $(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) ruby_cpp_static: $(SRCS) - $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACE) $(CXX) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) @@ -747,41 +701,41 @@ ruby_clean: ################################################################## # ------------------------------------------------------------------- -# Build a PHP dynamically loadable module (C) +# Build a PHP4 dynamically loadable module (C) # ------------------------------------------------------------------- -PHP_INCLUDE = @PHPINC@ -PHP_SO = @PHP_SO@ +PHP4_INCLUDE = @PHP4INC@ +PHP4_SO = @PHP4_SO@ -php: $(SRCS) - $(SWIG) -php $(SWIGOPT) $(INTERFACEPATH) - $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO) +php4: $(SRCS) + $(SWIG) -php5 $(SWIGOPT) $(INTERFACE) + $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP4_INCLUDE) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP4_SO) # -------------------------------------------------------------------- -# Build a PHP dynamically loadable module (C++) +# Build a PHP4 dynamically loadable module (C++) # -------------------------------------------------------------------- -php_cpp: $(SRCS) - $(SWIG) -php -cppext cxx -c++ $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO) +php4_cpp: $(SRCS) + $(SWIG) -php5 -cppext cxx -c++ $(SWIGOPT) $(INTERFACE) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP4_INCLUDE) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP4_SO) # ----------------------------------------------------------------- -# Running a PHP example +# Running a PHP4 example # ----------------------------------------------------------------- -PHP=@PHP@ -PHPSCRIPT ?= runme.php +PHP4=@PHP4@ +SCRIPT ?= runme.php4 -php_run: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT) +php4_run: + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP4) -n -q -d extension_dir=. $(SCRIPT) # ----------------------------------------------------------------- -# Cleaning the PHP examples +# Cleaning the PHP4 examples # ----------------------------------------------------------------- -php_clean: +php4_clean: rm -f *_wrap* *~ .~* example.php php_example.h rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ @@ -801,7 +755,7 @@ PIKE_DLNK = @PIKEDYNAMICLINKING@ # ---------------------------------------------------------------- pike: $(SRCS) - $(SWIG) -pike $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -pike $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PIKE_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -810,7 +764,7 @@ pike: $(SRCS) # ----------------------------------------------------------------- pike_cpp: $(SRCS) - $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -824,12 +778,12 @@ pike_cpp: $(SRCS) PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) pike_static: $(SRCS) - $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACE) $(CC) $(CFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) pike_cpp_static: $(SRCS) - $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACE) $(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) @@ -871,7 +825,7 @@ CHICKEN_COMPILED_MAIN_OBJECT = $(CHICKEN_COMPILED_MAIN:.c=.@OBJEXT@) # This is the old way to build chicken, but it does not work correctly with exceptions chicken_direct: $(SRCS) - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) + $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -dynamic -feature chicken-compile-shared \ -output-file $(CHICKEN_COMPILED_SCHEME) @@ -881,7 +835,7 @@ chicken_direct: $(SRCS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO) chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS) - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) + $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -dynamic -feature chicken-compile-shared \ -output-file $(CHICKEN_COMPILED_SCHEME) @@ -896,7 +850,7 @@ chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS) # The following two targets are also used by the test suite chicken_static: $(SRCS) $(CHICKSRCS) - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) + $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \ @@ -908,7 +862,7 @@ chicken_static: $(SRCS) $(CHICKSRCS) $(OBJS) $(IOBJS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET) chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS) - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) + $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \ @@ -924,11 +878,11 @@ chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS) # ---------------------------------------------------------------- chicken: - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) + $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO) chicken_cpp: - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) + $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO) chicken_externalhdr: @@ -956,7 +910,7 @@ CSHARPSO = @CSHARPSO@ # ---------------------------------------------------------------- csharp: $(SRCS) - $(SWIG) -csharp $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -csharp $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO) @@ -965,7 +919,7 @@ csharp: $(SRCS) # ---------------------------------------------------------------- csharp_cpp: $(SRCS) - $(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO) @@ -1005,7 +959,7 @@ LUA_INTERP = ../lua.c # ---------------------------------------------------------------- lua: $(SRCS) - $(SWIG) -lua $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -lua $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(LUA_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) @@ -1014,7 +968,7 @@ lua: $(SRCS) # ----------------------------------------------------------------- lua_cpp: $(SRCS) - $(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(LUA_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) @@ -1023,12 +977,12 @@ lua_cpp: $(SRCS) # ----------------------------------------------------------------- lua_static: $(SRCS) - $(SWIG) -lua -module example $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -lua -module example $(SWIGOPT) $(INTERFACE) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) lua_static_cpp: $(SRCS) - $(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACE) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) @@ -1046,12 +1000,12 @@ lua_clean: ################################################################## allegrocl: $(SRCS) - $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) allegrocl_cpp: $(SRCS) - $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -1065,10 +1019,10 @@ allegrocl_clean: ################################################################## clisp: $(SRCS) - $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -clisp $(SWIGOPT) $(INTERFACE) clisp_cpp: $(SRCS) - $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACE) clisp_clean: rm -f *_wrap* *~ .~* @@ -1080,12 +1034,12 @@ clisp_clean: ################################################################## cffi: $(SRCS) - $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -cffi $(SWIGOPT) $(INTERFACE) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) # $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) cffi_cpp: $(SRCS) - $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -1099,12 +1053,12 @@ cffi_clean: ################################################################## uffi: $(SRCS) - $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -uffi $(SWIGOPT) $(INTERFACE) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) # $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) uffi_cpp: $(SRCS) - $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACE) # $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) # $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -1122,11 +1076,11 @@ RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system a RRSRC = $(INTERFACE:.i=.R) r: $(SRCS) - $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -r $(SWIGOPT) $(INTERFACE) +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) r_cpp: $(CXXSRCS) - $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) + $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACE) +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) r_clean: @@ -1149,12 +1103,12 @@ CXX_LDSHARED = @CXX_LDSHARED@ C_SO = @C_SO@ c: $(SRCS) - $(SWIG) -c $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c $(SWIGOPT) $(INTERFACE) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(C_LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(CLIBPREFIX)$(TARGET)$(C_SO) c_cpp: $(SRCS) - $(SWIG) -c++ -c $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -c++ -c $(SWIGOPT) $(INTERFACE) $(CXX) -c $(CCSHARED) $(CXXFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXX_LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(CLIBPREFIX)$(TARGET)$(C_SO) diff --git a/Examples/csharp/arrays/Makefile b/Examples/csharp/arrays/Makefile deleted file mode 100644 index b3446d895..000000000 --- a/Examples/csharp/arrays/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -SRCS = example.c -TARGET = example -INTERFACE = example.i -SWIGOPT = -CSHARPSRCS = *.cs -CSHARPFLAGS= -nologo -unsafe -out:runme.exe - -all:: csharp - -csharp:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp - $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile - -clean:: - $(MAKE) -f $(TOP)/Makefile csharp_clean - -check: all diff --git a/Examples/csharp/arrays/example.c b/Examples/csharp/arrays/example.c deleted file mode 100644 index 2498e1f4e..000000000 --- a/Examples/csharp/arrays/example.c +++ /dev/null @@ -1,22 +0,0 @@ -/* File : example.c */ - -#include "example.h" - -/* copy the contents of the first array to the second */ -void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) { - int i; - for ( i = 0; i < nitems; i++ ) { - targetArray[ i ] = sourceArray[ i ]; - } -} - -/* swap the contents of the two arrays */ -void myArraySwap( int* array1, int* array2, int nitems ) { - int i, temp; - for ( i = 0; i < nitems; i++ ) { - temp = array1[ i ]; - array1[ i ] = array2[ i ]; - array2[ i ] = temp; - } -} - diff --git a/Examples/csharp/arrays/example.h b/Examples/csharp/arrays/example.h deleted file mode 100644 index 113b92c1b..000000000 --- a/Examples/csharp/arrays/example.h +++ /dev/null @@ -1,4 +0,0 @@ - -void myArrayCopy( int *sourceArray, int* targetArray, int nitems ); -void myArraySwap( int* array1, int* array2, int nitems ); - diff --git a/Examples/csharp/arrays/example.i b/Examples/csharp/arrays/example.i deleted file mode 100644 index 488565a74..000000000 --- a/Examples/csharp/arrays/example.i +++ /dev/null @@ -1,45 +0,0 @@ -/* File : example.i */ -%module example - -%{ -#include "example.h" -%} -%include "arrays_csharp.i" - -%apply int INPUT[] { int* sourceArray } -%apply int OUTPUT[] { int* targetArray } - -%apply int INOUT[] { int* array1 } -%apply int INOUT[] { int* array2 } - -%include "example.h" - -%clear int* sourceArray; -%clear int* targetArray; - -%clear int* array1; -%clear int* array2; - - -// Below replicates the above array handling but this time using the pinned (fixed) array typemaps -%csmethodmodifiers "public unsafe"; - -%apply int FIXED[] { int* sourceArray } -%apply int FIXED[] { int* targetArray } - -%inline %{ -void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) { - myArrayCopy(sourceArray, targetArray, nitems); -} -%} - -%apply int FIXED[] { int* array1 } -%apply int FIXED[] { int* array2 } - -%inline %{ -void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) { - myArraySwap(array1, array2, nitems); -} -%} - - diff --git a/Examples/csharp/arrays/runme.cs b/Examples/csharp/arrays/runme.cs deleted file mode 100644 index c2b8a6bdd..000000000 --- a/Examples/csharp/arrays/runme.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; - -public class runme -{ - static void Main() - { - int[] source = { 1, 2, 3 }; - int[] target = new int[ source.Length ]; - - example.myArrayCopy( source, target, target.Length ); - - Console.WriteLine( "Contents of copy target array using default marshaling" ); - PrintArray( target ); - - target = new int[ source.Length ]; - - example.myArrayCopyUsingFixedArrays( source, target, target.Length ); - Console.WriteLine( "Contents of copy target array using fixed arrays" ); - PrintArray( target ); - - target = new int[] { 4, 5, 6 }; - example.myArraySwap( source, target, target.Length ); - Console.WriteLine( "Contents of arrays after swapping using default marshaling" ); - PrintArray( source ); - PrintArray( target ); - - source = new int[] { 1, 2, 3 }; - target = new int[] { 4, 5, 6 }; - - example.myArraySwapUsingFixedArrays( source, target, target.Length ); - Console.WriteLine( "Contents of arrays after swapping using fixed arrays" ); - PrintArray( source ); - PrintArray( target ); - } - - static void PrintArray( int[] a ) - { - foreach ( int i in a ) - Console.Write( "{0} ", i ); - Console.WriteLine(); - } -} - diff --git a/Examples/csharp/check.list b/Examples/csharp/check.list index 5454d8531..c4d92402b 100644 --- a/Examples/csharp/check.list +++ b/Examples/csharp/check.list @@ -1,5 +1,4 @@ # see top-level Makefile.in -arrays callback class enum diff --git a/Examples/guile/matrix/matrix.scm b/Examples/guile/matrix/matrix.scm old mode 100644 new mode 100755 diff --git a/Examples/java/callback/runme.java b/Examples/java/callback/main.java similarity index 98% rename from Examples/java/callback/runme.java rename to Examples/java/callback/main.java index 4090f0ac3..4800f8cc9 100644 --- a/Examples/java/callback/runme.java +++ b/Examples/java/callback/main.java @@ -1,4 +1,4 @@ -public class runme +public class main { static { try { diff --git a/Examples/java/class/index.html b/Examples/java/class/index.html index cf9130c62..e9db7e94a 100644 --- a/Examples/java/class/index.html +++ b/Examples/java/class/index.html @@ -88,7 +88,7 @@ Note: when creating a C++ extension, you must run SWIG with the -c++ op

        A sample Java program

        -Click here to see a Java program that calls the C++ functions from Java. +Click here to see a Java program that calls the C++ functions from Java.

        Key points

        diff --git a/Examples/java/class/runme.java b/Examples/java/class/main.java similarity index 99% rename from Examples/java/class/runme.java rename to Examples/java/class/main.java index e1ea0d71c..8ef35db6d 100644 --- a/Examples/java/class/runme.java +++ b/Examples/java/class/main.java @@ -1,7 +1,7 @@ // This example illustrates how C++ classes can be used from Java using SWIG. // The Java class gets mapped onto the C++ class and behaves as if it is a Java class. -public class runme { +public class main { static { try { System.loadLibrary("example"); diff --git a/Examples/java/constants/index.html b/Examples/java/constants/index.html index 9f1e95a03..8367d0571 100644 --- a/Examples/java/constants/index.html +++ b/Examples/java/constants/index.html @@ -20,7 +20,7 @@ to see a SWIG interface with some constant declarations in it. Click here for the section on constants in the SWIG and Java documentation.

        -Click here to see a Java program that prints out the values +Click here to see a Java program that prints out the values of the constants contained in the above file.

        Key points

          diff --git a/Examples/java/constants/runme.java b/Examples/java/constants/main.java similarity index 98% rename from Examples/java/constants/runme.java rename to Examples/java/constants/main.java index 2c67d86aa..7130c3d70 100644 --- a/Examples/java/constants/runme.java +++ b/Examples/java/constants/main.java @@ -1,6 +1,6 @@ import java.lang.reflect.*; -public class runme { +public class main { static { try { System.loadLibrary("example"); diff --git a/Examples/java/enum/index.html b/Examples/java/enum/index.html index 20daf2691..52c06c5d1 100644 --- a/Examples/java/enum/index.html +++ b/Examples/java/enum/index.html @@ -21,7 +21,7 @@ See the documentation for the other approaches for wrapping enums.
          diff --git a/Examples/java/enum/runme.java b/Examples/java/enum/main.java similarity index 98% rename from Examples/java/enum/runme.java rename to Examples/java/enum/main.java index 56e49af91..8646e0087 100644 --- a/Examples/java/enum/runme.java +++ b/Examples/java/enum/main.java @@ -1,5 +1,5 @@ -public class runme { +public class main { static { try { System.loadLibrary("example"); diff --git a/Examples/java/extend/runme.java b/Examples/java/extend/main.java similarity index 99% rename from Examples/java/extend/runme.java rename to Examples/java/extend/main.java index 629bb14a6..ee3a94ed0 100644 --- a/Examples/java/extend/runme.java +++ b/Examples/java/extend/main.java @@ -17,7 +17,7 @@ class CEO extends Manager { } -public class runme { +public class main { static { try { System.loadLibrary("example"); diff --git a/Examples/java/funcptr/index.html b/Examples/java/funcptr/index.html index 56d3baa18..0ad2be1cf 100644 --- a/Examples/java/funcptr/index.html +++ b/Examples/java/funcptr/index.html @@ -66,7 +66,7 @@ Here are some files that illustrate this with a simple example:
        • example.c
        • example.h
        • example.i (SWIG interface) -
        • runme.java (Sample program) +
        • main.java (Sample program)

        Notes

        diff --git a/Examples/java/funcptr/runme.java b/Examples/java/funcptr/main.java similarity index 98% rename from Examples/java/funcptr/runme.java rename to Examples/java/funcptr/main.java index cd34c1b65..cf81f92b4 100644 --- a/Examples/java/funcptr/runme.java +++ b/Examples/java/funcptr/main.java @@ -1,5 +1,5 @@ -public class runme { +public class main { static { try { diff --git a/Examples/java/index.html b/Examples/java/index.html index 007e14dbc..d98f9a393 100644 --- a/Examples/java/index.html +++ b/Examples/java/index.html @@ -30,7 +30,7 @@ certain C declarations are turned into constants.

        Running the examples

        Please see the Windows page in the main manual for information on using the examples on Windows.

        -On Unix most of the examples work by making the Makefile before executing the program runme.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac. +On Unix most of the examples work by making the Makefile before executing the program main.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac.

        Ensure that the dynamic link library file is in the appropriate path before executing the Java program. For example in Unix, libexample.so must be in the LD_LIBRARY_PATH.

        @@ -39,7 +39,7 @@ A Unix example:

         $ make
         $ export LD_LIBRARY_PATH=. #ksh 
        -$ java runme
        +$ java main
         

        diff --git a/Examples/java/multimap/runme.java b/Examples/java/multimap/main.java similarity index 97% rename from Examples/java/multimap/runme.java rename to Examples/java/multimap/main.java index 738330e77..331ac6b89 100644 --- a/Examples/java/multimap/runme.java +++ b/Examples/java/multimap/main.java @@ -1,5 +1,5 @@ -public class runme { +public class main { static { try { diff --git a/Examples/java/native/index.html b/Examples/java/native/index.html index 1ca51c1e9..7ecf129ce 100644 --- a/Examples/java/native/index.html +++ b/Examples/java/native/index.html @@ -18,7 +18,7 @@ This example compares wrapping a c global function using the manual way and the

        • example.i. Interface file comparing code wrapped by SWIG and wrapped manually. -
        • runme.java. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions. +
        • main.java. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions.

        Notes

        diff --git a/Examples/java/native/runme.java b/Examples/java/native/main.java similarity index 96% rename from Examples/java/native/runme.java rename to Examples/java/native/main.java index e9a18b21a..f4760bb3d 100644 --- a/Examples/java/native/runme.java +++ b/Examples/java/native/main.java @@ -1,5 +1,5 @@ -public class runme { +public class main { static { try { diff --git a/Examples/java/pointer/index.html b/Examples/java/pointer/index.html index e20fe3328..c30d549e6 100644 --- a/Examples/java/pointer/index.html +++ b/Examples/java/pointer/index.html @@ -144,7 +144,7 @@ extraction.

        Notes

        diff --git a/Examples/java/pointer/runme.java b/Examples/java/pointer/main.java similarity index 98% rename from Examples/java/pointer/runme.java rename to Examples/java/pointer/main.java index f32f980f9..e96e02eaa 100644 --- a/Examples/java/pointer/runme.java +++ b/Examples/java/pointer/main.java @@ -1,5 +1,5 @@ -public class runme { +public class main { static { try { diff --git a/Examples/java/reference/index.html b/Examples/java/reference/index.html index 33c80c50f..64b129cbb 100644 --- a/Examples/java/reference/index.html +++ b/Examples/java/reference/index.html @@ -121,7 +121,7 @@ Click here to see a SWIG interface file with these addit

        Sample Java program

        -Click here to see a Java program that manipulates some C++ references. +Click here to see a Java program that manipulates some C++ references.

        Notes:

        diff --git a/Examples/java/reference/runme.java b/Examples/java/reference/main.java similarity index 99% rename from Examples/java/reference/runme.java rename to Examples/java/reference/main.java index 6a2d9bf70..4fd354761 100644 --- a/Examples/java/reference/runme.java +++ b/Examples/java/reference/main.java @@ -1,6 +1,6 @@ // This example illustrates the manipulation of C++ references in Java. -public class runme { +public class main { static { try { System.loadLibrary("example"); diff --git a/Examples/java/simple/index.html b/Examples/java/simple/index.html index 9729e6dd8..a363327fe 100644 --- a/Examples/java/simple/index.html +++ b/Examples/java/simple/index.html @@ -65,15 +65,15 @@ to create the extension libexample.so (unix).

        Using the extension

        -Click here to see a program that calls our C functions from Java. +Click here to see a program that calls our C functions from Java.

        -Compile the java files example.java and runme.java -to create the class files example.class and runme.class before running runme in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example: +Compile the java files example.java and main.java +to create the class files example.class and main.class before running main in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example:

         export LD_LIBRARY_PATH=. #ksh 
         javac *.java
        -java runme
        +java main
         
        diff --git a/Examples/java/simple/runme.java b/Examples/java/simple/main.java similarity index 97% rename from Examples/java/simple/runme.java rename to Examples/java/simple/main.java index 92880e8f9..6d224a4dc 100644 --- a/Examples/java/simple/runme.java +++ b/Examples/java/simple/main.java @@ -1,5 +1,5 @@ -public class runme { +public class main { static { try { diff --git a/Examples/java/template/index.html b/Examples/java/template/index.html index f4408e568..1aebd4c2a 100644 --- a/Examples/java/template/index.html +++ b/Examples/java/template/index.html @@ -85,7 +85,7 @@ Note that SWIG parses the templated function max and templated class A sample Java program -Click here to see a Java program that calls the C++ functions from Java. +Click here to see a Java program that calls the C++ functions from Java.

        Notes

        Use templated classes just like you would any other SWIG generated Java class. Use the classnames specified by the %template directive. diff --git a/Examples/java/template/runme.java b/Examples/java/template/main.java similarity index 98% rename from Examples/java/template/runme.java rename to Examples/java/template/main.java index 5d1097bba..9129fcf2a 100644 --- a/Examples/java/template/runme.java +++ b/Examples/java/template/main.java @@ -1,6 +1,6 @@ // This example illustrates how C++ templates can be used from Java. -public class runme { +public class main { static { try { System.loadLibrary("example"); diff --git a/Examples/java/typemap/index.html b/Examples/java/typemap/index.html index 5dd591941..486aa8e79 100644 --- a/Examples/java/typemap/index.html +++ b/Examples/java/typemap/index.html @@ -16,7 +16,7 @@ This example shows how typemaps can be used to modify the default behaviour of t

        Notes

        diff --git a/Examples/java/typemap/runme.java b/Examples/java/typemap/main.java similarity index 96% rename from Examples/java/typemap/runme.java rename to Examples/java/typemap/main.java index fcbcc3067..bd9a4e1b6 100644 --- a/Examples/java/typemap/runme.java +++ b/Examples/java/typemap/main.java @@ -1,5 +1,5 @@ -public class runme { +public class main { static { try { diff --git a/Examples/java/variables/index.html b/Examples/java/variables/index.html index 07b19d4e7..05aaa2d6e 100644 --- a/Examples/java/variables/index.html +++ b/Examples/java/variables/index.html @@ -38,7 +38,7 @@ example.set_foo(12.3); -Click here to see the example program that updates and prints +Click here to see the example program that updates and prints out the values of the variables using this technique.

        Key points

        diff --git a/Examples/java/variables/runme.java b/Examples/java/variables/main.java similarity index 99% rename from Examples/java/variables/runme.java rename to Examples/java/variables/main.java index 361a30fa6..92745db99 100644 --- a/Examples/java/variables/runme.java +++ b/Examples/java/variables/main.java @@ -2,7 +2,7 @@ import java.lang.reflect.*; -public class runme { +public class main { static { try { System.loadLibrary("example"); diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp index e5e0e0a7d..c2424f9af 100644 --- a/Examples/lua/embed3/embed3.cpp +++ b/Examples/lua/embed3/embed3.cpp @@ -26,12 +26,7 @@ extern "C" { #include #include } - -/* The SWIG external runtime is generated by using. -swig -lua -externalruntime swigluarun.h -It contains useful function used by SWIG in its wrappering -SWIG_TypeQuery() SWIG_NewPointerObj() -*/ + #include "swigluarun.h" // the SWIG external runtime /* the SWIG wrappered library */ diff --git a/Examples/perl5/class/example.dsp b/Examples/perl5/class/example.dsp index b5ccd1928..bbdedc094 100644 --- a/Examples/perl5/class/example.dsp +++ b/Examples/perl5/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -c++ -perl5 $(InputPath) + ..\..\..\swig -c++ -perl5 $(InputPath) # End Custom Build @@ -141,7 +141,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -c++ -perl5 $(InputPath) + ..\..\..\swig -c++ -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/import/bar.dsp b/Examples/perl5/import/bar.dsp index 64786b8f6..682c21757 100644 --- a/Examples/perl5/import/bar.dsp +++ b/Examples/perl5/import/bar.dsp @@ -118,7 +118,7 @@ InputName=bar echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -c++ -perl5 $(InputPath) + ..\..\..\swig -c++ -perl5 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=bar echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -c++ -perl5 $(InputPath) + ..\..\..\swig -c++ -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/import/base.dsp b/Examples/perl5/import/base.dsp index 920891cbf..7a0ea8027 100644 --- a/Examples/perl5/import/base.dsp +++ b/Examples/perl5/import/base.dsp @@ -118,7 +118,7 @@ InputName=base echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -c++ -perl5 $(InputPath) + ..\..\..\swig -c++ -perl5 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=base echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -c++ -perl5 $(InputPath) + ..\..\..\swig -c++ -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/import/foo.dsp b/Examples/perl5/import/foo.dsp index d519a5316..755560165 100644 --- a/Examples/perl5/import/foo.dsp +++ b/Examples/perl5/import/foo.dsp @@ -118,7 +118,7 @@ InputName=foo echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -c++ -perl5 $(InputPath) + ..\..\..\swig -c++ -perl5 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=foo echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -c++ -perl5 $(InputPath) + ..\..\..\swig -c++ -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/import/spam.dsp b/Examples/perl5/import/spam.dsp index e5c8046eb..ed41de36b 100644 --- a/Examples/perl5/import/spam.dsp +++ b/Examples/perl5/import/spam.dsp @@ -118,7 +118,7 @@ InputName=spam echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -c++ -perl5 $(InputPath) + ..\..\..\swig -c++ -perl5 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=spam echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -c++ -perl5 $(InputPath) + ..\..\..\swig -c++ -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/multimap/example.dsp b/Examples/perl5/multimap/example.dsp index be8a0070e..2d295763b 100644 --- a/Examples/perl5/multimap/example.dsp +++ b/Examples/perl5/multimap/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -perl5 $(InputPath) + ..\..\..\swig -perl5 $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -perl5 $(InputPath) + ..\..\..\swig -perl5 $(InputPath) # End Custom Build diff --git a/Examples/perl5/simple/example.dsp b/Examples/perl5/simple/example.dsp index be8a0070e..2d295763b 100644 --- a/Examples/perl5/simple/example.dsp +++ b/Examples/perl5/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -perl5 $(InputPath) + ..\..\..\swig -perl5 $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE% echo PERL5_LIB: %PERL5_LIB% echo on - ..\..\..\swig.exe -perl5 $(InputPath) + ..\..\..\swig -perl5 $(InputPath) # End Custom Build diff --git a/Examples/php/variables/Makefile b/Examples/php/variables/Makefile deleted file mode 100644 index 0862ce5ec..000000000 --- a/Examples/php/variables/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -SRCS = example.c -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_static - -clean:: - $(MAKE) -f $(TOP)/Makefile php_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php/check.list b/Examples/php4/check.list similarity index 100% rename from Examples/php/check.list rename to Examples/php4/check.list diff --git a/Examples/php/class/Makefile b/Examples/php4/class/Makefile similarity index 71% rename from Examples/php/class/Makefile rename to Examples/php4/class/Makefile index 252a72660..39c4d2f23 100644 --- a/Examples/php/class/Makefile +++ b/Examples/php4/class/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php_cpp + php4_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/class/example.cxx b/Examples/php4/class/example.cxx similarity index 100% rename from Examples/php/class/example.cxx rename to Examples/php4/class/example.cxx diff --git a/Examples/php/class/example.h b/Examples/php4/class/example.h similarity index 100% rename from Examples/php/class/example.h rename to Examples/php4/class/example.h diff --git a/Examples/php/class/example.i b/Examples/php4/class/example.i similarity index 100% rename from Examples/php/class/example.i rename to Examples/php4/class/example.i diff --git a/Examples/php/class/runme.php b/Examples/php4/class/runme.php4 similarity index 100% rename from Examples/php/class/runme.php rename to Examples/php4/class/runme.php4 diff --git a/Examples/php/pragmas/Makefile b/Examples/php4/constants/Makefile similarity index 70% rename from Examples/php/pragmas/Makefile rename to Examples/php4/constants/Makefile index 23e2675d7..aed110eb2 100644 --- a/Examples/php/pragmas/Makefile +++ b/Examples/php4/constants/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php + php4 static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/constants/example.i b/Examples/php4/constants/example.i similarity index 100% rename from Examples/php/constants/example.i rename to Examples/php4/constants/example.i diff --git a/Examples/php/constants/runme.php b/Examples/php4/constants/runme.php4 similarity index 100% rename from Examples/php/constants/runme.php rename to Examples/php4/constants/runme.php4 diff --git a/Examples/php/funcptr/Makefile b/Examples/php4/cpointer/Makefile similarity index 71% rename from Examples/php/funcptr/Makefile rename to Examples/php4/cpointer/Makefile index 0862ce5ec..caeec2d73 100644 --- a/Examples/php/funcptr/Makefile +++ b/Examples/php4/cpointer/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php + php4 static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/cpointer/example.c b/Examples/php4/cpointer/example.c similarity index 100% rename from Examples/php/cpointer/example.c rename to Examples/php4/cpointer/example.c diff --git a/Examples/php/cpointer/example.i b/Examples/php4/cpointer/example.i similarity index 100% rename from Examples/php/cpointer/example.i rename to Examples/php4/cpointer/example.i diff --git a/Examples/php/cpointer/runme.php b/Examples/php4/cpointer/runme.php4 similarity index 100% rename from Examples/php/cpointer/runme.php rename to Examples/php4/cpointer/runme.php4 diff --git a/Examples/php/proxy/Makefile b/Examples/php4/disown/Makefile similarity index 70% rename from Examples/php/proxy/Makefile rename to Examples/php4/disown/Makefile index 1bc0beaab..ef3acc773 100644 --- a/Examples/php/proxy/Makefile +++ b/Examples/php4/disown/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php_cpp + php4_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/disown/example.cxx b/Examples/php4/disown/example.cxx similarity index 100% rename from Examples/php/disown/example.cxx rename to Examples/php4/disown/example.cxx diff --git a/Examples/php/disown/example.h b/Examples/php4/disown/example.h similarity index 100% rename from Examples/php/disown/example.h rename to Examples/php4/disown/example.h diff --git a/Examples/php/disown/example.i b/Examples/php4/disown/example.i similarity index 100% rename from Examples/php/disown/example.i rename to Examples/php4/disown/example.i diff --git a/Examples/php/disown/runme.php b/Examples/php4/disown/runme.php4 similarity index 100% rename from Examples/php/disown/runme.php rename to Examples/php4/disown/runme.php4 diff --git a/Examples/php/enum/Makefile b/Examples/php4/enum/Makefile similarity index 71% rename from Examples/php/enum/Makefile rename to Examples/php4/enum/Makefile index 252a72660..39c4d2f23 100644 --- a/Examples/php/enum/Makefile +++ b/Examples/php4/enum/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php_cpp + php4_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/enum/example.cxx b/Examples/php4/enum/example.cxx similarity index 100% rename from Examples/php/enum/example.cxx rename to Examples/php4/enum/example.cxx diff --git a/Examples/php/enum/example.h b/Examples/php4/enum/example.h similarity index 100% rename from Examples/php/enum/example.h rename to Examples/php4/enum/example.h diff --git a/Examples/php/enum/example.i b/Examples/php4/enum/example.i similarity index 100% rename from Examples/php/enum/example.i rename to Examples/php4/enum/example.i diff --git a/Examples/php/enum/runme.php b/Examples/php4/enum/runme.php4 similarity index 100% rename from Examples/php/enum/runme.php rename to Examples/php4/enum/runme.php4 diff --git a/Examples/php/simple/Makefile b/Examples/php4/funcptr/Makefile similarity index 71% rename from Examples/php/simple/Makefile rename to Examples/php4/funcptr/Makefile index 0862ce5ec..caeec2d73 100644 --- a/Examples/php/simple/Makefile +++ b/Examples/php4/funcptr/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php + php4 static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/funcptr/example.c b/Examples/php4/funcptr/example.c similarity index 100% rename from Examples/php/funcptr/example.c rename to Examples/php4/funcptr/example.c diff --git a/Examples/php/funcptr/example.h b/Examples/php4/funcptr/example.h similarity index 100% rename from Examples/php/funcptr/example.h rename to Examples/php4/funcptr/example.h diff --git a/Examples/php/funcptr/example.i b/Examples/php4/funcptr/example.i similarity index 100% rename from Examples/php/funcptr/example.i rename to Examples/php4/funcptr/example.i diff --git a/Examples/php/funcptr/runme.php b/Examples/php4/funcptr/runme.php4 similarity index 100% rename from Examples/php/funcptr/runme.php rename to Examples/php4/funcptr/runme.php4 diff --git a/Examples/php/sync/Makefile b/Examples/php4/overloading/Makefile similarity index 70% rename from Examples/php/sync/Makefile rename to Examples/php4/overloading/Makefile index 1bc0beaab..ef3acc773 100644 --- a/Examples/php/sync/Makefile +++ b/Examples/php4/overloading/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php_cpp + php4_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/overloading/example.cxx b/Examples/php4/overloading/example.cxx similarity index 78% rename from Examples/php/overloading/example.cxx rename to Examples/php4/overloading/example.cxx index 2f684f05c..fc7aff195 100644 --- a/Examples/php/overloading/example.cxx +++ b/Examples/php4/overloading/example.cxx @@ -34,22 +34,22 @@ double Square::perimeter(void) { return 4*width; } -const char *overloaded(int i) { +char *overloaded(int i) { return "Overloaded with int"; } -const char *overloaded(double d) { +char *overloaded(double d) { return "Overloaded with double"; } -const char *overloaded(const char * str) { +char *overloaded(const char * str) { return "Overloaded with char *"; } -const char *overloaded( const Circle& ) { +char *overloaded( const Circle& ) { return "Overloaded with Circle"; } -const char *overloaded( const Shape& ) { +char *overloaded( const Shape& ) { return "Overloaded with Shape"; } diff --git a/Examples/php/overloading/example.h b/Examples/php4/overloading/example.h similarity index 77% rename from Examples/php/overloading/example.h rename to Examples/php4/overloading/example.h index 01d71dd70..39ccc1cb1 100644 --- a/Examples/php/overloading/example.h +++ b/Examples/php4/overloading/example.h @@ -38,9 +38,9 @@ public: virtual double perimeter(void); }; -const char *overloaded( int i ); -const char *overloaded( double d ); -const char *overloaded( const char * str ); -const char *overloaded( const Circle& ); -const char *overloaded( const Shape& ); +char *overloaded( int i ); +char *overloaded( double d ); +char *overloaded( const char * str ); +char *overloaded( const Circle& ); +char *overloaded( const Shape& ); diff --git a/Examples/php/overloading/example.i b/Examples/php4/overloading/example.i similarity index 100% rename from Examples/php/overloading/example.i rename to Examples/php4/overloading/example.i diff --git a/Examples/php/overloading/runme.php b/Examples/php4/overloading/runme.php4 similarity index 100% rename from Examples/php/overloading/runme.php rename to Examples/php4/overloading/runme.php4 diff --git a/Examples/php/pointer/Makefile b/Examples/php4/pointer/Makefile similarity index 71% rename from Examples/php/pointer/Makefile rename to Examples/php4/pointer/Makefile index 0862ce5ec..caeec2d73 100644 --- a/Examples/php/pointer/Makefile +++ b/Examples/php4/pointer/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php + php4 static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/pointer/example.c b/Examples/php4/pointer/example.c similarity index 100% rename from Examples/php/pointer/example.c rename to Examples/php4/pointer/example.c diff --git a/Examples/php/pointer/example.i b/Examples/php4/pointer/example.i similarity index 100% rename from Examples/php/pointer/example.i rename to Examples/php4/pointer/example.i diff --git a/Examples/php/pointer/runme.php b/Examples/php4/pointer/runme.php4 similarity index 100% rename from Examples/php/pointer/runme.php rename to Examples/php4/pointer/runme.php4 diff --git a/Examples/php/constants/Makefile b/Examples/php4/pragmas/Makefile similarity index 70% rename from Examples/php/constants/Makefile rename to Examples/php4/pragmas/Makefile index 23e2675d7..aed110eb2 100644 --- a/Examples/php/constants/Makefile +++ b/Examples/php4/pragmas/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php + php4 static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/pragmas/example.i b/Examples/php4/pragmas/example.i similarity index 70% rename from Examples/php/pragmas/example.i rename to Examples/php4/pragmas/example.i index c7e8bf303..289d4ec99 100644 --- a/Examples/php/pragmas/example.i +++ b/Examples/php4/pragmas/example.i @@ -21,11 +21,11 @@ zend_printf("This was %%rshutdown\n"); } -%pragma(php) include="include.php"; +%pragma(php4) include="include.php"; -%pragma(php) code=" +%pragma(php4) code=" # This code is inserted into example.php -echo \"this was php code\\n\"; +echo \"this was php4 code\\n\"; " -%pragma(php) phpinfo="php_info_print_table_start();" +%pragma(php4) phpinfo="php_info_print_table_start();" diff --git a/Examples/php/pragmas/include.php b/Examples/php4/pragmas/include.php similarity index 100% rename from Examples/php/pragmas/include.php rename to Examples/php4/pragmas/include.php diff --git a/Examples/php/pragmas/runme.php b/Examples/php4/pragmas/runme.php4 similarity index 100% rename from Examples/php/pragmas/runme.php rename to Examples/php4/pragmas/runme.php4 diff --git a/Examples/php/disown/Makefile b/Examples/php4/proxy/Makefile similarity index 70% rename from Examples/php/disown/Makefile rename to Examples/php4/proxy/Makefile index 1bc0beaab..ef3acc773 100644 --- a/Examples/php/disown/Makefile +++ b/Examples/php4/proxy/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php_cpp + php4_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/proxy/example.cxx b/Examples/php4/proxy/example.cxx similarity index 100% rename from Examples/php/proxy/example.cxx rename to Examples/php4/proxy/example.cxx diff --git a/Examples/php/proxy/example.h b/Examples/php4/proxy/example.h similarity index 100% rename from Examples/php/proxy/example.h rename to Examples/php4/proxy/example.h diff --git a/Examples/php/proxy/example.i b/Examples/php4/proxy/example.i similarity index 100% rename from Examples/php/proxy/example.i rename to Examples/php4/proxy/example.i diff --git a/Examples/php/proxy/runme.php b/Examples/php4/proxy/runme.php4 similarity index 100% rename from Examples/php/proxy/runme.php rename to Examples/php4/proxy/runme.php4 diff --git a/Examples/php4/reference/BUILD-proxy.sh b/Examples/php4/reference/BUILD-proxy.sh new file mode 100755 index 000000000..b1c8c71a4 --- /dev/null +++ b/Examples/php4/reference/BUILD-proxy.sh @@ -0,0 +1,5 @@ +#! /bin/sh -e + +${SWIG:=swig} -php4 -make -c++ -withcxx example.cxx example.i +make +php -d extension_dir=. runme-proxy.php4 diff --git a/Examples/php/reference/Makefile b/Examples/php4/reference/Makefile similarity index 71% rename from Examples/php/reference/Makefile rename to Examples/php4/reference/Makefile index 252a72660..39c4d2f23 100644 --- a/Examples/php/reference/Makefile +++ b/Examples/php4/reference/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php_cpp + php4_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/reference/example.cxx b/Examples/php4/reference/example.cxx similarity index 100% rename from Examples/php/reference/example.cxx rename to Examples/php4/reference/example.cxx diff --git a/Examples/php/reference/example.h b/Examples/php4/reference/example.h similarity index 100% rename from Examples/php/reference/example.h rename to Examples/php4/reference/example.h diff --git a/Examples/php/reference/example.i b/Examples/php4/reference/example.i similarity index 100% rename from Examples/php/reference/example.i rename to Examples/php4/reference/example.i diff --git a/Examples/php/reference/runme-proxy.php4 b/Examples/php4/reference/runme-proxy.php4 similarity index 100% rename from Examples/php/reference/runme-proxy.php4 rename to Examples/php4/reference/runme-proxy.php4 diff --git a/Examples/php/reference/runme.php b/Examples/php4/reference/runme.php4 similarity index 100% rename from Examples/php/reference/runme.php rename to Examples/php4/reference/runme.php4 diff --git a/Examples/php/cpointer/Makefile b/Examples/php4/simple/Makefile similarity index 71% rename from Examples/php/cpointer/Makefile rename to Examples/php4/simple/Makefile index 0862ce5ec..caeec2d73 100644 --- a/Examples/php/cpointer/Makefile +++ b/Examples/php4/simple/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php + php4 static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/simple/example.c b/Examples/php4/simple/example.c similarity index 100% rename from Examples/php/simple/example.c rename to Examples/php4/simple/example.c diff --git a/Examples/php/simple/example.i b/Examples/php4/simple/example.i similarity index 100% rename from Examples/php/simple/example.i rename to Examples/php4/simple/example.i diff --git a/Examples/php/simple/runme.php b/Examples/php4/simple/runme.php4 similarity index 100% rename from Examples/php/simple/runme.php rename to Examples/php4/simple/runme.php4 diff --git a/Examples/php/overloading/Makefile b/Examples/php4/sync/Makefile similarity index 70% rename from Examples/php/overloading/Makefile rename to Examples/php4/sync/Makefile index 1bc0beaab..ef3acc773 100644 --- a/Examples/php/overloading/Makefile +++ b/Examples/php4/sync/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php_cpp + php4_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/sync/example.cxx b/Examples/php4/sync/example.cxx similarity index 91% rename from Examples/php/sync/example.cxx rename to Examples/php4/sync/example.cxx index 31ed2021b..47378924b 100644 --- a/Examples/php/sync/example.cxx +++ b/Examples/php4/sync/example.cxx @@ -2,7 +2,7 @@ #include int x = 42; -char *s = (char *)"Test"; +char *s = "Test"; void Sync::printer(void) { diff --git a/Examples/php/sync/example.h b/Examples/php4/sync/example.h similarity index 100% rename from Examples/php/sync/example.h rename to Examples/php4/sync/example.h diff --git a/Examples/php/sync/example.i b/Examples/php4/sync/example.i similarity index 100% rename from Examples/php/sync/example.i rename to Examples/php4/sync/example.i diff --git a/Examples/php/sync/runme.php b/Examples/php4/sync/runme.php4 similarity index 100% rename from Examples/php/sync/runme.php rename to Examples/php4/sync/runme.php4 diff --git a/Examples/php/value/Makefile b/Examples/php4/value/Makefile similarity index 71% rename from Examples/php/value/Makefile rename to Examples/php4/value/Makefile index 9e69d00a4..cc383ea3f 100644 --- a/Examples/php/value/Makefile +++ b/Examples/php4/value/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php + php4 static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ - php_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_static clean:: - $(MAKE) -f $(TOP)/Makefile php_clean + $(MAKE) -f $(TOP)/Makefile php4_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php_run + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/value/example.c b/Examples/php4/value/example.c similarity index 100% rename from Examples/php/value/example.c rename to Examples/php4/value/example.c diff --git a/Examples/php/value/example.h b/Examples/php4/value/example.h similarity index 100% rename from Examples/php/value/example.h rename to Examples/php4/value/example.h diff --git a/Examples/php/value/example.i b/Examples/php4/value/example.i similarity index 100% rename from Examples/php/value/example.i rename to Examples/php4/value/example.i diff --git a/Examples/php/value/runme.php b/Examples/php4/value/runme.php4 similarity index 100% rename from Examples/php/value/runme.php rename to Examples/php4/value/runme.php4 diff --git a/Examples/php4/variables/Makefile b/Examples/php4/variables/Makefile new file mode 100644 index 000000000..caeec2d73 --- /dev/null +++ b/Examples/php4/variables/Makefile @@ -0,0 +1,24 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +LIBS = +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + php4 + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ + php4_static + +clean:: + $(MAKE) -f $(TOP)/Makefile php4_clean + rm -f $(TARGET).php + +check: all + $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/php/variables/example.c b/Examples/php4/variables/example.c similarity index 100% rename from Examples/php/variables/example.c rename to Examples/php4/variables/example.c diff --git a/Examples/php/variables/example.h b/Examples/php4/variables/example.h similarity index 100% rename from Examples/php/variables/example.h rename to Examples/php4/variables/example.h diff --git a/Examples/php/variables/example.i b/Examples/php4/variables/example.i similarity index 100% rename from Examples/php/variables/example.i rename to Examples/php4/variables/example.i diff --git a/Examples/php/variables/runme.php b/Examples/php4/variables/runme.php4 similarity index 100% rename from Examples/php/variables/runme.php rename to Examples/php4/variables/runme.php4 diff --git a/Examples/php/variables/runme.php4.old b/Examples/php4/variables/runme.php4.old similarity index 100% rename from Examples/php/variables/runme.php4.old rename to Examples/php4/variables/runme.php4.old diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile old mode 100644 new mode 100755 diff --git a/Examples/pike/class/example.cxx b/Examples/pike/class/example.cxx old mode 100644 new mode 100755 diff --git a/Examples/pike/class/example.h b/Examples/pike/class/example.h old mode 100644 new mode 100755 diff --git a/Examples/pike/class/example.i b/Examples/pike/class/example.i old mode 100644 new mode 100755 diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile old mode 100644 new mode 100755 diff --git a/Examples/pike/constants/example.i b/Examples/pike/constants/example.i old mode 100644 new mode 100755 diff --git a/Examples/pike/overload/example.cxx b/Examples/pike/overload/example.cxx old mode 100644 new mode 100755 diff --git a/Examples/pike/overload/example.h b/Examples/pike/overload/example.h old mode 100644 new mode 100755 diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile old mode 100644 new mode 100755 diff --git a/Examples/pike/template/example.h b/Examples/pike/template/example.h old mode 100644 new mode 100755 diff --git a/Examples/pike/template/example.i b/Examples/pike/template/example.i old mode 100644 new mode 100755 diff --git a/Examples/python/callback/Makefile b/Examples/python/callback/Makefile index a29276e58..ad36d7d7e 100644 --- a/Examples/python/callback/Makefile +++ b/Examples/python/callback/Makefile @@ -19,4 +19,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/class/Makefile b/Examples/python/class/Makefile index 74625b992..f331b8203 100644 --- a/Examples/python/class/Makefile +++ b/Examples/python/class/Makefile @@ -18,4 +18,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/class/example.dsp b/Examples/python/class/example.dsp index fd7bf8c06..dccba46b0 100644 --- a/Examples/python/class/example.dsp +++ b/Examples/python/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -c++ -python $(InputPath) + ..\..\..\swig -c++ -python $(InputPath) # End Custom Build @@ -141,7 +141,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -c++ -python $(InputPath) + ..\..\..\swig -c++ -python $(InputPath) # End Custom Build diff --git a/Examples/python/class/example.i b/Examples/python/class/example.i index 75700b305..0bf3285ca 100644 --- a/Examples/python/class/example.i +++ b/Examples/python/class/example.i @@ -5,6 +5,10 @@ #include "example.h" %} +%typemap(in) double { + /* hello */ +} + /* Let's just grab the original header file here */ %include "example.h" diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile index 1420b4e0b..01d0f943a 100644 --- a/Examples/python/constants/Makefile +++ b/Examples/python/constants/Makefile @@ -17,4 +17,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/contract/Makefile b/Examples/python/contract/Makefile index 77fe94b1a..c7b476995 100644 --- a/Examples/python/contract/Makefile +++ b/Examples/python/contract/Makefile @@ -17,4 +17,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/contract/example.dsp b/Examples/python/contract/example.dsp index 32845e0e8..7a32f4dc1 100644 --- a/Examples/python/contract/example.dsp +++ b/Examples/python/contract/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -python $(InputPath) + ..\..\..\swig -python $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -python $(InputPath) + ..\..\..\swig -python $(InputPath) # End Custom Build diff --git a/Examples/python/docstrings/Makefile b/Examples/python/docstrings/Makefile index f25450cac..74ab112a1 100644 --- a/Examples/python/docstrings/Makefile +++ b/Examples/python/docstrings/Makefile @@ -21,4 +21,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/enum/Makefile b/Examples/python/enum/Makefile index 74625b992..f331b8203 100644 --- a/Examples/python/enum/Makefile +++ b/Examples/python/enum/Makefile @@ -18,4 +18,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile index 7dbdde944..17c4f30b7 100644 --- a/Examples/python/exception/Makefile +++ b/Examples/python/exception/Makefile @@ -18,4 +18,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/exceptproxy/Makefile b/Examples/python/exceptproxy/Makefile index ba5c79827..a4f334311 100644 --- a/Examples/python/exceptproxy/Makefile +++ b/Examples/python/exceptproxy/Makefile @@ -19,4 +19,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/extend/Makefile b/Examples/python/extend/Makefile index a29276e58..ad36d7d7e 100644 --- a/Examples/python/extend/Makefile +++ b/Examples/python/extend/Makefile @@ -19,4 +19,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile index 0f4a1e077..4a1e1bb71 100644 --- a/Examples/python/funcptr/Makefile +++ b/Examples/python/funcptr/Makefile @@ -17,4 +17,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/funcptr2/Makefile b/Examples/python/funcptr2/Makefile index 0f4a1e077..4a1e1bb71 100644 --- a/Examples/python/funcptr2/Makefile +++ b/Examples/python/funcptr2/Makefile @@ -17,4 +17,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/functor/Makefile b/Examples/python/functor/Makefile index fe389757a..c45536529 100644 --- a/Examples/python/functor/Makefile +++ b/Examples/python/functor/Makefile @@ -19,4 +19,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile index 74d4f88cf..e00e81864 100644 --- a/Examples/python/import/Makefile +++ b/Examples/python/import/Makefile @@ -19,4 +19,3 @@ clean:: @rm -f foo.py bar.py spam.py base.py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/import/bar.dsp b/Examples/python/import/bar.dsp index 17b05cc39..edb45811b 100644 --- a/Examples/python/import/bar.dsp +++ b/Examples/python/import/bar.dsp @@ -118,7 +118,7 @@ InputName=bar echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -c++ -python $(InputPath) + ..\..\..\swig -c++ -python $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=bar echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -c++ -python $(InputPath) + ..\..\..\swig -c++ -python $(InputPath) # End Custom Build diff --git a/Examples/python/import/base.dsp b/Examples/python/import/base.dsp index 2bc9736d1..0ddb65157 100644 --- a/Examples/python/import/base.dsp +++ b/Examples/python/import/base.dsp @@ -118,7 +118,7 @@ InputName=base echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -c++ -python $(InputPath) + ..\..\..\swig -c++ -python $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=base echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -c++ -python $(InputPath) + ..\..\..\swig -c++ -python $(InputPath) # End Custom Build diff --git a/Examples/python/import/foo.dsp b/Examples/python/import/foo.dsp index 9a92c4b85..86e11699f 100644 --- a/Examples/python/import/foo.dsp +++ b/Examples/python/import/foo.dsp @@ -118,7 +118,7 @@ InputName=foo echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -c++ -python $(InputPath) + ..\..\..\swig -c++ -python $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=foo echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -c++ -python $(InputPath) + ..\..\..\swig -c++ -python $(InputPath) # End Custom Build diff --git a/Examples/python/import/spam.dsp b/Examples/python/import/spam.dsp index 0a6595bfe..7245f7a7c 100644 --- a/Examples/python/import/spam.dsp +++ b/Examples/python/import/spam.dsp @@ -118,7 +118,7 @@ InputName=spam echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -c++ -python $(InputPath) + ..\..\..\swig -c++ -python $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=spam echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -c++ -python $(InputPath) + ..\..\..\swig -c++ -python $(InputPath) # End Custom Build diff --git a/Examples/python/import_template/Makefile b/Examples/python/import_template/Makefile index ee47e994d..fa49f3145 100644 --- a/Examples/python/import_template/Makefile +++ b/Examples/python/import_template/Makefile @@ -19,4 +19,3 @@ clean:: @rm -f foo.py bar.py spam.py base.py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/libffi/Makefile b/Examples/python/libffi/Makefile index fafb7de09..8c7edfa65 100644 --- a/Examples/python/libffi/Makefile +++ b/Examples/python/libffi/Makefile @@ -17,4 +17,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/multimap/Makefile b/Examples/python/multimap/Makefile index 0f4a1e077..4a1e1bb71 100644 --- a/Examples/python/multimap/Makefile +++ b/Examples/python/multimap/Makefile @@ -17,4 +17,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/multimap/example.dsp b/Examples/python/multimap/example.dsp index 32845e0e8..7a32f4dc1 100644 --- a/Examples/python/multimap/example.dsp +++ b/Examples/python/multimap/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -python $(InputPath) + ..\..\..\swig -python $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -python $(InputPath) + ..\..\..\swig -python $(InputPath) # End Custom Build diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i index f1c4d9990..163d7cc8e 100644 --- a/Examples/python/multimap/example.i +++ b/Examples/python/multimap/example.i @@ -27,24 +27,11 @@ extern int gcd(int x, int y); $2 = (char **) malloc(($1+1)*sizeof(char *)); for (i = 0; i < $1; i++) { PyObject *s = PyList_GetItem($input,i); -%#if PY_VERSION_HEX >= 0x03000000 - if (!PyUnicode_Check(s)) -%#else - if (!PyString_Check(s)) -%#endif - { + if (!PyString_Check(s)) { free($2); SWIG_exception(SWIG_ValueError, "List items must be strings"); } -%#if PY_VERSION_HEX >= 0x03000000 - { - int l; - $2[i] = PyUnicode_AsStringAndSize(s, &l); - } -%#else $2[i] = PyString_AsString(s); -%#endif - } $2[i] = 0; } @@ -52,21 +39,12 @@ extern int gcd(int x, int y); extern int gcdmain(int argc, char *argv[]); %typemap(in) (char *bytes, int len) { - -%#if PY_VERSION_HEX >= 0x03000000 - if (!PyUnicode_Check($input)) { - PyErr_SetString(PyExc_ValueError,"Expected a string"); - return NULL; - } - $1 = PyUnicode_AsStringAndSize($input, &$2); -%#else if (!PyString_Check($input)) { PyErr_SetString(PyExc_ValueError,"Expected a string"); return NULL; } $1 = PyString_AsString($input); $2 = PyString_Size($input); -%#endif } extern int count(char *bytes, int len, char c); @@ -78,15 +56,9 @@ extern int count(char *bytes, int len, char c); so that we don't violate it's mutability */ %typemap(in) (char *str, int len) { -%#if PY_VERSION_HEX >= 0x03000000 - $2 = PyUnicode_GetSize($input); - $1 = (char *) malloc($2+1); - memmove($1,PyUnicode_AsString($input),$2); -%#else $2 = PyString_Size($input); $1 = (char *) malloc($2+1); memmove($1,PyString_AsString($input),$2); -%#endif } /* Return the mutated string as a new object. The t_output_helper @@ -95,11 +67,7 @@ extern int count(char *bytes, int len, char c); %typemap(argout) (char *str, int len) { PyObject *o; -%#if PY_VERSION_HEX >= 0x03000000 - o = PyUnicode_FromStringAndSize($1,$2); -%#else o = PyString_FromStringAndSize($1,$2); -%#endif $result = t_output_helper($result,o); free($1); } diff --git a/Examples/python/operator/Makefile b/Examples/python/operator/Makefile index fe389757a..c45536529 100644 --- a/Examples/python/operator/Makefile +++ b/Examples/python/operator/Makefile @@ -19,4 +19,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/pointer/Makefile b/Examples/python/pointer/Makefile index 0f4a1e077..4a1e1bb71 100644 --- a/Examples/python/pointer/Makefile +++ b/Examples/python/pointer/Makefile @@ -17,4 +17,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/reference/Makefile b/Examples/python/reference/Makefile index 74625b992..f331b8203 100644 --- a/Examples/python/reference/Makefile +++ b/Examples/python/reference/Makefile @@ -18,4 +18,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/simple/Makefile b/Examples/python/simple/Makefile index 0f4a1e077..4a1e1bb71 100644 --- a/Examples/python/simple/Makefile +++ b/Examples/python/simple/Makefile @@ -17,4 +17,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/simple/example.dsp b/Examples/python/simple/example.dsp index 32845e0e8..7a32f4dc1 100644 --- a/Examples/python/simple/example.dsp +++ b/Examples/python/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -python $(InputPath) + ..\..\..\swig -python $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo PYTHON_INCLUDE: %PYTHON_INCLUDE% echo PYTHON_LIB: %PYTHON_LIB% echo on - ..\..\..\swig.exe -python $(InputPath) + ..\..\..\swig -python $(InputPath) # End Custom Build diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile index f73802a6b..58d139643 100644 --- a/Examples/python/smartptr/Makefile +++ b/Examples/python/smartptr/Makefile @@ -19,4 +19,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/std_map/Makefile b/Examples/python/std_map/Makefile index 5d13da764..2d4c1b4a3 100644 --- a/Examples/python/std_map/Makefile +++ b/Examples/python/std_map/Makefile @@ -22,4 +22,3 @@ run: python runme.py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/std_map/example.i b/Examples/python/std_map/example.i index 6a7af7108..36354a882 100644 --- a/Examples/python/std_map/example.i +++ b/Examples/python/std_map/example.i @@ -23,5 +23,5 @@ namespace std { %template(halfi) half_map; -%template() std::pair; -%template(pymap) std::map; +%template() std::pair; +%template(pymap) std::map; diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile index ba5c79827..a4f334311 100644 --- a/Examples/python/std_vector/Makefile +++ b/Examples/python/std_vector/Makefile @@ -19,4 +19,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/swigrun/Makefile b/Examples/python/swigrun/Makefile index 2142be5bb..53bf701c9 100644 --- a/Examples/python/swigrun/Makefile +++ b/Examples/python/swigrun/Makefile @@ -22,4 +22,3 @@ clean:: check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile index ba5c79827..a4f334311 100644 --- a/Examples/python/template/Makefile +++ b/Examples/python/template/Makefile @@ -19,4 +19,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/varargs/Makefile b/Examples/python/varargs/Makefile index 1420b4e0b..01d0f943a 100644 --- a/Examples/python/varargs/Makefile +++ b/Examples/python/varargs/Makefile @@ -17,4 +17,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/variables/Makefile b/Examples/python/variables/Makefile index 0f4a1e077..4a1e1bb71 100644 --- a/Examples/python/variables/Makefile +++ b/Examples/python/variables/Makefile @@ -17,4 +17,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/weave/Makefile b/Examples/python/weave/Makefile index 88f95c095..822779bd1 100644 --- a/Examples/python/weave/Makefile +++ b/Examples/python/weave/Makefile @@ -19,4 +19,3 @@ clean:: rm -f $(TARGET).py check: all - $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/r/class/example.dsp b/Examples/r/class/example.dsp index b831989cc..682b156fb 100644 --- a/Examples/r/class/example.dsp +++ b/Examples/r/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on - ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath) + ..\..\..\swig -c++ -r -o example_wrap.cpp $(InputPath) # End Custom Build @@ -141,7 +141,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on - ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath) + ..\..\..\swig -c++ -r -o example_wrap.cpp $(InputPath) # End Custom Build diff --git a/Examples/r/simple/example.dsp b/Examples/r/simple/example.dsp index 356815d19..aaa5ef8e0 100644 --- a/Examples/r/simple/example.dsp +++ b/Examples/r/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on - ..\..\..\swig.exe -r $(InputPath) + ..\..\..\swig -r $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE% echo R_LIB: %R_LIB% echo on - ..\..\..\swig.exe -r $(InputPath) + ..\..\..\swig -r $(InputPath) # End Custom Build diff --git a/Examples/ruby/class/example.dsp b/Examples/ruby/class/example.dsp index 2adab787a..9a26322ec 100644 --- a/Examples/ruby/class/example.dsp +++ b/Examples/ruby/class/example.dsp @@ -128,7 +128,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build @@ -143,7 +143,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/free_function/example.dsp b/Examples/ruby/free_function/example.dsp index 2adab787a..9a26322ec 100644 --- a/Examples/ruby/free_function/example.dsp +++ b/Examples/ruby/free_function/example.dsp @@ -128,7 +128,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build @@ -143,7 +143,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/free_function/example.i b/Examples/ruby/free_function/example.i index a446b3f99..5ab29bd58 100644 --- a/Examples/ruby/free_function/example.i +++ b/Examples/ruby/free_function/example.i @@ -20,7 +20,7 @@ static void free_Zoo(void* ptr) { Zoo* zoo = (Zoo*) ptr; - /* Loop over each object and call SWIG_RubyRemoveTracking */ + /* Loop over each object and call SWIG_RemoveMapping */ int count = zoo->get_num_animals(); for(int i = 0; i < count; ++i) { @@ -32,7 +32,7 @@ SWIG_RubyRemoveTracking(animal); } - /* Now call SWIG_RubyRemoveTracking for the zoo */ + /* Now call SWIG_RemoveMapping for the zoo */ SWIG_RubyRemoveTracking(ptr); /* Now free the zoo which will free the animals it contains */ diff --git a/Examples/ruby/hashargs/Makefile b/Examples/ruby/hashargs/Makefile old mode 100644 new mode 100755 diff --git a/Examples/ruby/hashargs/example.i b/Examples/ruby/hashargs/example.i old mode 100644 new mode 100755 diff --git a/Examples/ruby/import/bar.dsp b/Examples/ruby/import/bar.dsp index 29d9abf2f..dd09ca021 100644 --- a/Examples/ruby/import/bar.dsp +++ b/Examples/ruby/import/bar.dsp @@ -120,7 +120,7 @@ InputName=bar echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build @@ -135,7 +135,7 @@ InputName=bar echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/import/base.dsp b/Examples/ruby/import/base.dsp index 174afef3e..2bd4fa243 100644 --- a/Examples/ruby/import/base.dsp +++ b/Examples/ruby/import/base.dsp @@ -120,7 +120,7 @@ InputName=base echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build @@ -135,7 +135,7 @@ InputName=base echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/import/foo.dsp b/Examples/ruby/import/foo.dsp index 7f4754915..2a764bbd7 100644 --- a/Examples/ruby/import/foo.dsp +++ b/Examples/ruby/import/foo.dsp @@ -120,7 +120,7 @@ InputName=foo echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build @@ -135,7 +135,7 @@ InputName=foo echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/import/spam.dsp b/Examples/ruby/import/spam.dsp index 72729f290..d2d7158bb 100644 --- a/Examples/ruby/import/spam.dsp +++ b/Examples/ruby/import/spam.dsp @@ -120,7 +120,7 @@ InputName=spam echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build @@ -135,7 +135,7 @@ InputName=spam echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/mark_function/example.dsp b/Examples/ruby/mark_function/example.dsp index 2adab787a..9a26322ec 100644 --- a/Examples/ruby/mark_function/example.dsp +++ b/Examples/ruby/mark_function/example.dsp @@ -128,7 +128,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build @@ -143,7 +143,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -c++ -ruby $(InputPath) + ..\..\..\swig -c++ -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/multimap/example.dsp b/Examples/ruby/multimap/example.dsp index 4888299f5..ccb99d44d 100644 --- a/Examples/ruby/multimap/example.dsp +++ b/Examples/ruby/multimap/example.dsp @@ -124,7 +124,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -ruby $(InputPath) + ..\..\..\swig -ruby $(InputPath) # End Custom Build @@ -139,7 +139,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -ruby $(InputPath) + ..\..\..\swig -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/simple/example.dsp b/Examples/ruby/simple/example.dsp index 4888299f5..ccb99d44d 100644 --- a/Examples/ruby/simple/example.dsp +++ b/Examples/ruby/simple/example.dsp @@ -124,7 +124,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -ruby $(InputPath) + ..\..\..\swig -ruby $(InputPath) # End Custom Build @@ -139,7 +139,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE% echo RUBY_LIB: %RUBY_LIB% echo on - ..\..\..\swig.exe -ruby $(InputPath) + ..\..\..\swig -ruby $(InputPath) # End Custom Build diff --git a/Examples/ruby/std_vector/runme.rb b/Examples/ruby/std_vector/runme.rb index 851190536..1529d38c6 100644 --- a/Examples/ruby/std_vector/runme.rb +++ b/Examples/ruby/std_vector/runme.rb @@ -9,7 +9,7 @@ puts Example::average([1,2,3,4]) # ... or a wrapped std::vector v = Example::IntVector.new(4) -0.upto(v.size-1) { |i| v[i] = i+1 } +0.upto(v.length-1) { |i| v[i] = i+1 } puts Example::average(v) @@ -17,7 +17,7 @@ puts Example::average(v) # Call it with a Ruby array... w = Example::half([1.0, 1.5, 2.0, 2.5, 3.0]) -0.upto(w.size-1) { |i| print w[i],"; " } +0.upto(w.length-1) { |i| print w[i],"; " } puts # ... or a wrapped std::vector @@ -25,12 +25,12 @@ puts v = Example::DoubleVector.new [1,2,3,4].each { |i| v.push(i) } w = Example::half(v) -0.upto(w.size-1) { |i| print w[i],"; " } +0.upto(w.length-1) { |i| print w[i],"; " } puts # now halve a wrapped std::vector in place Example::halve_in_place(v) -0.upto(v.size-1) { |i| print v[i],"; " } +0.upto(v.length-1) { |i| print v[i],"; " } puts diff --git a/Examples/tcl/class/example.dsp b/Examples/tcl/class/example.dsp index 0ff54829f..bf6149407 100644 --- a/Examples/tcl/class/example.dsp +++ b/Examples/tcl/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -c++ -tcl8 $(InputPath) + ..\..\..\swig -c++ -tcl8 $(InputPath) # End Custom Build @@ -141,7 +141,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -c++ -tcl8 $(InputPath) + ..\..\..\swig -c++ -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/contract/example.dsp b/Examples/tcl/contract/example.dsp index c1568f2c5..296cb313b 100644 --- a/Examples/tcl/contract/example.dsp +++ b/Examples/tcl/contract/example.dsp @@ -122,7 +122,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -tcl8 $(InputPath) + ..\..\..\swig -tcl8 $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -tcl8 $(InputPath) + ..\..\..\swig -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/import/bar.dsp b/Examples/tcl/import/bar.dsp index d22b6a6fa..35b4e608b 100644 --- a/Examples/tcl/import/bar.dsp +++ b/Examples/tcl/import/bar.dsp @@ -118,7 +118,7 @@ InputName=bar echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -c++ -tcl8 $(InputPath) + ..\..\..\swig -c++ -tcl8 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=bar echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -c++ -tcl8 $(InputPath) + ..\..\..\swig -c++ -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/import/base.dsp b/Examples/tcl/import/base.dsp index b27bbfdb6..74870ccb0 100644 --- a/Examples/tcl/import/base.dsp +++ b/Examples/tcl/import/base.dsp @@ -118,7 +118,7 @@ InputName=base echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -c++ -tcl8 $(InputPath) + ..\..\..\swig -c++ -tcl8 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=base echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -c++ -tcl8 $(InputPath) + ..\..\..\swig -c++ -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/import/foo.dsp b/Examples/tcl/import/foo.dsp index 4d3765bd7..ac7f09f06 100644 --- a/Examples/tcl/import/foo.dsp +++ b/Examples/tcl/import/foo.dsp @@ -118,7 +118,7 @@ InputName=foo echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -c++ -tcl8 $(InputPath) + ..\..\..\swig -c++ -tcl8 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=foo echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -c++ -tcl8 $(InputPath) + ..\..\..\swig -c++ -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/import/spam.dsp b/Examples/tcl/import/spam.dsp index 5674c4373..db9ade0a3 100644 --- a/Examples/tcl/import/spam.dsp +++ b/Examples/tcl/import/spam.dsp @@ -118,7 +118,7 @@ InputName=spam echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -c++ -tcl8 $(InputPath) + ..\..\..\swig -c++ -tcl8 $(InputPath) # End Custom Build @@ -133,7 +133,7 @@ InputName=spam echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -c++ -tcl8 $(InputPath) + ..\..\..\swig -c++ -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/multimap/example.dsp b/Examples/tcl/multimap/example.dsp index c1568f2c5..296cb313b 100644 --- a/Examples/tcl/multimap/example.dsp +++ b/Examples/tcl/multimap/example.dsp @@ -122,7 +122,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -tcl8 $(InputPath) + ..\..\..\swig -tcl8 $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -tcl8 $(InputPath) + ..\..\..\swig -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/tcl/simple/example.dsp b/Examples/tcl/simple/example.dsp index c1568f2c5..296cb313b 100644 --- a/Examples/tcl/simple/example.dsp +++ b/Examples/tcl/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -tcl8 $(InputPath) + ..\..\..\swig -tcl8 $(InputPath) # End Custom Build @@ -137,7 +137,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE% echo TCL_LIB: %TCL_LIB% echo on - ..\..\..\swig.exe -tcl8 $(InputPath) + ..\..\..\swig -tcl8 $(InputPath) # End Custom Build diff --git a/Examples/test-suite/abstract_virtual.i b/Examples/test-suite/abstract_virtual.i index 2e4d105b1..e2d8054bb 100644 --- a/Examples/test-suite/abstract_virtual.i +++ b/Examples/test-suite/abstract_virtual.i @@ -2,10 +2,10 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) D; /* C#, Java, Php4 multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) E; /* C#, Java, Php4 multiple inheritance */ %inline %{ #if defined(_MSC_VER) diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in index df7193389..394d2d524 100644 --- a/Examples/test-suite/allegrocl/Makefile.in +++ b/Examples/test-suite/allegrocl/Makefile.in @@ -9,75 +9,116 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ - -# these cpp tests generate warnings/errors when compiling -# the wrapper .cxx file. -CPP_TEST_BROKEN_CXX = -# the error is wrap:action code generated by swig. \ -# error: can't convert [std::string] 'b' to 'bool' \ -# might just need a bool overload op for std::string. \ - global_vars \ -# same as w/ global_vars but with more errors in cxx file \ - naturalvar \ - # these cpp tests aren't working. Fix 'em # need to further separate these into tests requiring # std libraries, or the $ldestructor problem. CPP_TEST_BROKEN_ACL = \ + array_member \ + char_strings \ + class_ignore \ + constant_pointers \ contract \ - allprotected \ -# 'throws' typemap entries. \ cplusplus_throw \ -# 'throws' typemap entries. \ + cpp_basic \ + cpp_enum \ + cpp_typedef \ + default_constructor \ default_args \ -# missing typemaps. suspect module support needed \ dynamic_cast \ + enum_thorough \ extend_variable \ -# cdata.i support needed \ + global_vars \ + import_nomodule \ + kind \ + li_carrays \ li_cdata \ -# warning generated. otherwise all good. \ + li_windows \ + namespace_class \ + namespace_spaces \ + naturalvar \ operator_overload \ -# std_common.i support \ + overload_simple \ + register_par \ sizet \ -# std_vector.i support. \ + smart_pointer_extend \ + smart_pointer_namespace \ + template \ + template_classes \ template_default \ -# *** line 31. can't copy typemap?? \ + template_default_inherit \ + template_enum \ + template_explicit \ + template_extend_overload \ + template_ns \ + template_ns4 \ + template_ns_enum \ + template_rename \ + template_retvalue \ + template_static \ + template_tbase_template \ + template_typedef \ + template_typedef_cplx \ + template_typedef_cplx2 \ + template_typedef_cplx3 \ + template_typedef_cplx4 \ + template_typedef_cplx5 \ + template_typedef_ns \ + template_typedef_rec \ + threads \ + typedef_array_member \ + typedef_sizet \ typemap_namespace \ + union_scope \ + using_pointers \ + valuewrapper_opaque \ + varargs \ + virtual_poly \ + voidtest \ + wrapmacro # these aren't working due to longlong support. (low hanging fruit) CPP_TEST_BROKEN_LONGLONG = \ arrays_dimensionless \ arrays_global \ arrays_global_twodim \ + li_stdint \ li_typemaps \ - li_windows \ long_long_apply \ + mixed_types \ primitive_ref \ reference_global_vars \ template_default_arg # These are currently unsupported. CPP_TEST_CASES_ACL_UNSUPPORTED = \ -# contract support \ aggregate \ -# directors support \ - apply_signed_char \ -# contract support \ contract \ + director_abstract \ + director_basic \ + director_constructor \ + director_detect \ + director_default \ + director_enum \ director_exception \ + director_frob \ + director_finalizer \ + director_nested \ director_protected \ + director_redefined \ + director_unroll \ + director_using \ + director_wombat \ exception_order \ -# 'throws' typemap support \ extern_throws \ - throw_exception \ - using_pointers \ + throw_exception C_TEST_CASES_ACL_BROKEN = \ -# 'cdate.i' module support \ + arrays \ + enums \ + extern_declaration \ + immutable \ + integers \ li_cdata \ -# adding an existing type defnition... \ - typedef_struct \ -# swigrun.swg support. \ typemap_subst C_TEST_BROKEN_LONGLONG = \ @@ -87,9 +128,11 @@ C_TEST_BROKEN_LONGLONG = \ # std lib support hasn't been done yet. SKIP_CPP_STD_CASES = Yes -include $(srcdir)/../common.mk +C_TEST_CASES = -# SWIGOPT += -debug-module 4 +CPP_TEST_CASES = + +include $(srcdir)/../common.mk # Rules for the different types of tests %.cpptest: @@ -114,8 +157,9 @@ run_testcase = \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \ fi; +# Clean: (does nothing, we dont generate extra allegrocl code) %.clean: - @rm -f $*.cl + clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean diff --git a/Examples/test-suite/allowexcept.i b/Examples/test-suite/allowexcept.i index 37b01cd75..14b19b33d 100644 --- a/Examples/test-suite/allowexcept.i +++ b/Examples/test-suite/allowexcept.i @@ -26,26 +26,14 @@ UVW Bar::static_member_variable; struct XYZ { }; -// The operator& trick doesn't work for SWIG/PHP because the generated code -// takes the address of the variable in the code in the "vinit" section. -#ifdef SWIGPHP %{ struct XYZ { void foo() {} private: XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method + XYZ* operator&(); // prevent dereferencing used in normally generated get method }; %} -#else -%{ -struct XYZ { - void foo() {} -private: - XYZ& operator=(const XYZ& other); // prevent assignment used in normally generated set method - XYZ* operator&(); // prevent dereferencing used in normally generated get method -}; -%} -#endif #if defined(SWIGUTL) %exception { /* diff --git a/Examples/test-suite/c/Makefile.in b/Examples/test-suite/c/Makefile.in index 5734805b6..a7941551c 100644 --- a/Examples/test-suite/c/Makefile.in +++ b/Examples/test-suite/c/Makefile.in @@ -34,8 +34,6 @@ C_CPP_TEST_BROKEN = \ li_windows \ long_long_apply -INTERFACEDIR = ../../ - # Rules for the different types of tests %.cpptest: $(setup) diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i index 12e4b5aa2..b06eba773 100644 --- a/Examples/test-suite/char_strings.i +++ b/Examples/test-suite/char_strings.i @@ -9,12 +9,6 @@ below. %warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[] %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory. -#ifdef SWIG_ALLEGRO_CL -%{ -#include -%} -#endif - %{ #define OTHERLAND_MSG "Little message from the safe world." #define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible." diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index 764518880..ef6d7056c 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -19,7 +19,7 @@ SKIP_CPP_STD_CASES = Yes CPP_TEST_CASES += li_std_string -EXTRA_TEST_CASES += chicken_ext_test.externaltest +EXTRA_TEST_CASES += ext_test.externaltest include $(srcdir)/../common.mk diff --git a/Examples/test-suite/chicken_ext_test.i b/Examples/test-suite/chicken/ext_test.i similarity index 94% rename from Examples/test-suite/chicken_ext_test.i rename to Examples/test-suite/chicken/ext_test.i index b4f726cc7..e8f5930df 100644 --- a/Examples/test-suite/chicken_ext_test.i +++ b/Examples/test-suite/chicken/ext_test.i @@ -1,4 +1,4 @@ -%module chicken_ext_test +%module ext_test /* just use the imports_a.h header... for this test we only need a class */ %{ diff --git a/Examples/test-suite/chicken/chicken_ext_test_runme.ss b/Examples/test-suite/chicken/ext_test_runme.ss similarity index 57% rename from Examples/test-suite/chicken/chicken_ext_test_runme.ss rename to Examples/test-suite/chicken/ext_test_runme.ss index 65fa4e085..ea3eaa487 100644 --- a/Examples/test-suite/chicken/chicken_ext_test_runme.ss +++ b/Examples/test-suite/chicken/ext_test_runme.ss @@ -1,4 +1,4 @@ -(load "chicken_ext_test.so") +(load "ext_test.so") (define a (test-create)) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 85858c2fd..d2e4f96a7 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -59,12 +59,11 @@ CXXSRCS = CSRCS = TARGETPREFIX = TARGETSUFFIX = -SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) -INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) +SWIGOPT = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) -DSWIG_NOEXTRA_QUALIFICATION +INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) LIBS = -L. LIBPREFIX = lib ACTION = check -INTERFACEDIR = ../ # # Please keep test cases in alphabetical order. @@ -78,9 +77,8 @@ CPP_TEST_BROKEN += \ cpp_broken \ exception_partial_info \ extend_variable \ - li_std_vector_ptr \ namespace_union \ - nested_struct \ + nested_comment \ overload_complicated \ template_default_pointer \ template_expr @@ -167,7 +165,6 @@ CPP_TEST_CASES += \ director_overload \ director_primitives \ director_protected \ - director_protected_overloaded \ director_redefined \ director_thread \ director_unroll \ @@ -195,7 +192,6 @@ CPP_TEST_CASES += \ fragments \ friends \ fvirtual \ - global_namespace \ global_ns_arg \ global_vars \ grouping \ @@ -207,7 +203,6 @@ CPP_TEST_CASES += \ inherit_target_language \ inherit_void_arg \ inline_initializer \ - insert_directive \ keyword_rename \ kind \ langobj \ @@ -239,12 +234,10 @@ CPP_TEST_CASES += \ namespace_typemap \ namespace_virtual_method \ naturalvar \ - nested_comment \ newobject1 \ null_pointer \ operator_overload \ operator_overload_break \ - operbool \ ordering \ overload_copy \ overload_extend \ @@ -267,7 +260,6 @@ CPP_TEST_CASES += \ rename3 \ rename4 \ rename_scope \ - rename_strip_encoder \ restrict_cplusplus \ return_const_value \ return_value_scope \ @@ -412,7 +404,6 @@ CPP_STD_TEST_CASES += \ template_typedef_fnc \ template_type_namespace \ template_opaque -# li_std_list ifndef SKIP_CPP_STD_CASES @@ -449,13 +440,11 @@ C_TEST_CASES += \ overload_extendc \ preproc \ ret_by_value \ - simple_array \ sizeof_pointer \ sneaky1 \ struct_rename \ typedef_struct \ typemap_subst \ - union_parameter \ unions @@ -501,14 +490,14 @@ swig_and_compile_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ + TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_c = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ + TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT) swig_and_compile_multi_cpp = \ @@ -516,7 +505,7 @@ swig_and_compile_multi_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done @@ -528,7 +517,7 @@ swig_and_compile_external = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ + TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_runtime = \ diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i index b979ef19e..6ee0a353c 100644 --- a/Examples/test-suite/contract.i +++ b/Examples/test-suite/contract.i @@ -3,7 +3,7 @@ %warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, PHP multiple inheritance */ + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, Php4 multiple inheritance */ #ifdef SWIGCSHARP %ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override @@ -201,33 +201,3 @@ struct E { }; %} - -// Namespace - -%{ -namespace myNames { - -class myClass -{ - public: - myClass(int i) {} -}; - -} -%} - -namespace myNames { - -%contract myClass::myClass( int i ) { -require: - i > 0; -} - -class myClass -{ - public: - myClass(int i) {} -}; - -} - diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 5fb547f3f..5fd576ed8 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -21,17 +21,12 @@ CPP_TEST_CASES = \ enum_thorough_typesafe \ exception_partial_info -CUSTOM_TEST_CASES = \ - csharp_lib_arrays \ - intermediary_classname +CUSTOM_TEST_CASES = intermediary_classname include $(srcdir)/../common.mk # Overridden variables here SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL) -INTERFACEDIR = ../../ - -CSHARPFLAGSSPECIAL = # Rules for the different types of tests %.cpptest: @@ -52,8 +47,6 @@ CSHARPFLAGSSPECIAL = # Rules for custom tests intermediary_classname.customtest: $(MAKE) intermediary_classname.cpptest SWIGOPTSPECIAL="-dllimport intermediary_classname" -csharp_lib_arrays.customtest: - $(MAKE) csharp_lib_arrays.cpptest CSHARPFLAGSSPECIAL="-unsafe" # Makes a directory for the testcase if it does not exist setup = \ @@ -72,14 +65,14 @@ setup = \ run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ - CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \ + CSHARPFLAGS='-nologo -out:$*_runme.exe' \ CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \ $*$(CSHARPPATHSEPARATOR)*.cs' csharp_compile && \ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; ) \ else ( \ cd $* && \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ - CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \ + CSHARPFLAGS='-nologo -t:module -out:$*.netmodule' \ CSHARPSRCS='*.cs' csharp_compile; ); \ fi; diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs deleted file mode 100644 index 9f3ea6b88..000000000 --- a/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System; -using csharp_lib_arraysNamespace; - -public class runme -{ - static void Main() - { - { - int[] source = { 1, 2, 3, 4, 5 }; - int[] target = new int[ source.Length ]; - - csharp_lib_arrays.myArrayCopy( source, target, target.Length ); - CompareArrays(source, target); - } - - { - int[] source = { 1, 2, 3, 4, 5 }; - int[] target = new int[ source.Length ]; - - csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length ); - CompareArrays(source, target); - } - - { - int[] source = { 1, 2, 3, 4, 5 }; - int[] target = new int[] { 6, 7, 8, 9, 10 }; - - csharp_lib_arrays.myArraySwap( source, target, target.Length ); - - for (int i=0; i myEnumerator = dv.GetEnumerator(); - while ( myEnumerator.MoveNext() ) { - if (myEnumerator.Current != 77.7) - throw new Exception("Repeat (2) test failed"); - } - } -#endif } { @@ -533,13 +516,6 @@ public class li_std_vector_runme { li_std_vector.halve_in_place(dvec); } - // Dispose() - { - using (StructVector vs = new StructVector() { new Struct(0.0), new Struct(11.1) } ) - using (DoubleVector vd = new DoubleVector() { 0.0, 11.1 } ) { - } - } - // More wrapped methods { RealVector v0 = li_std_vector.vecreal(new RealVector()); diff --git a/Examples/test-suite/csharp_lib_arrays.i b/Examples/test-suite/csharp_lib_arrays.i deleted file mode 100644 index d07d43737..000000000 --- a/Examples/test-suite/csharp_lib_arrays.i +++ /dev/null @@ -1,61 +0,0 @@ -%module csharp_lib_arrays - -%include "arrays_csharp.i" - -%apply int INPUT[] { int* sourceArray } -%apply int OUTPUT[] { int* targetArray } - -%apply int INOUT[] { int* array1 } -%apply int INOUT[] { int* array2 } - -%inline %{ -/* copy the contents of the first array to the second */ -void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) { - int i; - for ( i = 0; i < nitems; i++ ) { - targetArray[ i ] = sourceArray[ i ]; - } -} - -/* swap the contents of the two arrays */ -void myArraySwap( int* array1, int* array2, int nitems ) { - int i, temp; - for ( i = 0; i < nitems; i++ ) { - temp = array1[ i ]; - array1[ i ] = array2[ i ]; - array2[ i ] = temp; - } -} -%} - - -%clear int* sourceArray; -%clear int* targetArray; - -%clear int* array1; -%clear int* array2; - - -// Below replicates the above array handling but this time using the pinned (fixed) array typemaps -%csmethodmodifiers myArrayCopyUsingFixedArrays "public unsafe"; -%csmethodmodifiers myArraySwapUsingFixedArrays "public unsafe"; - -%apply int FIXED[] { int* sourceArray } -%apply int FIXED[] { int* targetArray } - -%inline %{ -void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) { - myArrayCopy(sourceArray, targetArray, nitems); -} -%} - -%apply int FIXED[] { int* array1 } -%apply int FIXED[] { int* array2 } - -%inline %{ -void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) { - myArraySwap(array1, array2, nitems); -} -%} - - diff --git a/Examples/test-suite/csharp_prepost.i b/Examples/test-suite/csharp_prepost.i index 0c35c1833..9c2cedc83 100644 --- a/Examples/test-suite/csharp_prepost.i +++ b/Examples/test-suite/csharp_prepost.i @@ -1,6 +1,6 @@ %module csharp_prepost -// Test the pre, post, terminate and cshin attributes for csin typemaps +// Test the pre, post and cshin attributes for csin typemaps %include "std_vector.i" @@ -88,102 +88,3 @@ public: }; %} - - -// test Date marshalling with pre post and terminate typemap attributes (Documented in CSharp.html) -%typemap(cstype) const CDate& "System.DateTime" -%typemap(csin, - pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);" - ) const CDate & - "$csclassname.getCPtr(temp$csinput)" - -%typemap(cstype) CDate& "out System.DateTime" -%typemap(csin, - pre=" CDate temp$csinput = new CDate();", - post=" $csinput = new System.DateTime(temp$csinput.getYear()," - " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", - cshin="out $csinput" - ) CDate & - "$csclassname.getCPtr(temp$csinput)" - - -%inline %{ -class CDate { -public: - CDate(); - CDate(int year, int month, int day); - int getYear(); - int getMonth(); - int getDay(); -private: - int m_year; - int m_month; - int m_day; -}; -struct Action { - int doSomething(const CDate &dateIn, CDate &dateOut); - Action(const CDate &dateIn, CDate& dateOut); -}; -%} - -%{ -Action::Action(const CDate &dateIn, CDate& dateOut) {dateOut = dateIn;} -int Action::doSomething(const CDate &dateIn, CDate &dateOut) { dateOut = dateIn; return 0; } -CDate::CDate() : m_year(0), m_month(0), m_day(0) {} -CDate::CDate(int year, int month, int day) : m_year(year), m_month(month), m_day(day) {} -int CDate::getYear() { return m_year; } -int CDate::getMonth() { return m_month; } -int CDate::getDay() { return m_day; } -%} - -%typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime" - -%typemap(csin, - pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);", - post=" $csinput = new System.DateTime(temp$csinput.getYear()," - " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", - cshin="ref $csinput" - ) CDate * - "$csclassname.getCPtr(temp$csinput)" - -%inline %{ -void addYears(CDate *pDate, int years) { - *pDate = CDate(pDate->getYear() + years, pDate->getMonth(), pDate->getDay()); -} -%} - -%typemap(csin, - pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {", - post=" $csinput = new System.DateTime(temp$csinput.getYear()," - " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", - terminator=" } // terminate temp$csinput using block", - cshin="ref $csinput" - ) CDate * - "$csclassname.getCPtr(temp$csinput)" - -%inline %{ -void subtractYears(CDate *pDate, int years) { - *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay()); -} -%} - -%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{ - /* csvarin typemap code */ - set { - CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day); - $imcall;$excode - } %} - -%typemap(csvarout, excode=SWIGEXCODE2) CDate * %{ - /* csvarout typemap code */ - get { - IntPtr cPtr = $imcall; - CDate tempDate = (cPtr == IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode - return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(), - 0, 0, 0); - } %} - -%inline %{ -CDate ImportantDate = CDate(1999, 12, 31); -%} - diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i index ff22c7834..71600e55a 100644 --- a/Examples/test-suite/default_constructor.i +++ b/Examples/test-suite/default_constructor.i @@ -5,11 +5,11 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) EB; /* C#, Java, Php4 multiple inheritance */ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) AD; /* C#, Java, Php4 multiple inheritance */ %warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */ diff --git a/Examples/test-suite/director_basic.i b/Examples/test-suite/director_basic.i index 12cb0db65..986a1706f 100644 --- a/Examples/test-suite/director_basic.i +++ b/Examples/test-suite/director_basic.i @@ -112,14 +112,12 @@ public: return vmethod(b); } + static MyClass *get_self(MyClass *c) { return c; } - - static Bar * call_pmethod(MyClass *myclass, Bar *b) { - return myclass->pmethod(b); - } + }; template diff --git a/Examples/test-suite/director_classic.i b/Examples/test-suite/director_classic.i old mode 100644 new mode 100755 diff --git a/Examples/test-suite/director_ignore.i b/Examples/test-suite/director_ignore.i old mode 100644 new mode 100755 diff --git a/Examples/test-suite/director_protected_overloaded.i b/Examples/test-suite/director_protected_overloaded.i deleted file mode 100644 index a9f786fc7..000000000 --- a/Examples/test-suite/director_protected_overloaded.i +++ /dev/null @@ -1,21 +0,0 @@ -%module(directors="1",dirprot="1") director_protected_overloaded - -%director IDataObserver; -%director DerivedDataObserver; - -// protected overloaded methods -%inline %{ - class IDataObserver - { - public: - virtual ~IDataObserver(){} - - protected: - virtual void notoverloaded() = 0; - virtual void isoverloaded() = 0; - virtual void isoverloaded(int i) = 0; - virtual void isoverloaded(int i, double d) = 0; - }; - class DerivedDataObserver : public IDataObserver { - }; -%} diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index 2732eb907..4f4e55cfe 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -13,7 +13,6 @@ #include #else #include -#include #include #endif @@ -28,8 +27,6 @@ extern "C" { void* working(void* t); pthread_t thread; #endif - static int thread_terminate = 0; - } %} @@ -54,15 +51,6 @@ extern "C" { virtual ~Foo() { } - void stop() { - thread_terminate = 1; - %#ifdef _WIN32 - /*TODO(bhy) what to do for win32? */ - %#else - pthread_join(thread, NULL); - %#endif - } - void run() { %#ifdef _WIN32 _beginthreadex(NULL,0,working,this,0,&thread_id); @@ -87,15 +75,10 @@ extern "C" { #endif { Foo* f = static_cast(t); - while ( ! thread_terminate ) { + while (1) { MilliSecondSleep(50); f->do_foo(); } -#ifdef _WIN32 - /* TODO(bhy) what's the corresponding of pthread_exit in win32? */ -#else - pthread_exit(0); -#endif return 0; } } diff --git a/Examples/test-suite/evil_diamond.i b/Examples/test-suite/evil_diamond.i index 7b2e9152f..33353e32e 100644 --- a/Examples/test-suite/evil_diamond.i +++ b/Examples/test-suite/evil_diamond.i @@ -6,7 +6,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance %inline %{ diff --git a/Examples/test-suite/evil_diamond_ns.i b/Examples/test-suite/evil_diamond_ns.i index 515044007..78a764ccc 100644 --- a/Examples/test-suite/evil_diamond_ns.i +++ b/Examples/test-suite/evil_diamond_ns.i @@ -6,7 +6,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance %inline %{ namespace Blah { diff --git a/Examples/test-suite/evil_diamond_prop.i b/Examples/test-suite/evil_diamond_prop.i index 804ea66b4..e9fc24f4d 100644 --- a/Examples/test-suite/evil_diamond_prop.i +++ b/Examples/test-suite/evil_diamond_prop.i @@ -6,7 +6,7 @@ %warnfilter(SWIGWARN_RUBY_WRONG_NAME, SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, Php4 multiple inheritance %inline %{ diff --git a/Examples/test-suite/features.i b/Examples/test-suite/features.i index 2ccbe725a..2db51ae6b 100644 --- a/Examples/test-suite/features.i +++ b/Examples/test-suite/features.i @@ -162,20 +162,3 @@ namespace Space { } %} -// Test 8 conversion operators -%rename(opbool) operator bool; -%rename(opuint) operator unsigned int; - -%exception ConversionOperators::ConversionOperators() "$action /* ConversionOperators::ConversionOperators() */"; -%exception ConversionOperators::~ConversionOperators() "$action /* ConversionOperators::~ConversionOperators() */"; -%exception ConversionOperators::operator bool "$action /* ConversionOperators::operator bool */"; -%exception ConversionOperators::operator unsigned int "$action /* ConversionOperators::unsigned int*/"; - -%inline %{ - class ConversionOperators { - public: - operator bool() { return false; } - operator unsigned int() { return 0; } - }; -%} - diff --git a/Examples/test-suite/global_namespace.i b/Examples/test-suite/global_namespace.i deleted file mode 100644 index 02139f6c4..000000000 --- a/Examples/test-suite/global_namespace.i +++ /dev/null @@ -1,60 +0,0 @@ -%module global_namespace - -// classes -%inline %{ -class Klass1 {}; -class Klass2 {}; -class Klass3 {}; -class Klass4 {}; -class Klass5 {}; -class Klass6 {}; -class Klass7 {}; - -struct KlassMethods { - static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, Klass7*& pr) {} - static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {} -}; -%} - -%inline %{ -namespace Space { -class XYZ1 {}; -class XYZ2 {}; -class XYZ3 {}; -class XYZ4 {}; -class XYZ5 {}; -class XYZ6 {}; -class XYZ7 {}; -} - -struct XYZMethods { - static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, Space::XYZ7*& pr) {} - static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*& pr) {} -}; -%} - -//enums -%inline %{ -enum AnEnum1 { anenum1 }; -enum AnEnum2 { anenum2 }; -enum AnEnum3 { anenum3 }; - -struct AnEnumMethods { - static void methodA(::AnEnum1 v, const ::AnEnum2 cv, const ::AnEnum3 &cr) {} - static void methodB( AnEnum1 v, const AnEnum2 cv, const AnEnum3 &cr) {} -}; -%} - -%inline %{ -namespace Space { -enum TheEnum1 { theenum1 }; -enum TheEnum2 { theenum2 }; -enum TheEnum3 { theenum3 }; - -struct TheEnumMethods { - static void methodA(::Space::TheEnum1 v, const ::Space::TheEnum2 cv, const ::Space::TheEnum3 &cr) {} - static void methodB( Space::TheEnum1 v, const Space::TheEnum2 cv, const Space::TheEnum3 &cr) {} -}; -} -%} - diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index 25d40674d..97f30e3b2 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -36,7 +36,7 @@ swig_and_compile_multi_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ SWIGOPT=" -noruntime "; \ done diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in index eb53f020e..04de236db 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilescm/Makefile.in @@ -2,7 +2,7 @@ # Makefile for guile test-suite (with SCM API) ####################################################################### -EXTRA_TEST_CASES += guilescm_ext_test.externaltest +EXTRA_TEST_CASES += ext_test.externaltest include ../guile/Makefile @@ -31,7 +31,7 @@ swig_and_compile_multi_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done diff --git a/Examples/test-suite/guilescm_ext_test.i b/Examples/test-suite/guilescm/ext_test.i similarity index 93% rename from Examples/test-suite/guilescm_ext_test.i rename to Examples/test-suite/guilescm/ext_test.i index fd5655d4f..8b117bb5a 100644 --- a/Examples/test-suite/guilescm_ext_test.i +++ b/Examples/test-suite/guilescm/ext_test.i @@ -1,4 +1,4 @@ -%module guilescm_ext_test +%module ext_test /* just use the imports_a.h header... for this test we only need a class */ %{ diff --git a/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm b/Examples/test-suite/guilescm/ext_test_runme.scm similarity index 82% rename from Examples/test-suite/guilescm/guilescm_ext_test_runme.scm rename to Examples/test-suite/guilescm/ext_test_runme.scm index ff3df064b..67add849e 100644 --- a/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm +++ b/Examples/test-suite/guilescm/ext_test_runme.scm @@ -1,4 +1,4 @@ -(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so")) +(dynamic-call "scm_init_ext_test_module" (dynamic-link "./libext_test.so")) ; This is a test for SF Bug 1573892 ; If IsPointer is called before TypeQuery, the test-is-pointer will fail diff --git a/Examples/test-suite/ignore_template_constructor.i b/Examples/test-suite/ignore_template_constructor.i index ffd541986..5225d5183 100644 --- a/Examples/test-suite/ignore_template_constructor.i +++ b/Examples/test-suite/ignore_template_constructor.i @@ -37,9 +37,3 @@ public: #endif %template(VectFlow) std::vector; - -%inline %{ -std::vector inandout(std::vector v) { - return v; -} -%} diff --git a/Examples/test-suite/import_nomodule.i b/Examples/test-suite/import_nomodule.i index a1ba9ad7a..5d5115360 100644 --- a/Examples/test-suite/import_nomodule.i +++ b/Examples/test-suite/import_nomodule.i @@ -3,9 +3,6 @@ #include "import_nomodule.h" %} -// For Python -%warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Bar; // Base class 'Foo' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %import directive. - %import "import_nomodule.h" #if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) diff --git a/Examples/test-suite/imports_b.i b/Examples/test-suite/imports_b.i index 81e84cddd..afc573a39 100644 --- a/Examples/test-suite/imports_b.i +++ b/Examples/test-suite/imports_b.i @@ -34,14 +34,9 @@ */ #if 0 - %import "imports_a.i" +%import "imports_a.i" #else -# if 0 - // Test Warning 401 (Python only) - %import "imports_a.h" -# else - %import(module="imports_a") "imports_a.h" -# endif +%import(module="imports_a") "imports_a.h" #endif %include "imports_b.h" diff --git a/Examples/test-suite/insert_directive.i b/Examples/test-suite/insert_directive.i deleted file mode 100644 index 8ad966a99..000000000 --- a/Examples/test-suite/insert_directive.i +++ /dev/null @@ -1,38 +0,0 @@ -%module insert_directive - -// check %insert and the order of each insert section is correct - -%begin %{ -// %inserted code %begin -int inserted_begin(int i) { return i; } -%} - -%runtime %{ -// %inserted code %runtime -int inserted_runtime(int i) { return inserted_begin(i); } -%} - -%{ -// %inserted code %header -int inserted_header1(int i) { return inserted_runtime(i); } -%} - -%header %{ -// %inserted code %header -int inserted_header2(int i) { return inserted_header1(i); } -%} - -%{ -// %inserted code %header -int inserted_header3(int i) { return inserted_header2(i); } -%} - -%wrapper %{ -// %inserted code %wrapper -int inserted_wrapper(int i) { return inserted_header3(i); } -%} - -%init %{ -// %inserted code %init -int inserted_init_value = inserted_wrapper(0); -%} diff --git a/Examples/test-suite/intermediary_classname.i b/Examples/test-suite/intermediary_classname.i index 94858a5fb..0f90f9cdd 100644 --- a/Examples/test-suite/intermediary_classname.i +++ b/Examples/test-suite/intermediary_classname.i @@ -18,7 +18,6 @@ "new $javaclassname($jniinput, false)/*javadirectorin*/" %typemap(out, throws="IllegalAccessException/*out Base&*/") Base& { // XYZ& typemap out - $result = 0; // remove unused variable warning } %inline %{ diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index 03c10d498..ace8dee86 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -32,13 +32,11 @@ CPP_TEST_CASES = \ java_throws \ java_typemaps_proxy \ java_typemaps_typewrapper -# li_boost_intrusive_ptr include $(srcdir)/../common.mk # Overridden variables here SWIGOPT += -package $* -INTERFACEDIR = ../../ # Rules for the different types of tests %.cpptest: @@ -74,7 +72,7 @@ run_testcase = \ (cd $* && $(COMPILETOOL) $(JAVAC) -classpath . *.java) && \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ $(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme;) \ + env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*\_runme;) \ fi; # Clean: remove testcase directories diff --git a/Examples/test-suite/java/allprotected_runme.java b/Examples/test-suite/java/allprotected_runme.java old mode 100644 new mode 100755 diff --git a/Examples/test-suite/java/director_basic_runme.java b/Examples/test-suite/java/director_basic_runme.java index 16a46aa35..eafe20bec 100644 --- a/Examples/test-suite/java/director_basic_runme.java +++ b/Examples/test-suite/java/director_basic_runme.java @@ -14,43 +14,28 @@ public class director_basic_runme { public static void main(String argv[]) { - director_basic_MyFoo a = new director_basic_MyFoo(); + director_basic_MyFoo a = new director_basic_MyFoo(); - if (!a.ping().equals("director_basic_MyFoo::ping()")) { - throw new RuntimeException ( "a.ping()" ); - } + if (!a.ping().equals("director_basic_MyFoo::ping()")) { + throw new RuntimeException ( "a.ping()" ); + } - if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) { - throw new RuntimeException ( "a.pong()" ); - } + if (!a.pong().equals("Foo::pong();director_basic_MyFoo::ping()")) { + throw new RuntimeException ( "a.pong()" ); + } - Foo b = new Foo(); + Foo b = new Foo(); - if (!b.ping().equals("Foo::ping()")) { - throw new RuntimeException ( "b.ping()" ); - } + if (!b.ping().equals("Foo::ping()")) { + throw new RuntimeException ( "b.ping()" ); + } - if (!b.pong().equals("Foo::pong();Foo::ping()")) { - throw new RuntimeException ( "b.pong()" ); - } + if (!b.pong().equals("Foo::pong();Foo::ping()")) { + throw new RuntimeException ( "b.pong()" ); + } - A1 a1 = new A1(1, false); - a1.delete(); - - { - MyOverriddenClass my = new MyOverriddenClass(); - - my.expectNull = true; - if (MyClass.call_pmethod(my, null) != null) - throw new RuntimeException("null pointer marshalling problem"); - - Bar myBar = new Bar(); - my.expectNull = false; - Bar myNewBar = MyClass.call_pmethod(my, myBar); - if (myNewBar == null) - throw new RuntimeException("non-null pointer marshalling problem"); - myNewBar.setX(10); - } + A1 a1 = new A1(1, false); + a1.delete(); } } @@ -60,13 +45,3 @@ class director_basic_MyFoo extends Foo { } } -class MyOverriddenClass extends MyClass { - public boolean expectNull = false; - public boolean nonNullReceived = false; - public Bar pmethod(Bar b) { - if ( expectNull && (b != null) ) - throw new RuntimeException("null not received as expected"); - return b; - } -} - diff --git a/Examples/test-suite/java/director_classic_runme.java b/Examples/test-suite/java/director_classic_runme.java old mode 100644 new mode 100755 diff --git a/Examples/test-suite/java/director_ignore_runme.java b/Examples/test-suite/java/director_ignore_runme.java old mode 100644 new mode 100755 diff --git a/Examples/test-suite/java/global_namespace_runme.java b/Examples/test-suite/java/global_namespace_runme.java deleted file mode 100644 index faab7d4ba..000000000 --- a/Examples/test-suite/java/global_namespace_runme.java +++ /dev/null @@ -1,25 +0,0 @@ -import global_namespace.*; - -public class global_namespace_runme { - - static { - try { - System.loadLibrary("global_namespace"); - } catch (UnsatisfiedLinkError e) { - System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); - System.exit(1); - } - } - - public static void main(String argv[]) { - - KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7()); - KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7()); - - XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7()); - XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7()); - - TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3); - TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3); - } -} diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java index 6a73ea563..3538aa6d4 100644 --- a/Examples/test-suite/java/java_throws_runme.java +++ b/Examples/test-suite/java/java_throws_runme.java @@ -94,20 +94,5 @@ public class java_throws_runme { if (!pass) throw new RuntimeException("Test 7 failed"); - - // Test %nojavaexception - NoExceptTest net = new NoExceptTest(); - - pass = false; - try { - net.exceptionPlease(); - pass = true; - } - catch (MyException e) {} - - if (!pass) - throw new RuntimeException("Test 8 failed"); - - net.noExceptionPlease(); } } diff --git a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java deleted file mode 100644 index f40c28e9e..000000000 --- a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java +++ /dev/null @@ -1,701 +0,0 @@ -import li_boost_intrusive_ptr.*; - -public class li_boost_intrusive_ptr_runme { - static { - try { - System.loadLibrary("li_boost_intrusive_ptr"); - } catch (UnsatisfiedLinkError e) { - System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); - System.exit(1); - } - } - - // Debugging flag - public final static boolean debug = false; - - public static void main(String argv[]) - { - if (debug) - System.out.println("Started"); - - li_boost_intrusive_ptr.setDebug_shared(debug); - - // Change loop count to run for a long time to monitor memory - final int loopCount = 5000; //5000; - for (int i=0; iFindClass("java_throws/MyException"); - if (excep) - jenv->ThrowNew(excep, "exception message"); - return $null; -} -%} - -%nojavaexception *::noExceptionPlease(); -%nojavaexception NoExceptTest::NoExceptTest(); - -// Need to handle the checked exception in NoExceptTest.delete() -%typemap(javafinalize) SWIGTYPE %{ - protected void finalize() { - try { - delete(); - } catch (MyException e) { - throw new RuntimeException(e); - } - } -%} - -%inline %{ -struct NoExceptTest { - unsigned int noExceptionPlease() { return 123; } - unsigned int exceptionPlease() { return 456; } - ~NoExceptTest() {} -}; -%} - -// Turn global exceptions off (for the implicit destructors/constructors) -%nojavaexception; - diff --git a/Examples/test-suite/li_attribute.i b/Examples/test-suite/li_attribute.i index 4f9497afb..5b4379ebf 100644 --- a/Examples/test-suite/li_attribute.i +++ b/Examples/test-suite/li_attribute.i @@ -93,11 +93,9 @@ struct MyFoo; // %attribute2 does not work with templates %template(Param_i) Param; -// class/struct attribute with get/set methods using return/pass by reference %attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo); %inline %{ struct MyFoo { - MyFoo() : x(-1) {} int x; }; class MyClass { @@ -108,32 +106,3 @@ struct MyFoo; // %attribute2 does not work with templates }; %} - -// class/struct attribute with get/set methods using return/pass by value -%attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo); -%attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo); -%inline %{ - class MyClassVal { - MyFoo foo; - public: - MyFoo GetFoo() { return foo; } - void SetFoo(MyFoo other) { foo = other; } - }; -%} - - -// string attribute with get/set methods using return/pass by value -%include -%attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString); -%attributestring(MyStringyClass, std::string, ReadOnlyString, GetString); -%inline %{ - class MyStringyClass { - std::string str; - public: - MyStringyClass(const std::string &val) : str(val) {} - std::string GetString() { return str; } - void SetString(std::string other) { str = other; } - }; -%} - - diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i deleted file mode 100644 index 7c37e6843..000000000 --- a/Examples/test-suite/li_boost_intrusive_ptr.i +++ /dev/null @@ -1,494 +0,0 @@ -// This tests intrusive_ptr is working okay. It also checks that there are no memory leaks in the -// class that intrusive_ptr is pointing via a counting mechanism in the constructors and destructor of Klass. -// In order to test that there are no leaks of the intrusive_ptr class itself (as it is created on the heap) -// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools -// like 'top'. There is a wrapper for intrusive_ptr in intrusive_ptr_wrapper.h which enables one to -// count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on. -// -// Also note the debug_shared flag which can be set from the target language. - -%module li_boost_intrusive_ptr - -%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); - -%inline %{ -#include "boost/shared_ptr.hpp" -#include "boost/intrusive_ptr.hpp" -#include - -// Uncomment macro below to turn on intrusive_ptr memory leak checking as described above -//#define INTRUSIVE_PTR_WRAPPER - -#ifdef INTRUSIVE_PTR_WRAPPER -# include "intrusive_ptr_wrapper.h" -# include "shared_ptr_wrapper.h" -#endif -%} - -%{ -#ifndef INTRUSIVE_PTR_WRAPPER -# define SwigBoost boost -#endif -%} - -%include "std_string.i" -#ifndef INTRUSIVE_PTR_WRAPPER -# define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost -# define SWIG_SHARED_PTR_NAMESPACE SwigBoost -#endif - -#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) -#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED -#endif - -#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED) - -%include -SWIG_INTRUSIVE_PTR(Klass, Space::Klass) -SWIG_INTRUSIVE_PTR_NO_WRAP(KlassWithoutRefCount, Space::KlassWithoutRefCount) -SWIG_INTRUSIVE_PTR_DERIVED(KlassDerived, Space::KlassWithoutRefCount, Space::KlassDerived) -SWIG_INTRUSIVE_PTR_DERIVED(KlassDerivedDerived, Space::KlassDerived, Space::KlassDerivedDerived) - -//For the use_count shared_ptr functions -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{ - $1 = $input ? *($&1_ltype)&$input : &tempnull; -%} -%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "jlong" -%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "long" -%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass" -%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass.getCPtr($javainput)" - -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & ($*1_ltype tempnull) %{ - $1 = $input ? *($&1_ltype)&$input : &tempnull; -%} -%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "jlong" -%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "long" -%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived" -%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived.getCPtr($javainput)" - -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & ($*1_ltype tempnull) %{ - $1 = $input ? *($&1_ltype)&$input : &tempnull; -%} -%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "jlong" -%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "long" -%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived" -%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)" - -#endif - -// TODO: -// const intrusive_ptr -// std::vector -// Add in generic %extend for the Upcast function for derived classes -// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method - -%exception { - if (debug_shared) { - cout << "++++++" << endl << flush; - cout << "calling $name" << endl << flush; - } - $action - if (debug_shared) { - cout << "------" << endl << flush; - } -} - -%ignore IgnoredRefCountingBase; -%ignore *::operator=; -%ignore intrusive_ptr_add_ref; -%ignore intrusive_ptr_release; -%newobject pointerownertest(); -%newobject smartpointerpointerownertest(); - -%inline %{ -#include -using namespace std; - -static bool debug_shared = false; - -namespace Space { - -struct Klass { - Klass() : value("EMPTY"), count(0) { if (debug_shared) cout << "Klass() [" << value << "]" << endl << flush; increment(); } - - Klass(const std::string &val) : value(val), count(0) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl << flush; increment(); } - - virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl << flush; decrement(); } - virtual std::string getValue() const { return value; } - void append(const std::string &s) { value += s; } - Klass(const Klass &other) : value(other.value), count(0) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl << flush; increment(); } - - Klass &operator=(const Klass &other) { value = other.value; return *this; } - - void addref(void) const { ++count; } - void release(void) const { if (--count == 0) delete this; } - int use_count(void) const { return count; } - static long getTotal_count() { return total_count; } - -private: - static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;} - static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;} - static boost::detail::atomic_count total_count; - std::string value; - int array[1024]; - mutable boost::detail::atomic_count count; -}; - -struct KlassWithoutRefCount { - KlassWithoutRefCount() : value("EMPTY") { if (debug_shared) cout << "KlassWithoutRefCount() [" << value << "]" << endl << flush; increment(); } - - KlassWithoutRefCount(const std::string &val) : value(val) { if (debug_shared) cout << "KlassWithoutRefCount(string) [" << value << "]" << endl << flush; increment(); } - - virtual ~KlassWithoutRefCount() { if (debug_shared) cout << "~KlassWithoutRefCount() [" << value << "]" << endl << flush; decrement(); } - virtual std::string getValue() const { return value; } - void append(const std::string &s) { value += s; } - KlassWithoutRefCount(const KlassWithoutRefCount &other) : value(other.value) { if (debug_shared) cout << "KlassWithoutRefCount(const KlassWithoutRefCount&) [" << value << "]" << endl << flush; increment(); } - std::string getSpecialValueFromUnwrappableClass() { return "this class cannot be wrapped by intrusive_ptrs but we can still use it"; } - KlassWithoutRefCount &operator=(const KlassWithoutRefCount &other) { value = other.value; return *this; } - static long getTotal_count() { return total_count; } - -private: - static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassWithoutRefCount::increment tot: " << total_count << endl;} - static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassWithoutRefCount::decrement tot: " << total_count << endl;} - static boost::detail::atomic_count total_count; - std::string value; - int array[1024]; -}; - -struct IgnoredRefCountingBase { - IgnoredRefCountingBase() : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase()" << endl << flush; increment(); } - - IgnoredRefCountingBase(const IgnoredRefCountingBase &other) : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase(const IgnoredRefCountingBase&)" << endl << flush; increment(); } - - IgnoredRefCountingBase &operator=(const IgnoredRefCountingBase& other) { - return *this; - } - - virtual ~IgnoredRefCountingBase() { if (debug_shared) cout << "~IgnoredRefCountingBase()" << endl << flush; decrement(); } - - void addref(void) const { ++count; } - void release(void) const { if (--count == 0) delete this; } - int use_count(void) const { return count; } - static long getTotal_count() { return total_count; } - - private: - static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx IgnoredRefCountingBase::increment tot: " << total_count << endl;} - static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx IgnoredRefCountingBase::decrement tot: " << total_count << endl;} - static boost::detail::atomic_count total_count; - double d; - double e; - mutable boost::detail::atomic_count count; -}; - -long getTotal_IgnoredRefCountingBase_count() { - return IgnoredRefCountingBase::getTotal_count(); -} - -// For most compilers, this use of multiple inheritance results in different derived and base class -// pointer values ... for some more challenging tests :) -struct KlassDerived : IgnoredRefCountingBase, KlassWithoutRefCount { - KlassDerived() : KlassWithoutRefCount() { if (debug_shared) cout << "KlassDerived()" << endl << flush; increment(); } - KlassDerived(const std::string &val) : KlassWithoutRefCount(val) { if (debug_shared) cout << "KlassDerived(string) [" << val << "]" << endl << flush; increment(); } - KlassDerived(const KlassDerived &other) : KlassWithoutRefCount(other) { if (debug_shared) cout << "KlassDerived(const KlassDerived&))" << endl << flush; increment(); } - virtual ~KlassDerived() { if (debug_shared) cout << "~KlassDerived()" << endl << flush; decrement(); } - virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-Derived"; } - int use_count(void) const { return IgnoredRefCountingBase::use_count(); } - static long getTotal_count() { return total_count; } - - private: - static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerived::increment tot: " << total_count << endl;} - static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerived::decrement tot: " << total_count << endl;} - static boost::detail::atomic_count total_count; -}; -struct KlassDerivedDerived : KlassDerived { - KlassDerivedDerived() : KlassDerived() { if (debug_shared) cout << "KlassDerivedDerived()" << endl << flush; increment(); } - KlassDerivedDerived(const std::string &val) : KlassDerived(val) { if (debug_shared) cout << "KlassDerivedDerived(string) [" << val << "]" << endl << flush; increment(); } - KlassDerivedDerived(const KlassDerived &other) : KlassDerived(other) { if (debug_shared) cout << "KlassDerivedDerived(const KlassDerivedDerived&))" << endl << flush; increment(); } - virtual ~KlassDerivedDerived() { if (debug_shared) cout << "~KlassDerivedDerived()" << endl << flush; decrement(); } - virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-DerivedDerived"; } - static long getTotal_count() { return total_count; } - - private: - static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerivedDerived::increment tot: " << total_count << endl;} - static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerivedDerived::decrement tot: " << total_count << endl;} - static boost::detail::atomic_count total_count; -}; -KlassDerived* derivedpointertest(KlassDerived* kd) { - if (kd) - kd->append(" derivedpointertest"); - return kd; -} -KlassDerived derivedvaluetest(KlassDerived kd) { - kd.append(" derivedvaluetest"); - return kd; -} -KlassDerived& derivedreftest(KlassDerived& kd) { - kd.append(" derivedreftest"); - return kd; -} -SwigBoost::intrusive_ptr derivedsmartptrtest(SwigBoost::intrusive_ptr kd) { - if (kd) - kd->append(" derivedsmartptrtest"); - return kd; -} -SwigBoost::intrusive_ptr* derivedsmartptrpointertest(SwigBoost::intrusive_ptr* kd) { - if (kd && *kd) - (*kd)->append(" derivedsmartptrpointertest"); - return kd; -} -SwigBoost::intrusive_ptr* derivedsmartptrreftest(SwigBoost::intrusive_ptr* kd) { - if (kd && *kd) - (*kd)->append(" derivedsmartptrreftest"); - return kd; -} -SwigBoost::intrusive_ptr*& derivedsmartptrpointerreftest(SwigBoost::intrusive_ptr*& kd) { - if (kd && *kd) - (*kd)->append(" derivedsmartptrpointerreftest"); - return kd; -} - -SwigBoost::intrusive_ptr factorycreate() { - return SwigBoost::intrusive_ptr(new Klass("factorycreate")); -} -// smart pointer -SwigBoost::intrusive_ptr smartpointertest(SwigBoost::intrusive_ptr k) { - if (k) - k->append(" smartpointertest"); - return SwigBoost::intrusive_ptr(k); -} -SwigBoost::intrusive_ptr* smartpointerpointertest(SwigBoost::intrusive_ptr* k) { - if (k && *k) - (*k)->append(" smartpointerpointertest"); - return k; -} -SwigBoost::intrusive_ptr& smartpointerreftest(SwigBoost::intrusive_ptr& k) { - if (k) - k->append(" smartpointerreftest"); - return k; -} -SwigBoost::intrusive_ptr*& smartpointerpointerreftest(SwigBoost::intrusive_ptr*& k) { - if (k && *k) - (*k)->append(" smartpointerpointerreftest"); - return k; -} -// const -SwigBoost::intrusive_ptr constsmartpointertest(SwigBoost::intrusive_ptr k) { - return SwigBoost::intrusive_ptr(k); -} -SwigBoost::intrusive_ptr* constsmartpointerpointertest(SwigBoost::intrusive_ptr* k) { - return k; -} -SwigBoost::intrusive_ptr& constsmartpointerreftest(SwigBoost::intrusive_ptr& k) { - return k; -} -// plain pointer -Klass valuetest(Klass k) { - k.append(" valuetest"); - return k; -} -Klass *pointertest(Klass *k) { - if (k) - k->append(" pointertest"); - return k; -} -Klass& reftest(Klass& k) { - k.append(" reftest"); - return k; -} -Klass*& pointerreftest(Klass*& k) { - k->append(" pointerreftest"); - return k; -} -// null -std::string nullsmartpointerpointertest(SwigBoost::intrusive_ptr* k) { - if (k && *k) - return "not null"; - else if (!k) - return "null smartpointer pointer"; - else if (!*k) - return "null pointer"; - else - return "also not null"; -} -// $owner -Klass *pointerownertest() { - return new Klass("pointerownertest"); -} -SwigBoost::intrusive_ptr* smartpointerpointerownertest() { - return new SwigBoost::intrusive_ptr(new Klass("smartpointerpointerownertest")); -} - -const SwigBoost::intrusive_ptr& ref_1() { - static SwigBoost::intrusive_ptr sptr; - return sptr; -} - -// overloading tests -std::string overload_rawbyval(int i) { return "int"; } -std::string overload_rawbyval(Klass k) { return "rawbyval"; } - -std::string overload_rawbyref(int i) { return "int"; } -std::string overload_rawbyref(Klass &k) { return "rawbyref"; } - -std::string overload_rawbyptr(int i) { return "int"; } -std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; } - -std::string overload_rawbyptrref(int i) { return "int"; } -std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; } - - - -std::string overload_smartbyval(int i) { return "int"; } -std::string overload_smartbyval(SwigBoost::intrusive_ptr k) { return "smartbyval"; } - -std::string overload_smartbyref(int i) { return "int"; } -std::string overload_smartbyref(SwigBoost::intrusive_ptr &k) { return "smartbyref"; } - -std::string overload_smartbyptr(int i) { return "int"; } -std::string overload_smartbyptr(SwigBoost::intrusive_ptr *k) { return "smartbyptr"; } - -std::string overload_smartbyptrref(int i) { return "int"; } -std::string overload_smartbyptrref(SwigBoost::intrusive_ptr *&k) { return "smartbyptrref"; } - -} // namespace Space - -%} -%{ - boost::detail::atomic_count Space::Klass::total_count(0); - boost::detail::atomic_count Space::KlassWithoutRefCount::total_count(0); - boost::detail::atomic_count Space::IgnoredRefCountingBase::total_count(0); - boost::detail::atomic_count Space::KlassDerived::total_count(0); - boost::detail::atomic_count Space::KlassDerivedDerived::total_count(0); -%} - -// Member variables - -%inline %{ -struct MemberVariables { - MemberVariables() : SmartMemberPointer(new SwigBoost::intrusive_ptr()), SmartMemberReference(*(new SwigBoost::intrusive_ptr())), MemberPointer(0), MemberReference(MemberValue) {} - virtual ~MemberVariables() { - delete SmartMemberPointer; - delete &SmartMemberReference; - } - SwigBoost::intrusive_ptr SmartMemberValue; - SwigBoost::intrusive_ptr * SmartMemberPointer; - SwigBoost::intrusive_ptr & SmartMemberReference; - Space::Klass MemberValue; - Space::Klass * MemberPointer; - Space::Klass & MemberReference; -}; - -// Global variables -SwigBoost::intrusive_ptr GlobalSmartValue; -Space::Klass GlobalValue; -Space::Klass * GlobalPointer = 0; -Space::Klass & GlobalReference = GlobalValue; - -%} - -#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED) - -// Note: %template after the intrusive_ptr typemaps -SWIG_INTRUSIVE_PTR(BaseIntDouble, Base) -// Note: cannot use Base in the macro below because of the comma in the type, -// so we use a typedef instead. Alternatively use %arg(Base). %arg is defined in swigmacros.swg. -SWIG_INTRUSIVE_PTR_DERIVED(PairIntDouble, BaseIntDouble_t, Pair) - -#endif - -// Templates -%inline %{ -template struct Base { - Space::Klass klassBase; - T1 baseVal1; - T2 baseVal2; - Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {} - virtual std::string getValue() const { return "Base<>"; }; - mutable int count; - void addref(void) const { count++; } - void release(void) const { if (--count == 0) delete this; } - int use_count(void) const { return count; } -}; -typedef Base BaseIntDouble_t; -%} - -%template(BaseIntDouble) Base; - -%inline %{ -template struct Pair : Base { - Space::Klass klassPair; - T1 val1; - T2 val2; - Pair(T1 t1, T2 t2) : Base(t1, t2), val1(t1), val2(t2) {} - virtual std::string getValue() const { return "Pair<>"; }; -}; - -Pair pair_id2(Pair p) { return p; } -SwigBoost::intrusive_ptr< Pair > pair_id1(SwigBoost::intrusive_ptr< Pair > p) { return p; } - -template void intrusive_ptr_add_ref(const T* r) { r->addref(); } - -template void intrusive_ptr_release(const T* r) { r->release(); } - -long use_count(const SwigBoost::shared_ptr& sptr) { - return sptr.use_count(); -} -long use_count(const SwigBoost::shared_ptr& sptr) { - return sptr.use_count(); -} -long use_count(const SwigBoost::shared_ptr& sptr) { - return sptr.use_count(); -} -%} - -%template(PairIntDouble) Pair; - -// For counting the instances of intrusive_ptr (all of which are created on the heap) -// intrusive_ptr_wrapper_count() gives overall count -%inline %{ -namespace SwigBoost { - const int NOT_COUNTING = -123456; - int intrusive_ptr_wrapper_count() { - #ifdef INTRUSIVE_PTR_WRAPPER - return SwigBoost::IntrusivePtrWrapper::getTotalCount(); - #else - return NOT_COUNTING; - #endif - } - #ifdef INTRUSIVE_PTR_WRAPPER - template<> std::string show_message(boost::intrusive_ptr*t) { - if (!t) - return "null intrusive_ptr!!!"; - if (*t) - return "Klass: " + (*t)->getValue(); - else - return "Klass: NULL"; - } - template<> std::string show_message(boost::intrusive_ptr*t) { - if (!t) - return "null intrusive_ptr!!!"; - if (*t) - return "Klass: " + (*t)->getValue(); - else - return "Klass: NULL"; - } - template<> std::string show_message(boost::intrusive_ptr*t) { - if (!t) - return "null intrusive_ptr!!!"; - if (*t) - return "KlassDerived: " + (*t)->getValue(); - else - return "KlassDerived: NULL"; - } - template<> std::string show_message(boost::intrusive_ptr*t) { - if (!t) - return "null intrusive_ptr!!!"; - if (*t) - return "KlassDerived: " + (*t)->getValue(); - else - return "KlassDerived: NULL"; - } - #endif -} -%} - diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i index f992a3c08..a6225410b 100644 --- a/Examples/test-suite/li_boost_shared_ptr.i +++ b/Examples/test-suite/li_boost_shared_ptr.i @@ -43,14 +43,6 @@ %include SWIG_SHARED_PTR(Klass, Space::Klass) SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived) -SWIG_SHARED_PTR_DERIVED(Klass2ndDerived, Space::Klass, Space::Klass2ndDerived) -SWIG_SHARED_PTR_DERIVED(Klass3rdDerived, Space::Klass2ndDerived, Space::Klass3rdDerived) - -// TEMP for python -%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >) { - *newmemory = SWIG_CAST_NEW_MEMORY; - return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > *)$from); -} #endif @@ -109,13 +101,7 @@ private: }; SwigExamples::CriticalSection Space::Klass::critical_section; -struct IgnoredMultipleInheritBase { - IgnoredMultipleInheritBase() : d(0.0), e(0.0) {} - virtual ~IgnoredMultipleInheritBase() {} - double d; - double e; - virtual void AVirtualMethod() {} -}; +struct IgnoredMultipleInheritBase { virtual ~IgnoredMultipleInheritBase() {} double d; double e;}; // For most compilers, this use of multiple inheritance results in different derived and base class // pointer values ... for some more challenging tests :) @@ -156,21 +142,7 @@ SwigBoost::shared_ptr*& derivedsmartptrpointerreftest(SwigBoost::s return kd; } -// 3 classes in inheritance chain test -struct Klass2ndDerived : Klass { - Klass2ndDerived() : Klass() {} - Klass2ndDerived(const std::string &val) : Klass(val) {} -}; -struct Klass3rdDerived : IgnoredMultipleInheritBase, Klass2ndDerived { - Klass3rdDerived() : Klass2ndDerived() {} - Klass3rdDerived(const std::string &val) : Klass2ndDerived(val) {} - virtual ~Klass3rdDerived() {} - virtual std::string getValue() const { return Klass2ndDerived::getValue() + "-3rdDerived"; } -}; -std::string test3rdupcast( SwigBoost::shared_ptr< Klass > k) { - return k->getValue(); -} @@ -245,14 +217,8 @@ SwigBoost::shared_ptr* smartpointerpointerownertest() { return new SwigBoost::shared_ptr(new Klass("smartpointerpointerownertest")); } -// Provide overloads for Klass and derived classes as some language modules, eg Python, create an extra reference in +// Provide overloads for Klass and KlassDerived as some language modules, eg Python, create an extra reference in // the marshalling if an upcast to a base class is required. -long use_count(const SwigBoost::shared_ptr& sptr) { - return sptr.use_count(); -} -long use_count(const SwigBoost::shared_ptr& sptr) { - return sptr.use_count(); -} long use_count(const SwigBoost::shared_ptr& sptr) { return sptr.use_count(); } diff --git a/Examples/test-suite/li_cstring.i b/Examples/test-suite/li_cstring.i index 28e8049e8..fd92ac7d3 100644 --- a/Examples/test-suite/li_cstring.i +++ b/Examples/test-suite/li_cstring.i @@ -4,7 +4,7 @@ #ifndef SWIG_CSTRING_UNIMPL -%cstring_input_binary(char *str_in, int n); +%cstring_input_binary(char *in, int n); %cstring_bounded_output(char *out1, 512); %cstring_chunk_output(char *out2, 64); %cstring_bounded_mutable(char *out3, 512); @@ -22,13 +22,13 @@ %inline %{ -int count(char *str_in, int n, char c) { +int count(char *in, int n, char c) { int r = 0; while (n > 0) { - if (*str_in == c) { + if (*in == c) { r++; } - str_in++; + in++; --n; } return r; diff --git a/Examples/test-suite/li_cwstring.i b/Examples/test-suite/li_cwstring.i index 769dcce12..dc9a1c4b9 100644 --- a/Examples/test-suite/li_cwstring.i +++ b/Examples/test-suite/li_cwstring.i @@ -4,7 +4,7 @@ #ifndef SWIG_CWSTRING_UNIMPL -%cwstring_input_binary(wchar_t *str_in, int n); +%cwstring_input_binary(wchar_t *in, int n); %cwstring_bounded_output(wchar_t *out1, 512); %cwstring_chunk_output(wchar_t *out2, 64); %cwstring_bounded_mutable(wchar_t *out3, 512); @@ -22,13 +22,13 @@ %inline %{ -int count(wchar_t *str_in, int n, wchar_t c) { +int count(wchar_t *in, int n, wchar_t c) { int r = 0; while (n > 0) { - if (*str_in == c) { + if (*in == c) { r++; } - str_in++; + in++; --n; } return r; diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index 27c1b1a70..edcb05641 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -10,7 +10,7 @@ * * For example: * swig::LANGUAGE_OBJ is GC_VALUE in Ruby - * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python + * swig::LANGUAGE_OBJ is PyObject_ptr in python * * */ @@ -47,15 +47,8 @@ namespace std %template(pairiiAc) pair >; -#ifdef SWIGRUBY %template() pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >; %template(LanguageMap) map< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >; -#endif - -#ifdef SWIGPYTHON - %template() pair; - %template(pymap) map; -#endif } diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index 8c335b24c..c2cdc2ebe 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -10,7 +10,7 @@ * * For example: * swig::LANGUAGE_OBJ is GC_VALUE in Ruby - * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python + * swig::LANGUAGE_OBJ is PyObject_ptr in python * * */ @@ -31,10 +31,4 @@ -#if defined(SWIGRUBY) %template(LanguageSet) std::set; -#endif - -#if defined(SWIGPYTHON) -%template(pyset) std::set; -#endif diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i index c6e2ea9ad..587ea2217 100644 --- a/Examples/test-suite/li_std_vector.i +++ b/Examples/test-suite/li_std_vector.i @@ -85,10 +85,8 @@ SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *) %template(StructureConstPtrVector) std::vector; #endif -#if !defined(SWIGR) %template(IntPtrVector) std::vector; %template(IntConstPtrVector) std::vector; -#endif %template(StructVector) std::vector; %template(StructPtrVector) std::vector; %template(StructConstPtrVector) std::vector; diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i deleted file mode 100644 index 688cbdd54..000000000 --- a/Examples/test-suite/li_std_vector_ptr.i +++ /dev/null @@ -1,29 +0,0 @@ -%module li_std_vector_ptr - -%include "std_vector.i" - -%template(IntPtrVector) std::vector; - -%inline %{ -#include -using namespace std; -int* makeIntPtr(int v) { - return new int(v); -} -double* makeDoublePtr(double v) { - return new double(v); -} - -#if 1 -int** makeIntPtrPtr(int* v) { - return new int*(v); -} -#endif - -void displayVector(std::vector vpi) { - cout << "displayVector..." << endl; - for (int i=0; i; + %inline { /* silently rename the parameter names in csharp/java */ #ifdef SWIGR double foo(double inparam, double out) { return 1.0; } #else - double foo(double abstract, double out) { return 1.0; } + double foo(double in, double out) { return 1.0; } #endif double bar(double native, bool boolean) { return 1.0; } } diff --git a/Examples/test-suite/namespace_typemap.i b/Examples/test-suite/namespace_typemap.i index 984b93a6f..e4e0af905 100644 --- a/Examples/test-suite/namespace_typemap.i +++ b/Examples/test-suite/namespace_typemap.i @@ -75,7 +75,7 @@ namespace test { class string_class; #ifdef SWIGPYTHON %typemap(in) string_class * { - $1 = new string_class(SWIG_Python_str_AsChar($input)); + $1 = new string_class(PyString_AsString($input)); } %typemap(freearg) string_class * { delete $1; diff --git a/Examples/test-suite/nested_comment.i b/Examples/test-suite/nested_comment.i index ea365a6fe..16f1b7af2 100644 --- a/Examples/test-suite/nested_comment.i +++ b/Examples/test-suite/nested_comment.i @@ -18,17 +18,24 @@ in rlgc models */ char *name; } n ; } s2; + %} -// comment in nested struct +// bug #491476 %inline %{ -struct a -{ - struct { - /*struct*/ - struct { - int b; - } c; - } d; -}; +struct { +struct { +int a; +} a, b; +} a; + %} + +// bug #909387 +%inline %{ +struct foo { + struct happy; // no warning + struct sad { int x; }; // warning + happy *good(); // produces good code + sad *bad(); // produces bad code +}; diff --git a/Examples/test-suite/nested_structs.i b/Examples/test-suite/nested_structs.i deleted file mode 100644 index 4b13ff69d..000000000 --- a/Examples/test-suite/nested_structs.i +++ /dev/null @@ -1,22 +0,0 @@ -%module nested_structs - -// bug #491476 -%inline %{ -struct { -struct { -int a; -} a, b; -} a; - -%} - -// bug #909387 -%inline %{ -struct foo { - struct happy; // no warning - struct sad { int x; }; // warning - happy *good(); // produces good code - sad *bad(); // produces bad code -}; -%} - diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 0e6235f94..6f0b65489 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -16,7 +16,7 @@ run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \ -f $(top_srcdir)/Examples/test-suite/$*.list ] ; then ( \ $(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme) ; \ + $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& ./runme) ; \ elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ $(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \ diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index b12cf500a..534da55c4 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -10,9 +10,7 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ - li_std_pair_extra \ - li_std_string_extra \ - octave_cell_deref + cell_deref CPP_TEST_BROKEN += \ implicittest \ diff --git a/Examples/test-suite/octave_cell_deref.i b/Examples/test-suite/octave/cell_deref.i similarity index 86% rename from Examples/test-suite/octave_cell_deref.i rename to Examples/test-suite/octave/cell_deref.i index 2e92ec4de..fddcd80ec 100644 --- a/Examples/test-suite/octave_cell_deref.i +++ b/Examples/test-suite/octave/cell_deref.i @@ -1,4 +1,4 @@ -%module octave_cell_deref +%module cell_deref %inline { bool func(const char* s) { diff --git a/Examples/test-suite/octave/octave_cell_deref_runme.m b/Examples/test-suite/octave/cell_deref_runme.m similarity index 85% rename from Examples/test-suite/octave/octave_cell_deref_runme.m rename to Examples/test-suite/octave/cell_deref_runme.m index 5a98c0a3b..1c370fe85 100644 --- a/Examples/test-suite/octave/octave_cell_deref_runme.m +++ b/Examples/test-suite/octave/cell_deref_runme.m @@ -1,4 +1,4 @@ -octave_cell_deref; +cell_deref; assert(func("hello")); assert(func({"hello"})); diff --git a/Examples/test-suite/implicittest.i b/Examples/test-suite/octave/implicittest.i similarity index 100% rename from Examples/test-suite/implicittest.i rename to Examples/test-suite/octave/implicittest.i diff --git a/Examples/test-suite/octave/li_attribute_runme.m b/Examples/test-suite/octave/li_attribute_runme.m index 548e733ed..c66e27c5b 100644 --- a/Examples/test-suite/octave/li_attribute_runme.m +++ b/Examples/test-suite/octave/li_attribute_runme.m @@ -10,6 +10,7 @@ if (aa.a != 3) error("aa.a = %i",aa.a) endif + if (aa.b != 2) error(aa.b) endif @@ -18,6 +19,8 @@ if (aa.b != 5) error endif + + if (aa.d != aa.b) error endif @@ -36,13 +39,14 @@ if (pi.value != 3) error endif + b = li_attribute.B(aa); if (b.a.c != 3) error endif + -# class/struct attribute with get/set methods using return/pass by reference myFoo = li_attribute.MyFoo(); myFoo.x = 8; myClass = li_attribute.MyClass(); @@ -51,35 +55,3 @@ if (myClass.Foo.x != 8) error endif -# class/struct attribute with get/set methods using return/pass by value -myClassVal = li_attribute.MyClassVal(); -if (myClassVal.ReadWriteFoo.x != -1) - error -endif -if (myClassVal.ReadOnlyFoo.x != -1) - error -endif -myClassVal.ReadWriteFoo = myFoo; -if (myClassVal.ReadWriteFoo.x != 8) - error -endif -if (myClassVal.ReadOnlyFoo.x != 8) - error -endif - -# string attribute with get/set methods using return/pass by value -myStringyClass = li_attribute.MyStringyClass("initial string"); -if (myStringyClass.ReadWriteString != "initial string") - error -endif -if (myStringyClass.ReadOnlyString != "initial string") - error -endif -myStringyClass.ReadWriteString = "changed string"; -if (myStringyClass.ReadWriteString != "changed string") - error -endif -if (myStringyClass.ReadOnlyString != "changed string") - error -endif - diff --git a/Examples/test-suite/li_std_pair_extra.i b/Examples/test-suite/octave/li_std_pair.i similarity index 99% rename from Examples/test-suite/li_std_pair_extra.i rename to Examples/test-suite/octave/li_std_pair.i index 4e3b3a571..886bf1a4b 100644 --- a/Examples/test-suite/li_std_pair_extra.i +++ b/Examples/test-suite/octave/li_std_pair.i @@ -1,4 +1,4 @@ -%module li_std_pair_extra +%module li_std_pair // // activate the automatic comparison methods generation (==,!=,...) diff --git a/Examples/test-suite/octave/li_std_pair_extra_runme.m b/Examples/test-suite/octave/li_std_pair_extra_runme.m deleted file mode 100644 index 0f9e9a23d..000000000 --- a/Examples/test-suite/octave/li_std_pair_extra_runme.m +++ /dev/null @@ -1,69 +0,0 @@ -li_std_pair_extra - -p = {1,2}; -p1 = li_std_pair_extra.p_inout(p); -assert(all(cell2mat(p1)==[2,1])); -p2 = li_std_pair_extra.p_inoutd(p1); -assert(all(cell2mat(p2)==[1,2])); - -d1 = li_std_pair_extra.d_inout(2); -assert(d1==4); - -[i,d2] = li_std_pair_extra.d_inout2(2); -assert(all([i,d2]==[1,4])); - -[i,p] = li_std_pair_extra.p_inout2(p); -assert(i==1&&all([cell2mat(p)]==[2,1])); -[p3,p4] = li_std_pair_extra.p_inout3(p1,p1); -assert(all(cell2mat(p3)==[2,1])); -assert(all(cell2mat(p4)==[2,1])); - -psi = li_std_pair_extra.SIPair("hello",1); -assert(psi=={"hello",1}); -pci = li_std_pair_extra.CIPair(complex(1,2),1); -assert(pci.first==complex(1,2)&&pci.second==1); - - -psi = li_std_pair_extra.SIPair("hi",1); -assert(psi.first=="hi"&&psi.second==1); - -psii = li_std_pair_extra.SIIPair(psi,1); -assert(psii.first.first=="hi"); -assert(psii.first.second==1); -assert(psii.second==1); - -a = li_std_pair_extra.A(); -b = li_std_pair_extra.B(); - -pab = li_std_pair_extra.ABPair(a,b); - -pab.first = a; -pab.first.val = 2; - -assert(pab.first.val == 2); - -pci = li_std_pair_extra.CIntPair(1,0); -assert(pci.first==1&&pci.second==0); - -a = li_std_pair_extra.A(5); -p1 = li_std_pair_extra.pairP1(1,a); -p2 = li_std_pair_extra.pairP2(a,1); -p3 = li_std_pair_extra.pairP3(a,a); - -assert(a.val == li_std_pair_extra.p_identa(p1){2}.val); - -p = li_std_pair_extra.IntPair(1,10); -assert(p.first==1&&p.second==10); -p.first = 1; -assert(p.first==1); - -p = li_std_pair_extra.paircA1(1,a); -assert(p.first==1); -assert(swig_this(p.second)==swig_this(a)); - -p = li_std_pair_extra.paircA2(1,a); -assert(p.first==1); -assert(swig_this(p.second)==swig_this(a)); -#pp = li_std_pair_extra.pairiiA(1,p); # conversion pb re const of pairA1/A2 -pp = li_std_pair_extra.pairiiA(1,{1,A()}); - diff --git a/Examples/test-suite/octave/li_std_pair_runme.m b/Examples/test-suite/octave/li_std_pair_runme.m new file mode 100644 index 000000000..83e9fe5b5 --- /dev/null +++ b/Examples/test-suite/octave/li_std_pair_runme.m @@ -0,0 +1,69 @@ +li_std_pair + +p = {1,2}; +p1 = li_std_pair.p_inout(p); +assert(all(cell2mat(p1)==[2,1])); +p2 = li_std_pair.p_inoutd(p1); +assert(all(cell2mat(p2)==[1,2])); + +d1 = li_std_pair.d_inout(2); +assert(d1==4); + +[i,d2] = li_std_pair.d_inout2(2); +assert(all([i,d2]==[1,4])); + +[i,p] = li_std_pair.p_inout2(p); +assert(i==1&&all([cell2mat(p)]==[2,1])); +[p3,p4] = li_std_pair.p_inout3(p1,p1); +assert(all(cell2mat(p3)==[2,1])); +assert(all(cell2mat(p4)==[2,1])); + +psi = li_std_pair.SIPair("hello",1); +assert(psi=={"hello",1}); +pci = li_std_pair.CIPair(complex(1,2),1); +assert(pci.first==complex(1,2)&&pci.second==1); + + +psi = li_std_pair.SIPair("hi",1); +assert(psi.first=="hi"&&psi.second==1); + +psii = li_std_pair.SIIPair(psi,1); +assert(psii.first.first=="hi"); +assert(psii.first.second==1); +assert(psii.second==1); + +a = li_std_pair.A(); +b = li_std_pair.B(); + +pab = li_std_pair.ABPair(a,b); + +pab.first = a; +pab.first.val = 2; + +assert(pab.first.val == 2); + +pci = li_std_pair.CIntPair(1,0); +assert(pci.first==1&&pci.second==0); + +a = li_std_pair.A(5); +p1 = li_std_pair.pairP1(1,a); +p2 = li_std_pair.pairP2(a,1); +p3 = li_std_pair.pairP3(a,a); + +assert(a.val == li_std_pair.p_identa(p1){2}.val); + +p = li_std_pair.IntPair(1,10); +assert(p.first==1&&p.second==10); +p.first = 1; +assert(p.first==1); + +p = li_std_pair.paircA1(1,a); +assert(p.first==1); +assert(swig_this(p.second)==swig_this(a)); + +p = li_std_pair.paircA2(1,a); +assert(p.first==1); +assert(swig_this(p.second)==swig_this(a)); +#pp = li_std_pair.pairiiA(1,p); # conversion pb re const of pairA1/A2 +pp = li_std_pair.pairiiA(1,{1,A()}); + diff --git a/Examples/test-suite/li_std_string_extra.i b/Examples/test-suite/octave/li_std_string.i similarity index 93% rename from Examples/test-suite/li_std_string_extra.i rename to Examples/test-suite/octave/li_std_string.i index aa758532a..822d713c4 100644 --- a/Examples/test-suite/li_std_string_extra.i +++ b/Examples/test-suite/octave/li_std_string.i @@ -1,4 +1,4 @@ -%module li_std_string_extra +%module li_std_string %naturalvar A; @@ -51,5 +51,5 @@ std::basic_string,std::allocator > test_value_ %} -%include "li_std_string.i" +%include ../li_std_string.i diff --git a/Examples/test-suite/octave/li_std_string_extra_runme.m b/Examples/test-suite/octave/li_std_string_extra_runme.m deleted file mode 100644 index 8d506af8a..000000000 --- a/Examples/test-suite/octave/li_std_string_extra_runme.m +++ /dev/null @@ -1,162 +0,0 @@ -li_std_string_extra - -x="hello"; - - - -if (li_std_string_extra.test_ccvalue(x) != x) - error("bad string mapping") -endif - -if (li_std_string_extra.test_cvalue(x) != x) - error("bad string mapping") -endif - -if (li_std_string_extra.test_value(x) != x) - error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x)) -endif - -if (li_std_string_extra.test_const_reference(x) != x) - error("bad string mapping") -endif - - -s = li_std_string_extra.string("he"); -#s += "ll" -#s.append("ll") -s = s + "llo"; - -if (s != x) - error("bad string mapping: %s, %s", s, x); -endif - -#if (s(1:4) != x(1:4)) -# error("bad string mapping") -#endif - -if (li_std_string_extra.test_value(s) != x) - error("bad string mapping") -endif - -if (li_std_string_extra.test_const_reference(s) != x) - error("bad string mapping") -endif - -a = li_std_string_extra.A(s); - -if (li_std_string_extra.test_value(a) != x) - error("bad string mapping") -endif - -if (li_std_string_extra.test_const_reference(a) != x) - error("bad string mapping") -endif - -b = li_std_string_extra.string(" world"); - -s = a + b; -if (a + b != "hello world") - error("bad string mapping: %s", a + b) -endif - -if (a + " world" != "hello world") - error("bad string mapping") -endif - -#if ("hello" + b != "hello world") -# error("bad string mapping") -#endif - -c = (li_std_string_extra.string("hello") + b); -if (c.find_last_of("l") != 9) - error("bad string mapping") -endif - -s = "hello world"; - -b = li_std_string_extra.B("hi"); - -b.name = li_std_string_extra.string("hello"); -if (b.name != "hello") - error("bad string mapping") -endif - - -b.a = li_std_string_extra.A("hello"); -if (b.a != "hello") - error("bad string mapping") -endif - - -if (li_std_string_extra.test_value_basic1(x) != x) - error("bad string mapping") -endif - -if (li_std_string_extra.test_value_basic2(x) != x) - error("bad string mapping") -endif - - -if (li_std_string_extra.test_value_basic3(x) != x) - error("bad string mapping") -endif - -# Global variables -s = "initial string"; -if (li_std_string_extra.cvar.GlobalString2 != "global string 2") - error("GlobalString2 test 1") -endif -li_std_string_extra.cvar.GlobalString2 = s; -if (li_std_string_extra.cvar.GlobalString2 != s) - error("GlobalString2 test 2") -endif -if (li_std_string_extra.cvar.ConstGlobalString != "const global string") - error("ConstGlobalString test") -endif - -# Member variables -myStructure = li_std_string_extra.Structure(); -if (myStructure.MemberString2 != "member string 2") - error("MemberString2 test 1") -endif -myStructure.MemberString2 = s; -if (myStructure.MemberString2 != s) - error("MemberString2 test 2") -endif -if (myStructure.ConstMemberString != "const member string") - error("ConstMemberString test") -endif - -if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2") - error("StaticMemberString2 test 1") -endif -li_std_string_extra.cvar.Structure_StaticMemberString2 = s; -if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s) - error("StaticMemberString2 test 2") -endif -if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string") - error("ConstStaticMemberString test") -endif - - -if (li_std_string_extra.test_reference_input("hello") != "hello") - error -endif -s = li_std_string_extra.test_reference_inout("hello"); -if (s != "hellohello") - error -endif - - -if (li_std_string_extra.stdstring_empty() != "") - error -endif - - -if (li_std_string_extra.c_empty() != "") - error -endif - -#if (li_std_string_extra.c_null() != None) -# error -#endif diff --git a/Examples/test-suite/octave/li_std_string_runme.m b/Examples/test-suite/octave/li_std_string_runme.m new file mode 100644 index 000000000..fa0e260e0 --- /dev/null +++ b/Examples/test-suite/octave/li_std_string_runme.m @@ -0,0 +1,162 @@ +li_std_string + +x="hello"; + + + +if (li_std_string.test_ccvalue(x) != x) + error("bad string mapping") +endif + +if (li_std_string.test_cvalue(x) != x) + error("bad string mapping") +endif + +if (li_std_string.test_value(x) != x) + error("bad string mapping: %s, %s", x, li_std_string.test_value(x)) +endif + +if (li_std_string.test_const_reference(x) != x) + error("bad string mapping") +endif + + +s = li_std_string.string("he"); +#s += "ll" +#s.append('o') +s = s + "llo"; + +if (s != x) + error("bad string mapping: %s, %s", s, x); +endif + +if (s[1:4] != x[1:4]) + error("bad string mapping") +endif + +if (li_std_string.test_value(s) != x) + error("bad string mapping") +endif + +if (li_std_string.test_const_reference(s) != x) + error("bad string mapping") +endif + +a = li_std_string.A(s); + +if (li_std_string.test_value(a) != x) + error("bad string mapping") +endif + +if (li_std_string.test_const_reference(a) != x) + error("bad string mapping") +endif + +b = li_std_string.string(" world"); + +s = a + b; +if (a + b != "hello world") + error("bad string mapping: %s", a + b) +endif + +if (a + " world" != "hello world") + error("bad string mapping") +endif + +if ("hello" + b != "hello world") + error("bad string mapping") +endif + +c = ("hello" + b) +if (c.find_last_of("l") != 9) + error("bad string mapping") +endif + +s = "hello world"; + +b = li_std_string.B("hi"); + +b.name = li_std_string.string("hello"); +if (b.name != "hello") + error("bad string mapping") +endif + + +b.a = li_std_string.A("hello"); +if (b.a != "hello") + error("bad string mapping") +endif + + +if (li_std_string.test_value_basic1(x) != x) + error("bad string mapping") +endif + +if (li_std_string.test_value_basic2(x) != x) + error("bad string mapping") +endif + + +if (li_std_string.test_value_basic3(x) != x) + error("bad string mapping") +endif + +# Global variables +s = "initial string"; +if (li_std_string.cvar.GlobalString2 != "global string 2") + error("GlobalString2 test 1") +endif +li_std_string.cvar.GlobalString2 = s; +if (li_std_string.cvar.GlobalString2 != s) + error("GlobalString2 test 2") +endif +if (li_std_string.cvar.ConstGlobalString != "const global string") + error("ConstGlobalString test") +endif + +# Member variables +myStructure = li_std_string.Structure(); +if (myStructure.MemberString2 != "member string 2") + error("MemberString2 test 1") +endif +myStructure.MemberString2 = s; +if (myStructure.MemberString2 != s) + error("MemberString2 test 2") +endif +if (myStructure.ConstMemberString != "const member string") + error("ConstMemberString test") +endif + +if (li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2") + error("StaticMemberString2 test 1") +endif +li_std_string.cvar.Structure_StaticMemberString2 = s; +if (li_std_string.cvar.Structure_StaticMemberString2 != s) + error("StaticMemberString2 test 2") +endif +if (li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string") + error("ConstStaticMemberString test") +endif + + +if (li_std_string.test_reference_input("hello") != "hello") + error +endif +s = li_std_string.test_reference_inout("hello"); +if (s != "hellohello") + error +endif + + +if (li_std_string.stdstring_empty() != "") + error +endif + + +if (li_std_string.c_empty() != "") + error +endif + +if (li_std_string.c_null() != None) + error +endif diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i index c9b0a6e34..78330c88d 100644 --- a/Examples/test-suite/operator_overload.i +++ b/Examples/test-suite/operator_overload.i @@ -76,12 +76,6 @@ see bottom for a set of possible tests %rename(OrOperator) operator ||; #endif -#ifdef SWIG_ALLEGRO_CL -%{ -#include -%} -#endif - %rename(IntCast) operator int(); %rename(DoubleCast) operator double(); diff --git a/Examples/test-suite/operbool.i b/Examples/test-suite/operbool.i deleted file mode 100644 index 793c0174e..000000000 --- a/Examples/test-suite/operbool.i +++ /dev/null @@ -1,12 +0,0 @@ -%module operbool - -%rename(operbool) operator bool(); - -%inline %{ - class Test { - public: - operator bool() { - return false; - } - }; -%} diff --git a/Examples/test-suite/packageoption.h b/Examples/test-suite/packageoption.h index 82f29d1c7..a7ef499aa 100644 --- a/Examples/test-suite/packageoption.h +++ b/Examples/test-suite/packageoption.h @@ -1,6 +1,5 @@ -struct Base { - virtual int vmethod() { return 1; } - int basemethod() { return 1; } - virtual ~Base() {} +class A +{ + public: + int testInt() { return 2;} }; - diff --git a/Examples/test-suite/packageoption.list b/Examples/test-suite/packageoption.list index da125c2a3..4bdabeccf 100644 --- a/Examples/test-suite/packageoption.list +++ b/Examples/test-suite/packageoption.list @@ -1,3 +1,2 @@ packageoption_a packageoption_b -packageoption_c diff --git a/Examples/test-suite/packageoption_a.i b/Examples/test-suite/packageoption_a.i index b28278282..e95091b0d 100644 --- a/Examples/test-suite/packageoption_a.i +++ b/Examples/test-suite/packageoption_a.i @@ -1,4 +1,4 @@ -%module(package="CommonPackage") "packageoption_a"; +%module(package="C") "packageoption_a"; %inline %{ class A @@ -6,11 +6,5 @@ class A public: int testInt() { return 2;} }; + %} - -%{ -#include "packageoption.h" -%} - -%include "packageoption.h" - diff --git a/Examples/test-suite/packageoption_b.i b/Examples/test-suite/packageoption_b.i index 40a44be14..466853cc0 100644 --- a/Examples/test-suite/packageoption_b.i +++ b/Examples/test-suite/packageoption_b.i @@ -1,4 +1,4 @@ -%module(package="CommonPackage") "packageoption_b"; +%module(package="C") "packageoption_b"; %inline %{ class B diff --git a/Examples/test-suite/packageoption_c.i b/Examples/test-suite/packageoption_c.i deleted file mode 100644 index f43e47002..000000000 --- a/Examples/test-suite/packageoption_c.i +++ /dev/null @@ -1,13 +0,0 @@ -%module(package="PackageC") "packageoption_c"; - -%import "packageoption_a.i" - -%inline %{ -#include "packageoption.h" - -struct Derived : Base { - virtual int vmethod() { return 2; } - virtual ~Derived() {} -}; - -%} diff --git a/Examples/test-suite/perl5/char_strings_runme.pl b/Examples/test-suite/perl5/char_strings_runme.pl index c4573737e..51c227bb9 100644 --- a/Examples/test-suite/perl5/char_strings_runme.pl +++ b/Examples/test-suite/perl5/char_strings_runme.pl @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 4; BEGIN { use_ok('char_strings') } require_ok('char_strings'); @@ -10,6 +10,3 @@ is(char_strings::CharPingPong($val1), "100", 'cstr1'); my $val2 = "greetings"; is(char_strings::CharPingPong($val2), "greetings", 'cstr2'); -# SF#2564192 -"this is a test" =~ /(\w+)$/; -is(char_strings::CharPingPong($1), "test", "handles Magical"); diff --git a/Examples/test-suite/li_std_list.i b/Examples/test-suite/perl5/li_std_list.i similarity index 100% rename from Examples/test-suite/li_std_list.i rename to Examples/test-suite/perl5/li_std_list.i diff --git a/Examples/test-suite/perl5/li_typemaps_runme.pl b/Examples/test-suite/perl5/li_typemaps_runme.pl index c182cdbb1..c149284ae 100644 --- a/Examples/test-suite/perl5/li_typemaps_runme.pl +++ b/Examples/test-suite/perl5/li_typemaps_runme.pl @@ -37,29 +37,24 @@ batch('ulong', 0, 1, 12, 0xffffffff); batch('uchar', 0, 1, 12, 0xff); batch('schar', -0x80, 0, 1, 12, 0x7f); -{ - use Math::BigInt qw(); - # the pack dance is to get plain old NVs out of the - # Math::BigInt objects. - my $inf = unpack 'd', pack 'd', Math::BigInt->binf(); - my $nan = unpack 'd', pack 'd', Math::BigInt->bnan(); - batch('float', - -(2 - 2 ** -23) * 2 ** 127, - -1, -2 ** -149, 0, 2 ** -149, 1, - (2 - 2 ** -23) * 2 ** 127, - $nan); - { local $TODO = "float typemaps don't pass infinity"; - # it seems as though SWIG is unwilling to pass infinity around - # because that value always fails bounds checking. I think that - # is a bug. - batch('float', $inf); - } - batch('double', - -(2 - 2 ** -53) ** 1023, - -1, -2 ** -1074, 0, 2 ** 1074, - (2 - 2 ** -53) ** 1023, - $nan, $inf); +# IEEE 754 machine, please! +batch('float', + -(2 - 2 ** -23) * 2 ** 127, + -1, -2 ** -149, 0, 2 ** -149, 1, + (2 - 2 ** -23) * 2 ** 127, + 'nan'); +{ local $TODO = "shouldn't some Inf <=> float work?"; + # I'm going to guess that it could work reasonably as + # NV Inf => float Inf + # float Inf => NV NaN + # but this needs some thought. + batch('float', 'inf'); } +batch('double', + -(2 - 2 ** -53) ** 1023, + -1, -2 ** -1074, 0, 2 ** 1074, + (2 - 2 ** -53) ** 1023, + 'nan', 'inf'); batch('longlong', -1, 0, 1, 12); batch('ulonglong', 0, 1, 12); SKIP: { diff --git a/Examples/test-suite/perl5/packageoption_runme.pl b/Examples/test-suite/perl5/packageoption_runme.pl index d94a7a1fd..debea78e1 100644 --- a/Examples/test-suite/perl5/packageoption_runme.pl +++ b/Examples/test-suite/perl5/packageoption_runme.pl @@ -14,11 +14,11 @@ sub ok_not ($;$) { ok($test, $name); } -my $a = CommonPackage::A->new(); +my $a = C::A->new(); -isa_ok($a, 'CommonPackage::A'); +isa_ok($a, 'C::A'); -my $b = CommonPackage::B->new(); +my $b = C::B->new(); -isa_ok($b, 'CommonPackage::B'); +isa_ok($b, 'C::B'); diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php4/Makefile.in similarity index 69% rename from Examples/test-suite/php/Makefile.in rename to Examples/test-suite/php4/Makefile.in index b8aeaaa11..2e14ef9a2 100644 --- a/Examples/test-suite/php/Makefile.in +++ b/Examples/test-suite/php4/Makefile.in @@ -1,16 +1,13 @@ ####################################################################### -# Makefile for php test-suite +# Makefile for php4 test-suite ####################################################################### -LANGUAGE = php -SCRIPTSUFFIX = _runme.php +LANGUAGE = php4 +SCRIPTSUFFIX = _runme.php4 srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -#CPP_TEST_CASES += \ -# php_namewarn_rename \ - include $(srcdir)/../common.mk # Overridden variables here @@ -25,19 +22,19 @@ makectests: @bash -ec 'for test in $(C_TEST_CASES) ; do $($(MAKE)) clean && $(MAKE) $${test}.cpptest; done' runcpptests: - @bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done' + @bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done' runctests: - @bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done' + @bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done' runtests: runcpptests runctests -# write out tests without a _runme.php +# write out tests without a _runme.php4 missingcpptests: - @bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done' + @bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done' missingctests: - @bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done' + @bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done' missingtests: missingcpptests missingctests @@ -58,10 +55,10 @@ missingtests: missingcpptests missingctests +$(run_testcase) # Runs the testcase. A testcase is only run if -# a file is found which has _runme.php appended after the testcase name. +# a file is found which has _runme.php4 appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php_run;) \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php4_run;) \ fi; # Clean: remove the generated .php file @@ -69,4 +66,4 @@ run_testcase = \ @rm -f $*.php; clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php4_clean diff --git a/Examples/test-suite/php/abstract_inherit_ok_runme.php b/Examples/test-suite/php4/abstract_inherit_ok_runme.php4 similarity index 88% rename from Examples/test-suite/php/abstract_inherit_ok_runme.php rename to Examples/test-suite/php4/abstract_inherit_ok_runme.php4 index c2d86499b..1182e4cec 100644 --- a/Examples/test-suite/php/abstract_inherit_ok_runme.php +++ b/Examples/test-suite/php4/abstract_inherit_ok_runme.php4 @@ -1,6 +1,6 @@ diff --git a/Examples/test-suite/php/arrays_global_twodim_runme.php b/Examples/test-suite/php4/arrays_global_twodim_runme.php4 similarity index 97% rename from Examples/test-suite/php/arrays_global_twodim_runme.php rename to Examples/test-suite/php4/arrays_global_twodim_runme.php4 index d9b62de0d..352ad2568 100644 --- a/Examples/test-suite/php/arrays_global_twodim_runme.php +++ b/Examples/test-suite/php4/arrays_global_twodim_runme.php4 @@ -1,7 +1,7 @@ /dev/null 2>&1 - - # Runs the testcase. A testcase is only run if -# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name. - -run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) - -py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) -py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) - -ifeq (,$(PY3)) +# a file is found which has _runme.py appended after the testcase name. run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ - $(run_python);)\ + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \ fi; -else -run_testcase = \ - if [ -f $(py2_runme) ]; then ( \ - $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && \ - $(run_python);) \ - elif [ -f $(py3_runme) ]; then ( \ - $(run_python);) \ - fi; -endif # Clean: remove the generated .py file %.clean: @rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py @rm -f $*.py; - @#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py. - @if [ -f $(py2_runme) ]; then (rm -f $(py3_runme) $(py3_runme).bak;) fi; clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean @@ -153,15 +101,14 @@ cvsignore: @echo clientdata_prop_b.py @echo imports_a.py @echo imports_b.py - @echo mod_a.py mod_b.py + @echo mod_a.py mod_b.py @echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py @echo template_typedef_import.py -hugemod_runme = hugemod$(SCRIPTPREFIX) hugemod: - perl hugemod.pl $(hugemod_runme) + perl hugemod.pl $(MAKE) hugemod_a.cpptest $(MAKE) hugemod_b.cpptest - sh -c "time $(PYTHON) $(hugemod_runme)" - sh -c "time $(PYTHON) $(hugemod_runme)" + time $(PYTHON) hugemod_runme.py + time $(PYTHON) hugemod_runme.py diff --git a/Examples/test-suite/python/README b/Examples/test-suite/python/README index 71db759b5..b86ec5289 100644 --- a/Examples/test-suite/python/README +++ b/Examples/test-suite/python/README @@ -1,8 +1,4 @@ See ../README for common README file. -Any testcases which have _runme.py (or _runme3.py for Python 3) appended after the testcase name will be detected and run. +Any testcases which have _runme.py appended after the testcase name will be detected and run. -If you intend to write a testcase for both Python 2.x and 3.x, do *not* directly put the _runme3.py in this directory. Just write Python 2.x's _runme.py testcase and it will be automatically converted to Python 3 code during test. - -You can run make with PY3=y to run test case with Python 3.x, eg. - $ make voidtest.cpptest PY3=y diff --git a/Examples/test-suite/argcargvtest.i b/Examples/test-suite/python/argcargvtest.i similarity index 100% rename from Examples/test-suite/argcargvtest.i rename to Examples/test-suite/python/argcargvtest.i diff --git a/Examples/test-suite/python_autodoc.i b/Examples/test-suite/python/autodoc.i similarity index 97% rename from Examples/test-suite/python_autodoc.i rename to Examples/test-suite/python/autodoc.i index c363e4384..c22cc02f0 100644 --- a/Examples/test-suite/python_autodoc.i +++ b/Examples/test-suite/python/autodoc.i @@ -1,4 +1,4 @@ -%module(docstring="hello") python_autodoc +%module(docstring="hello") autodoc %feature("autodoc"); diff --git a/Examples/test-suite/callback.i b/Examples/test-suite/python/callback.i similarity index 100% rename from Examples/test-suite/callback.i rename to Examples/test-suite/python/callback.i diff --git a/Examples/test-suite/complextest.i b/Examples/test-suite/python/complextest.i similarity index 100% rename from Examples/test-suite/complextest.i rename to Examples/test-suite/python/complextest.i diff --git a/Examples/test-suite/python/contract_runme.py b/Examples/test-suite/python/contract_runme.py index 905bf1196..9ded5bb5b 100644 --- a/Examples/test-suite/python/contract_runme.py +++ b/Examples/test-suite/python/contract_runme.py @@ -133,11 +133,3 @@ try: except: pass -#Namespace -my = contract.myClass(1) -try: - my = contract.myClass(0) - print "Failed! constructor preassertion" -except: - pass - diff --git a/Examples/test-suite/python/cpp_namespace_runme.py b/Examples/test-suite/python/cpp_namespace_runme.py index a454774f5..3108b4f47 100644 --- a/Examples/test-suite/python/cpp_namespace_runme.py +++ b/Examples/test-suite/python/cpp_namespace_runme.py @@ -3,20 +3,20 @@ import cpp_namespace n = cpp_namespace.fact(4) if n != 24: - raise RuntimeError("Bad return value!") + raise "Bad return value!" if cpp_namespace.cvar.Foo != 42: - raise RuntimeError("Bad variable value!") + raise "Bad variable value!" t = cpp_namespace.Test() if t.method() != "Test::method": - raise RuntimeError("Bad method return value!") + raise "Bad method return value!" if cpp_namespace.do_method(t) != "Test::method": - raise RuntimeError("Bad return value!") + raise "Bad return value!" if cpp_namespace.do_method2(t) != "Test::method": - raise RuntimeError("Bad return value!") + raise "Bad return value!" cpp_namespace.weird("hello", 4) @@ -28,18 +28,18 @@ t4 = cpp_namespace.Test4() t5 = cpp_namespace.Test5() if cpp_namespace.foo3(42) != 42: - raise RuntimeError("Bad return value!") + raise "Bad return value!" if cpp_namespace.do_method3(t2,40) != "Test2::method": - raise RuntimeError("Bad return value!") + raise "Bad return value!" if cpp_namespace.do_method3(t3,40) != "Test3::method": - raise RuntimeError("Bad return value!") + raise "Bad return value!" if cpp_namespace.do_method3(t4,40) != "Test4::method": - raise RuntimeError("Bad return value!") + raise "Bad return value!" if cpp_namespace.do_method3(t5,40) != "Test5::method": - raise RuntimeError("Bad return value!") + raise "Bad return value!" diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py deleted file mode 100644 index ef8623359..000000000 --- a/Examples/test-suite/python/cpp_static_runme.py +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/evn python -from cpp_static import * -StaticFunctionTest.static_func() -StaticFunctionTest.static_func_2(1) -StaticFunctionTest.static_func_3(1,2) -StaticMemberTest.static_int = 10 -assert StaticMemberTest.static_int == 10 diff --git a/Examples/test-suite/python/director_classic_runme.py b/Examples/test-suite/python/director_classic_runme.py index 7e18a9a61..878905679 100644 --- a/Examples/test-suite/python/director_classic_runme.py +++ b/Examples/test-suite/python/director_classic_runme.py @@ -1,56 +1,56 @@ from director_classic import * class TargetLangPerson(Person): - def __init__(self): - Person.__init__(self) - def id(self): - identifier = "TargetLangPerson" - return identifier + def __init__(self): + Person.__init__(self) + def id(self): + identifier = "TargetLangPerson" + return identifier class TargetLangChild(Child): - def __init__(self): - Child.__init__(self) - def id(self): - identifier = "TargetLangChild" - return identifier + def __init__(self): + Child.__init__(self) + def id(self): + identifier = "TargetLangChild" + return identifier class TargetLangGrandChild(GrandChild): - def __init__(self): - GrandChild.__init__(self) - def id(self): - identifier = "TargetLangGrandChild" - return identifier + def __init__(self): + GrandChild.__init__(self) + def id(self): + identifier = "TargetLangGrandChild" + return identifier # Semis - don't override id() in target language class TargetLangSemiPerson(Person): - def __init__(self): - Person.__init__(self) + def __init__(self): + Person.__init__(self) # No id() override class TargetLangSemiChild(Child): - def __init__(self): - Child.__init__(self) + def __init__(self): + Child.__init__(self) # No id() override class TargetLangSemiGrandChild(GrandChild): - def __init__(self): - GrandChild.__init__(self) + def __init__(self): + GrandChild.__init__(self) # No id() override # Orphans - don't override id() in C++ class TargetLangOrphanPerson(OrphanPerson): - def __init__(self): - OrphanPerson.__init__(self) - def id(self): - identifier = "TargetLangOrphanPerson" - return identifier + def __init__(self): + OrphanPerson.__init__(self) + def id(self): + identifier = "TargetLangOrphanPerson" + return identifier class TargetLangOrphanChild(OrphanChild): - def __init__(self): - Child.__init__(self) - def id(self): - identifier = "TargetLangOrphanChild" - return identifier + def __init__(self): + Child.__init__(self) + def id(self): + identifier = "TargetLangOrphanChild" + return identifier def check(person, expected): @@ -61,7 +61,7 @@ def check(person, expected): if (debug): print(ret) if (ret != expected): - raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected) + raise ("Failed. Received: " + ret + " Expected: " + expected) # Polymorphic call from C++ caller = Caller() @@ -70,7 +70,7 @@ def check(person, expected): if (debug): print(ret) if (ret != expected): - raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected) + raise ("Failed. Received: " + ret + " Expected: " + expected) # Polymorphic call of object created in target language and passed to C++ and back again baseclass = caller.baseClass() @@ -78,7 +78,7 @@ def check(person, expected): if (debug): print(ret) if (ret != expected): - raise RuntimeError("Failed. Received: " + str(ret)+ " Expected: " + expected) + raise ("Failed. Received: " + ret + " Expected: " + expected) caller.resetCallback() if (debug): diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index ef7a044f1..7c9e69250 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -1,8 +1,5 @@ from director_exception import * - -class MyException(Exception): - def __init__(self, a, b): - self.msg = a + b +from exceptions import * class MyFoo(Foo): def ping(self): @@ -10,62 +7,39 @@ class MyFoo(Foo): class MyFoo2(Foo): def ping(self): - return True + return true pass # error: should return a string -class MyFoo3(Foo): - def ping(self): - raise MyException("foo", "bar") - -# Check that the NotImplementedError raised by MyFoo.ping() is returned by -# MyFoo.pong(). ok = 0 + a = MyFoo() b = launder(a) + try: b.pong() except NotImplementedError, e: - if str(e) == "MyFoo::ping() EXCEPTION": - ok = 1 - else: - print "Unexpected error message: %s" % str(e) + ok = 1 except: pass + if not ok: raise RuntimeError - -# Check that the director returns the appropriate TypeError if the return type -# is wrong. ok = 0 + a = MyFoo2() b = launder(a) + try: b.pong() -except TypeError, e: - if str(e) == "Swig director type mismatch in output value of type 'std::string'": - ok = 1 - else: - print "Unexpected error message: %s" % str(e) +except: + ok = 1 + + if not ok: raise RuntimeError -# Check that the director can return an exception which requires two arguments -# to the constructor, without mangling it. -ok = 0 -a = MyFoo3() -b = launder(a) -try: - b.pong() -except MyException, e: - if e.msg == 'foobar': - ok = 1 - else: - print "Unexpected error message: %s" % str(e) -if not ok: - raise RuntimeError - try: raise Exception2() except Exception2: diff --git a/Examples/test-suite/director_profile.i b/Examples/test-suite/python/director_profile.i similarity index 100% rename from Examples/test-suite/director_profile.i rename to Examples/test-suite/python/director_profile.i diff --git a/Examples/test-suite/director_stl.i b/Examples/test-suite/python/director_stl.i similarity index 100% rename from Examples/test-suite/director_stl.i rename to Examples/test-suite/python/director_stl.i diff --git a/Examples/test-suite/python/director_thread_runme.py b/Examples/test-suite/python/director_thread_runme.py index 15a12ab80..e66817e17 100644 --- a/Examples/test-suite/python/director_thread_runme.py +++ b/Examples/test-suite/python/director_thread_runme.py @@ -14,5 +14,3 @@ d.run() if d.val >= 0: print d.val raise RuntimeError - -d.stop() diff --git a/Examples/test-suite/python/file_test_runme.py b/Examples/test-suite/python/file_test_runme.py index de4e2669e..64154c619 100644 --- a/Examples/test-suite/python/file_test_runme.py +++ b/Examples/test-suite/python/file_test_runme.py @@ -1,8 +1,7 @@ import sys import file_test -if sys.version_info < (3,0): - file_test.nfile(sys.stdout) +file_test.nfile(sys.stdout) cstdout = file_test.GetStdOut() diff --git a/Examples/test-suite/python/hugemod.pl b/Examples/test-suite/python/hugemod.pl index 5420926e4..15c4ce41b 100644 --- a/Examples/test-suite/python/hugemod.pl +++ b/Examples/test-suite/python/hugemod.pl @@ -2,12 +2,8 @@ use strict; -my $modsize = 399; #adjust it so you can have a smaller or bigger hugemod - -my $runme = shift @ARGV; - open HEADER, ">hugemod.h" or die "error"; -open TEST, ">$runme" or die "error"; +open TEST, ">hugemod_runme.py" or die "error"; open I1, ">hugemod_a.i" or die "error"; open I2, ">hugemod_b.i" or die "error"; @@ -25,7 +21,7 @@ print I2 "\%inline \%{\n"; my $i; -for ($i = 0; $i < $modsize; $i++) { +for ($i = 0; $i < 6000; $i++) { my $t = $i * 4; print HEADER "class type$i { public: int a; };\n"; print I2 "class dtype$i : public type$i { public: int b; };\n"; diff --git a/Examples/test-suite/iadd.i b/Examples/test-suite/python/iadd.h similarity index 79% rename from Examples/test-suite/iadd.i rename to Examples/test-suite/python/iadd.h index 514bd3e4f..367eda26f 100644 --- a/Examples/test-suite/iadd.i +++ b/Examples/test-suite/python/iadd.h @@ -1,12 +1,3 @@ -%module iadd - -%include attribute.i -class Foo; -%attribute_ref(test::Foo, test::A& , AsA); -%attribute_ref(test::Foo, long, AsLong); - - -%inline %{ struct B { int x; B(const int x) : x(x) {} @@ -54,5 +45,3 @@ private: long *_n; }; } - -%} diff --git a/Examples/test-suite/python/iadd.i b/Examples/test-suite/python/iadd.i new file mode 100644 index 000000000..76604c027 --- /dev/null +++ b/Examples/test-suite/python/iadd.i @@ -0,0 +1,12 @@ +%module iadd + +%include attribute.i +%{ +#include "iadd.h" +%} +class Foo; +%attribute_ref(test::Foo, test::A& , AsA); +%attribute_ref(test::Foo, long, AsLong); + + +%include "iadd.h" diff --git a/Examples/test-suite/python/implicittest.i b/Examples/test-suite/python/implicittest.i new file mode 100644 index 000000000..91205aafa --- /dev/null +++ b/Examples/test-suite/python/implicittest.i @@ -0,0 +1,68 @@ +%module(naturalvar="1") implicittest + +%implicitconv; + +%inline +{ + struct B { }; +} + +%inline +{ + struct A + { + int ii; + A(int i) { ii = 1; } + A(double d) { ii = 2; } + A(const B& b) { ii = 3; } + explicit A(char *s) { ii = 4; } + + int get() const { return ii; } + + }; + + int get(const A& a) { return a.ii; } + + template + struct A_T + { + int ii; + A_T(int i) { ii = 1; } + A_T(double d) { ii = 2; } + A_T(const B& b) { ii = 3; } + explicit A_T(char *s) { ii = 4; } + + int get() const { return ii; } + + }; +} + +%inline +{ + struct Foo + { + int ii; + Foo(){ ii = 0;} + Foo(int){ ii = 1;} + Foo(double){ ii = 2;} + explicit Foo(char *s){ii = 3;} + Foo(const Foo& f){ ii = f.ii;} + + }; + + struct Bar + { + int ii; + Foo f; + Bar() {ii = -1;} + Bar(const Foo& ff){ ii = ff.ii;} + }; + + + int get_b(const Bar&b) { return b.ii; } + + Foo foo; + +} + +%template(A_int) A_T; diff --git a/Examples/test-suite/inout.i b/Examples/test-suite/python/inout.i similarity index 100% rename from Examples/test-suite/inout.i rename to Examples/test-suite/python/inout.i diff --git a/Examples/test-suite/inplaceadd.i b/Examples/test-suite/python/inplaceadd.i similarity index 100% rename from Examples/test-suite/inplaceadd.i rename to Examples/test-suite/python/inplaceadd.i diff --git a/Examples/test-suite/input.i b/Examples/test-suite/python/input.i similarity index 100% rename from Examples/test-suite/input.i rename to Examples/test-suite/python/input.i diff --git a/Examples/test-suite/python_kwargs.i b/Examples/test-suite/python/kwargs.i similarity index 98% rename from Examples/test-suite/python_kwargs.i rename to Examples/test-suite/python/kwargs.i index 28089bbf1..83713d8c2 100644 --- a/Examples/test-suite/python_kwargs.i +++ b/Examples/test-suite/python/kwargs.i @@ -1,4 +1,4 @@ -%module python_kwargs +%module kwargs %nocopyctor; %kwargs; diff --git a/Examples/test-suite/python/python_kwargs_runme.py b/Examples/test-suite/python/kwargs_runme.py similarity index 97% rename from Examples/test-suite/python/python_kwargs_runme.py rename to Examples/test-suite/python/kwargs_runme.py index fb6e191dd..91812929d 100644 --- a/Examples/test-suite/python/python_kwargs_runme.py +++ b/Examples/test-suite/python/kwargs_runme.py @@ -1,4 +1,4 @@ -from python_kwargs import * +from kwargs import * class MyFoo(Foo): def __init__(self, a , b = 0): diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py index db40b9b2a..5eeec299b 100644 --- a/Examples/test-suite/python/li_attribute_runme.py +++ b/Examples/test-suite/python/li_attribute_runme.py @@ -1,5 +1,3 @@ -# Ported to C# li_attribute_runme.cs - import li_attribute aa = li_attribute.A(1,2,3) @@ -11,6 +9,7 @@ if aa.a != 3: print aa.a raise RuntimeError + if aa.b != 2: print aa.b raise RuntimeError @@ -18,6 +17,8 @@ aa.b = 5 if aa.b != 5: raise RuntimeError + + if aa.d != aa.b: raise RuntimeError @@ -35,40 +36,17 @@ pi.value=3 if pi.value != 3: raise RuntimeError + b = li_attribute.B(aa) if b.a.c != 3: raise RuntimeError -# class/struct attribute with get/set methods using return/pass by reference -myFoo = li_attribute.MyFoo() + +myFoo = li_attribute.MyFoo myFoo.x = 8 -myClass = li_attribute.MyClass() +myClass = li_attribute.MyClass myClass.Foo = myFoo if myClass.Foo.x != 8: raise RuntimeError -# class/struct attribute with get/set methods using return/pass by value -myClassVal = li_attribute.MyClassVal() -if myClassVal.ReadWriteFoo.x != -1: - raise RuntimeError -if myClassVal.ReadOnlyFoo.x != -1: - raise RuntimeError -myClassVal.ReadWriteFoo = myFoo -if myClassVal.ReadWriteFoo.x != 8: - raise RuntimeError -if myClassVal.ReadOnlyFoo.x != 8: - raise RuntimeError - -# string attribute with get/set methods using return/pass by value -myStringyClass = li_attribute.MyStringyClass("initial string") -if myStringyClass.ReadWriteString != "initial string": - raise RuntimeError -if myStringyClass.ReadOnlyString != "initial string": - raise RuntimeError -myStringyClass.ReadWriteString = "changed string" -if myStringyClass.ReadWriteString != "changed string": - raise RuntimeError -if myStringyClass.ReadOnlyString != "changed string": - raise RuntimeError - diff --git a/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_runme.py index f967def14..5f6cbd211 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py @@ -304,15 +304,6 @@ class li_boost_shared_ptr_runme: self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr") self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref") - # 3rd derived class - k = li_boost_shared_ptr.Klass3rdDerived("me oh my") - val = k.getValue() - self.verifyValue("me oh my-3rdDerived", val) - self.verifyCount(1, k) - val = li_boost_shared_ptr.test3rdupcast(k) - self.verifyValue("me oh my-3rdDerived", val) - self.verifyCount(1, k) - # //////////////////////////////// Member variables //////////////////////////////////////// # smart pointer by value m = li_boost_shared_ptr.MemberVariables() diff --git a/Examples/test-suite/li_std_carray.i b/Examples/test-suite/python/li_std_carray.i similarity index 100% rename from Examples/test-suite/li_std_carray.i rename to Examples/test-suite/python/li_std_carray.i diff --git a/Examples/test-suite/python/li_std_map.i b/Examples/test-suite/python/li_std_map.i new file mode 100644 index 000000000..a8ba4f2e2 --- /dev/null +++ b/Examples/test-suite/python/li_std_map.i @@ -0,0 +1,58 @@ +%module("templatereduce") li_std_map + +%include std_pair.i +%include std_map.i +%include std_multimap.i + +%inline %{ +struct A{ + int val; + + A(int v = 0): val(v) + { + } + +}; +%} + +namespace std +{ + %template(pairii) pair; + %template(pairAA) pair; + %template(pairA) pair; + %template(mapA) map; + %template(mmapA) multimap; + + %template(paircA1) pair; + %template(paircA2) pair; + %template(pairiiA) pair >; + %template(pairiiAc) pair >; + + + %template() pair; + %template(pymap) map; + +} + + + +%inline +{ +std::pair +p_identa(std::pair p) { + return p; +} + +std::map m_identa(const std::map& v) +{ + return v; +} + +} + + + +namespace std +{ +%template(mapii) map; +} diff --git a/Examples/test-suite/python/li_std_pair.i b/Examples/test-suite/python/li_std_pair.i new file mode 100644 index 000000000..886bf1a4b --- /dev/null +++ b/Examples/test-suite/python/li_std_pair.i @@ -0,0 +1,210 @@ +%module li_std_pair + +// +// activate the automatic comparison methods generation (==,!=,...) +// + +%{ +#include // for std::swap +%} + + +%include std_pair.i +%include std_string.i +%include std_complex.i + +%inline +%{ + struct A + { + int val; + + A(int v = 0): val(v) + { + } + + }; + struct B + { + }; +%} + +%std_comp_methods(std::pair); + +namespace std { + %template(CIntPair) pair; + %template() pair; + %template(ShortPair) pair; + + %template(IntPair) pair; + %extend pair + { + %template(pair) pair; + } + + + + %template(SIPair) pair; + %template(CIPair) pair, int>; + %template(SIIPair) pair, int>; + %template(AIntPair) pair; + + %template(CCIntPair) pair >; + + %template(ABPair) pair; + %template(IntAPair) pair; + + %template(pairP1) pair; + %template(pairP2) pair; + %template(pairP3) pair; + %template(pairP4) pair; + %template(pairP5) pair; + %template(pairP6) pair; + +} +%std_comp_methods(std::pair, int>); + +%apply std::pair *INOUT {std::pair *INOUT2}; + +%inline %{ + +/* Test the "out" typemap for pair */ +std::pair makeIntPair(int a, int b) { + return std::make_pair(a, b); +} + +/** + * There is no "out" typemap for a pointer to a pair, so + * this should return a wrapped instance of a std::pair + * instead of the native "array" type for the target language. + */ +std::pair * makeIntPairPtr(int a, int b) { + static std::pair p = std::make_pair(a, b); + return &p; +} + +/** + * There is no "out" typemap for a non-const reference to a pair, so + * this should return a wrapped instance of a std::pair instead of + * the native "array" type for the target language. + */ +std::pair& makeIntPairRef(int a, int b) { + static std::pair p = std::make_pair(a, b); + return p; +} + +/** + * There is no "out" typemap for a const reference to a pair, so + * this should return a wrapped instance of a std::pair + * instead of the native "array" type for the target language. + */ +const std::pair & makeIntPairConstRef(int a, int b) { + static std::pair p = std::make_pair(a, b); + return p; +} + +/* Test the "in" typemap for pair */ +int product1(std::pair p) { + return p.first*p.second; +} + +/* Test the "in" typemap for const pair& */ +int product2(const std::pair& p) { + return p.first*p.second; +} + +std::pair + p_ident(std::pair p, const std::pair& q) { + return p; +} + + +std::pair +p_identa(const std::pair& p) { + return p; +} + +void +d_inout(double *INOUT) { + *INOUT += *INOUT; +} + +void +d_inout(int *INOUT) { + *INOUT += *INOUT; +} + +int +d_inout2(double *INOUT) { + *INOUT += *INOUT; + return 1; +} + +void +p_inout(std::pair *INOUT) { + std::swap(INOUT->first, INOUT->second); +} + +int +p_inout2(std::pair *INOUT) { + std::swap(INOUT->first, INOUT->second); + return 1; +} + +void + p_inout3(std::pair *INOUT, std::pair *INOUT2) { + std::swap(*INOUT, *INOUT2); +} + +void +p_inoutd(std::pair *INOUT) { + std::swap(INOUT->first, INOUT->second); +} + +std::string + s_ident(const std::string& s) { + return s; +} + +#if 0 +std::pair + p_ident(std::pair p, const std::pair& q) { + return p; +} + +/* Test the "in" typemap for const pair* */ +std::pair + p_ident(std::pair p, const std::pair& q) { + return q; +} + +/* Test the "in" typemap for const pair* */ +std::pair + p_ident(std::pair p, const std::pair& q) { + return p; +} + + +std::pair + p_ident(std::pair p, const std::pair& q) { + return p; +} + +std::pair + p_ident(std::pair p, const std::pair& q) { + return p; +} + + + +#endif +%} + + +namespace std +{ + %template(paircA1) pair; + %template(paircA2) pair; + %template(pairiiA) pair >; +} + diff --git a/Examples/test-suite/python/li_std_pair_extra_runme.py b/Examples/test-suite/python/li_std_pair_extra_runme.py deleted file mode 100644 index dc6e31b76..000000000 --- a/Examples/test-suite/python/li_std_pair_extra_runme.py +++ /dev/null @@ -1,59 +0,0 @@ -import li_std_pair_extra - -p = (1,2) -p1 = li_std_pair_extra.p_inout(p) -p2 = li_std_pair_extra.p_inoutd(p1) - -d1 = li_std_pair_extra.d_inout(2) - -i,d2 = li_std_pair_extra.d_inout2(2) - -i,p = li_std_pair_extra.p_inout2(p) -p3,p4 = li_std_pair_extra.p_inout3(p1,p1) - -psi = li_std_pair_extra.SIPair("hello",1) -pci = li_std_pair_extra.CIPair(1,1) - - -#psi.first = "hi" - - -psi = li_std_pair_extra.SIPair("hi",1) -if psi != ("hi",1): - raise RuntimeError - -psii = li_std_pair_extra.SIIPair(psi,1) - -a = li_std_pair_extra.A() -b = li_std_pair_extra.B() - -pab = li_std_pair_extra.ABPair(a,b); - -pab.first = a -pab.first.val = 2 - -if pab.first.val != 2: - raise RuntimeError - - -pci = li_std_pair_extra.CIntPair(1,0) - -a = li_std_pair_extra.A(5) -p1 = li_std_pair_extra.pairP1(1,a.this) -p2 = li_std_pair_extra.pairP2(a,1) -p3 = li_std_pair_extra.pairP3(a,a) - - -if a.val != li_std_pair_extra.p_identa(p1.this)[1].val: - raise RuntimeError - -p = li_std_pair_extra.IntPair(1,10) -p.first = 1 - -p = li_std_pair_extra.paircA1(1,a) -p.first -p.second - -p = li_std_pair_extra.paircA2(1,a) -pp = li_std_pair_extra.pairiiA(1,p) - diff --git a/Examples/test-suite/python/li_std_pair_runme.py b/Examples/test-suite/python/li_std_pair_runme.py new file mode 100644 index 000000000..b301f0d24 --- /dev/null +++ b/Examples/test-suite/python/li_std_pair_runme.py @@ -0,0 +1,59 @@ +import li_std_pair + +p = (1,2) +p1 = li_std_pair.p_inout(p) +p2 = li_std_pair.p_inoutd(p1) + +d1 = li_std_pair.d_inout(2) + +i,d2 = li_std_pair.d_inout2(2) + +i,p = li_std_pair.p_inout2(p) +p3,p4 = li_std_pair.p_inout3(p1,p1) + +psi = li_std_pair.SIPair("hello",1) +pci = li_std_pair.CIPair(1,1) + + +#psi.first = "hi" + + +psi = li_std_pair.SIPair("hi",1) +if psi != ("hi",1): + raise RuntimeError + +psii = li_std_pair.SIIPair(psi,1) + +a = li_std_pair.A() +b = li_std_pair.B() + +pab = li_std_pair.ABPair(a,b); + +pab.first = a +pab.first.val = 2 + +if pab.first.val != 2: + raise RuntimeError + + +pci = li_std_pair.CIntPair(1,0) + +a = li_std_pair.A(5) +p1 = li_std_pair.pairP1(1,a.this) +p2 = li_std_pair.pairP2(a,1) +p3 = li_std_pair.pairP3(a,a) + + +if a.val != li_std_pair.p_identa(p1.this)[1].val: + raise RuntimeError + +p = li_std_pair.IntPair(1,10) +p.first = 1 + +p = li_std_pair.paircA1(1,a) +p.first +p.second + +p = li_std_pair.paircA2(1,a) +pp = li_std_pair.pairiiA(1,p) + diff --git a/Examples/test-suite/python/li_std_set.i b/Examples/test-suite/python/li_std_set.i new file mode 100644 index 000000000..f0fddb058 --- /dev/null +++ b/Examples/test-suite/python/li_std_set.i @@ -0,0 +1,17 @@ +%module li_std_set + +%include +%include +%include +%include + +%template(set_string) std::set; +%template(set_int) std::multiset; + + +%template(v_int) std::vector; + + + + +%template(pyset) std::set; diff --git a/Examples/test-suite/python/li_std_stream.i b/Examples/test-suite/python/li_std_stream.i new file mode 100644 index 000000000..0a999ddbf --- /dev/null +++ b/Examples/test-suite/python/li_std_stream.i @@ -0,0 +1,59 @@ +%module li_std_stream + +%inline %{ + struct A; +%} + +%include +%include + + + +%callback(1) A::bar; + +%inline %{ + + struct B { + virtual ~B() + { + } + + }; + + struct A : B + { + void __add__(int a) + { + } + + void __add__(double a) + { + } + + static int bar(int a){ + return a; + } + + static int foo(int a, int (*pf)(int a)) + { + return pf(a); + } + + + std::ostream& __rlshift__(std::ostream& out) + { + out << "A class"; + return out; + } + }; +%} + +%extend std::basic_ostream{ + std::basic_ostream& + operator<<(const A& a) + { + *self << "A class"; + return *self; + } +} + diff --git a/Examples/test-suite/python/li_std_string.i b/Examples/test-suite/python/li_std_string.i new file mode 100644 index 000000000..822d713c4 --- /dev/null +++ b/Examples/test-suite/python/li_std_string.i @@ -0,0 +1,55 @@ +%module li_std_string + +%naturalvar A; + + +%include +%include + + +%inline %{ + +struct A : std::string +{ + A(const std::string& s) : std::string(s) + { + } +}; + +struct B +{ + B(const std::string& s) : cname(0), name(s), a(s) + { + } + + char *cname; + std::string name; + A a; + +}; + + +const char* test_ccvalue(const char* x) { + return x; +} + +char* test_cvalue(char* x) { + return x; +} + +std::basic_string test_value_basic1(std::basic_string x) { + return x; +} + +std::basic_string > test_value_basic2(std::basic_string > x) { + return x; +} + +std::basic_string,std::allocator > test_value_basic3(std::basic_string,std::allocator > x) { + return x; +} + +%} + +%include ../li_std_string.i + diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_runme.py similarity index 54% rename from Examples/test-suite/python/li_std_string_extra_runme.py rename to Examples/test-suite/python/li_std_string_runme.py index cef5921b0..c0dae1e25 100644 --- a/Examples/test-suite/python/li_std_string_extra_runme.py +++ b/Examples/test-suite/python/li_std_string_runme.py @@ -1,24 +1,24 @@ -import li_std_string_extra +import li_std_string x="hello" -if li_std_string_extra.test_ccvalue(x) != x: +if li_std_string.test_ccvalue(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string_extra.test_cvalue(x) != x: +if li_std_string.test_cvalue(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string_extra.test_value(x) != x: - print x, li_std_string_extra.test_value(x) +if li_std_string.test_value(x) != x: + print x, li_std_string.test_value(x) raise RuntimeError, "bad string mapping" -if li_std_string_extra.test_const_reference(x) != x: +if li_std_string.test_const_reference(x) != x: raise RuntimeError, "bad string mapping" -s = li_std_string_extra.string("he") +s = li_std_string.string("he") #s += "ll" #s.append('o') s = s + "llo" @@ -30,21 +30,21 @@ if s != x: if s[1:4] != x[1:4]: raise RuntimeError, "bad string mapping" -if li_std_string_extra.test_value(s) != x: +if li_std_string.test_value(s) != x: raise RuntimeError, "bad string mapping" -if li_std_string_extra.test_const_reference(s) != x: +if li_std_string.test_const_reference(s) != x: raise RuntimeError, "bad string mapping" -a = li_std_string_extra.A(s) +a = li_std_string.A(s) -if li_std_string_extra.test_value(a) != x: +if li_std_string.test_value(a) != x: raise RuntimeError, "bad string mapping" -if li_std_string_extra.test_const_reference(a) != x: +if li_std_string.test_const_reference(a) != x: raise RuntimeError, "bad string mapping" -b = li_std_string_extra.string(" world") +b = li_std_string.string(" world") s = a + b if a + b != "hello world": @@ -63,40 +63,40 @@ if c.find_last_of("l") != 9: s = "hello world" -b = li_std_string_extra.B("hi") +b = li_std_string.B("hi") -b.name = li_std_string_extra.string("hello") +b.name = li_std_string.string("hello") if b.name != "hello": raise RuntimeError, "bad string mapping" -b.a = li_std_string_extra.A("hello") +b.a = li_std_string.A("hello") if b.a != "hello": raise RuntimeError, "bad string mapping" -if li_std_string_extra.test_value_basic1(x) != x: +if li_std_string.test_value_basic1(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string_extra.test_value_basic2(x) != x: +if li_std_string.test_value_basic2(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string_extra.test_value_basic3(x) != x: +if li_std_string.test_value_basic3(x) != x: raise RuntimeError, "bad string mapping" # Global variables s = "initial string" -if li_std_string_extra.cvar.GlobalString2 != "global string 2": +if li_std_string.cvar.GlobalString2 != "global string 2": raise RuntimeError, "GlobalString2 test 1" -li_std_string_extra.cvar.GlobalString2 = s -if li_std_string_extra.cvar.GlobalString2 != s: +li_std_string.cvar.GlobalString2 = s +if li_std_string.cvar.GlobalString2 != s: raise RuntimeError, "GlobalString2 test 2" -if li_std_string_extra.cvar.ConstGlobalString != "const global string": +if li_std_string.cvar.ConstGlobalString != "const global string": raise RuntimeError, "ConstGlobalString test" # Member variables -myStructure = li_std_string_extra.Structure() +myStructure = li_std_string.Structure() if myStructure.MemberString2 != "member string 2": raise RuntimeError, "MemberString2 test 1" myStructure.MemberString2 = s @@ -105,28 +105,28 @@ if myStructure.MemberString2 != s: if myStructure.ConstMemberString != "const member string": raise RuntimeError, "ConstMemberString test" -if li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2": +if li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2": raise RuntimeError, "StaticMemberString2 test 1" -li_std_string_extra.cvar.Structure_StaticMemberString2 = s -if li_std_string_extra.cvar.Structure_StaticMemberString2 != s: +li_std_string.cvar.Structure_StaticMemberString2 = s +if li_std_string.cvar.Structure_StaticMemberString2 != s: raise RuntimeError, "StaticMemberString2 test 2" -if li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string": +if li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string": raise RuntimeError, "ConstStaticMemberString test" -if li_std_string_extra.test_reference_input("hello") != "hello": +if li_std_string.test_reference_input("hello") != "hello": raise RuntimeError -s = li_std_string_extra.test_reference_inout("hello") +s = li_std_string.test_reference_inout("hello") if s != "hellohello": raise RuntimeError -if li_std_string_extra.stdstring_empty() != "": +if li_std_string.stdstring_empty() != "": raise RuntimeError -if li_std_string_extra.c_empty() != "": +if li_std_string.c_empty() != "": raise RuntimeError -if li_std_string_extra.c_null() != None: +if li_std_string.c_null() != None: raise RuntimeError diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/python/li_std_vector.i similarity index 85% rename from Examples/test-suite/li_std_vector_extra.i rename to Examples/test-suite/python/li_std_vector.i index 9c2497f7c..06dafce59 100644 --- a/Examples/test-suite/li_std_vector_extra.i +++ b/Examples/test-suite/python/li_std_vector.i @@ -1,4 +1,4 @@ -%module li_std_vector_extra +%module li_std_vector %warnfilter(509) overloaded1; %warnfilter(509) overloaded2; @@ -123,17 +123,11 @@ std::vector vecStr(std::vector v) { %pointer_class(int,PtrInt) %array_functions(int,ArrInt) -%inline %{ - int *makeIntPtr(int v) { return new int(v); } - double *makeDoublePtr(double v) { return new double(v); } - int extractInt(int *p) { return *p; } -%} -%template(pyvector) std::vector; +%template(pyvector) std::vector; namespace std { - %template(ConstShortVector) vector; -// %template(ConstIntVector) vector; // interferes with vector... see new testcase li_std_vector_ptr + %template(ConstIntVector) vector; } %inline %{ diff --git a/Examples/test-suite/python/li_std_vector_ptr_runme.py b/Examples/test-suite/python/li_std_vector_ptr_runme.py deleted file mode 100644 index c5f72fde4..000000000 --- a/Examples/test-suite/python/li_std_vector_ptr_runme.py +++ /dev/null @@ -1,8 +0,0 @@ -from li_std_vector_ptr import * - -ip1 = makeIntPtr(11) -ip2 = makeIntPtr(22) - -vi = IntPtrVector((ip1, ip2)) -displayVector(vi) - diff --git a/Examples/test-suite/python/li_std_vector_extra_runme.py b/Examples/test-suite/python/li_std_vector_runme.py similarity index 84% rename from Examples/test-suite/python/li_std_vector_extra_runme.py rename to Examples/test-suite/python/li_std_vector_runme.py index 776eacfb3..a0d96d4aa 100644 --- a/Examples/test-suite/python/li_std_vector_extra_runme.py +++ b/Examples/test-suite/python/li_std_vector_runme.py @@ -1,4 +1,4 @@ -from li_std_vector_extra import * +from li_std_vector import * iv = IntVector(4) for i in range(0,4): @@ -133,24 +133,3 @@ if overloaded3(None) != "vector *": if overloaded3(100) != "int": raise RuntimeError - -# vector pointer checks -ip = makeIntPtr(11) -dp = makeDoublePtr(33.3) -error = 0 -try: - vi = IntPtrVector((ip, dp)) # check vector does not accept double * element - error = 1 -except: - pass - -if error: - raise RuntimeError - -vi = IntPtrVector((ip, makeIntPtr(22))) -if extractInt(vi[0]) != 11: - raise RuntimeError - -if extractInt(vi[1]) != 22: - raise RuntimeError - diff --git a/Examples/test-suite/li_std_vectora.i b/Examples/test-suite/python/li_std_vectora.i similarity index 100% rename from Examples/test-suite/li_std_vectora.i rename to Examples/test-suite/python/li_std_vectora.i diff --git a/Examples/test-suite/li_std_wstream.i b/Examples/test-suite/python/li_std_wstream.i similarity index 100% rename from Examples/test-suite/li_std_wstream.i rename to Examples/test-suite/python/li_std_wstream.i diff --git a/Examples/test-suite/python/li_std_wstring.i b/Examples/test-suite/python/li_std_wstring.i new file mode 100644 index 000000000..c809e11ec --- /dev/null +++ b/Examples/test-suite/python/li_std_wstring.i @@ -0,0 +1,89 @@ +%module li_std_wstring +%include +%include + + +%inline %{ + +struct A : std::wstring +{ + A(const std::wstring& s) : std::wstring(s) + { + } +}; + +struct B +{ + B(const std::wstring& s) : cname(0), name(s), a(s) + { + } + + char *cname; + std::wstring name; + A a; + +}; + + +wchar_t test_wcvalue(wchar_t x) { + return x; +} + +const wchar_t* test_ccvalue(const wchar_t* x) { + return x; +} + +wchar_t* test_cvalue(wchar_t* x) { + return x; +} + + +std::wstring test_value(std::wstring x) { + return x; +} + +const std::wstring& test_const_reference(const std::wstring &x) { + return x; +} + +void test_pointer(std::wstring *x) { +} + +std::wstring *test_pointer_out() { + static std::wstring x = L"x"; + return &x; +} + +void test_const_pointer(const std::wstring *x) { +} + +const std::wstring *test_const_pointer_out() { + static std::wstring x = L"x"; + return &x; +} + +void test_reference(std::wstring &x) { +} + +std::wstring& test_reference_out() { + static std::wstring x = L"x"; + return x; +} + +#if defined(_MSC_VER) + #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) +#endif + +void test_throw() throw(std::wstring){ + static std::wstring x = L"x"; + + throw x; +} + +#if defined(_MSC_VER) + #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) +#endif + +%} + + diff --git a/Examples/test-suite/python_nondynamic.i b/Examples/test-suite/python/nondynamic.i similarity index 96% rename from Examples/test-suite/python_nondynamic.i rename to Examples/test-suite/python/nondynamic.i index 26c69644d..2acc9bf8b 100644 --- a/Examples/test-suite/python_nondynamic.i +++ b/Examples/test-suite/python/nondynamic.i @@ -1,4 +1,4 @@ -%module python_nondynamic +%module nondynamic /* Use the %pythonnondynamic directuve to make the wrapped class a diff --git a/Examples/test-suite/python/python_nondynamic_runme.py b/Examples/test-suite/python/nondynamic_runme.py similarity index 67% rename from Examples/test-suite/python/python_nondynamic_runme.py rename to Examples/test-suite/python/nondynamic_runme.py index 27755db9c..18230616d 100644 --- a/Examples/test-suite/python/python_nondynamic_runme.py +++ b/Examples/test-suite/python/nondynamic_runme.py @@ -1,6 +1,6 @@ -import python_nondynamic +import nondynamic -aa = python_nondynamic.A() +aa = nondynamic.A() aa.a = 1 aa.b = 2 @@ -14,10 +14,10 @@ if not err: raise RuntimeError, "A is not static" -class B(python_nondynamic.A): +class B(nondynamic.A): c = 4 def __init__(self): - python_nondynamic.A.__init__(self) + nondynamic.A.__init__(self) pass pass @@ -35,5 +35,5 @@ if not err: raise RuntimeError, "B is not static" -cc = python_nondynamic.C() +cc = nondynamic.C() cc.d = 3 diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py deleted file mode 100644 index 4218b5dd4..000000000 --- a/Examples/test-suite/python/operbool_runme.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python -import operbool -assert not operbool.Test() - diff --git a/Examples/test-suite/python_overload_simple_cast.i b/Examples/test-suite/python/overload_simple_cast.i similarity index 58% rename from Examples/test-suite/python_overload_simple_cast.i rename to Examples/test-suite/python/overload_simple_cast.i index e7f58d788..d274722c0 100644 --- a/Examples/test-suite/python_overload_simple_cast.i +++ b/Examples/test-suite/python/overload_simple_cast.i @@ -1,4 +1,4 @@ // Simple tests of overloaded functions -%module("castmode") python_overload_simple_cast +%module("castmode") overload_simple_cast %include overload_simple.i diff --git a/Examples/test-suite/python/python_overload_simple_cast_runme.py b/Examples/test-suite/python/overload_simple_cast_runme.py similarity index 98% rename from Examples/test-suite/python/python_overload_simple_cast_runme.py rename to Examples/test-suite/python/overload_simple_cast_runme.py index 1b3a5482c..87e6e5d43 100644 --- a/Examples/test-suite/python/python_overload_simple_cast_runme.py +++ b/Examples/test-suite/python/overload_simple_cast_runme.py @@ -1,4 +1,4 @@ -from python_overload_simple_cast import * +from overload_simple_cast import * class Ai: def __init__(self,x): diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py deleted file mode 100644 index e34777558..000000000 --- a/Examples/test-suite/python/python_abstractbase_runme3.py +++ /dev/null @@ -1,8 +0,0 @@ -from python_abstractbase import * -from collections import * -assert issubclass(Mapii, MutableMapping) -assert issubclass(Multimapii, MutableMapping) -assert issubclass(IntSet, MutableSet) -assert issubclass(IntMultiset, MutableSet) -assert issubclass(IntVector, MutableSequence) -assert issubclass(IntList, MutableSequence) diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py deleted file mode 100644 index c8e6b2640..000000000 --- a/Examples/test-suite/python/python_append_runme.py +++ /dev/null @@ -1,4 +0,0 @@ -from python_append import * -t=Test() -t.func() -t.static_func() diff --git a/Examples/test-suite/python/python_pybuf_runme3.py b/Examples/test-suite/python/python_pybuf_runme3.py deleted file mode 100644 index 152aecdc0..000000000 --- a/Examples/test-suite/python/python_pybuf_runme3.py +++ /dev/null @@ -1,42 +0,0 @@ -#run: -# python python_pybuf_runme3.py benchmark -#for the benchmark, other wise the test case will be run -import python_pybuf -import sys -if len(sys.argv)>=2 and sys.argv[1]=="benchmark": - #run the benchmark - import time - k=1000000 #number of times to excute the functions - - t=time.time() - a = bytearray(b'hello world') - for i in range(k): - pybuf.title1(a) - print("Time used by bytearray:",time.time()-t) - - t=time.time() - b = 'hello world' - for i in range(k): - pybuf.title2(b) - print("Time used by string:",time.time()-t) -else: - #run the test case - buf1 = bytearray(10) - buf2 = bytearray(50) - - pybuf.func1(buf1) - assert buf1 == b'a'*10 - - pybuf.func2(buf2) - assert buf2.startswith(b"Hello world!\x00") - - count = pybuf.func3(buf2) - assert count==10 #number of alpha and number in 'Hello world!' - - length = pybuf.func4(buf2) - assert length==12 - - buf3 = bytearray(b"hello") - pybuf.title1(buf3) - assert buf3==b'Hello' - diff --git a/Examples/test-suite/python/rename_strip_encoder_runme.py b/Examples/test-suite/python/rename_strip_encoder_runme.py deleted file mode 100644 index 64be611d6..000000000 --- a/Examples/test-suite/python/rename_strip_encoder_runme.py +++ /dev/null @@ -1,6 +0,0 @@ -from rename_strip_encoder import * - -s = SomeWidget() -a = AnotherWidget() -a.DoSomething() - diff --git a/Examples/test-suite/simutry.i b/Examples/test-suite/python/simutry.i similarity index 100% rename from Examples/test-suite/simutry.i rename to Examples/test-suite/python/simutry.i diff --git a/Examples/test-suite/python/std_containers.i b/Examples/test-suite/python/std_containers.i new file mode 100644 index 000000000..a1d39e7ab --- /dev/null +++ b/Examples/test-suite/python/std_containers.i @@ -0,0 +1,199 @@ +%module std_containers + +%{ +#include +%} +%include std_vector.i +%include std_string.i +%include std_deque.i +%include std_list.i +%include std_set.i +%include std_multiset.i +%include std_pair.i +%include std_map.i +%include std_multimap.i +%include std_complex.i + +%template() std::vector; +%template() std::pair; +%template() std::pair; + +%template() std::vector< std::vector > ; +%template(ccube) std::vector< std::vector< std::vector > >; + +%inline +{ + typedef + std::vector > > + ccube; + + ccube cident(const ccube& c) + { + return c; + } + + struct C + { + }; +} + + +%template(map_si) std::map; +%template(pair_iC) std::pair; +%template(map_iC) std::map; +%template(mmap_si) std::multimap; +%template(set_i) std::set; +%template(multiset_i) std::multiset; +%template(list_i) std::list; +%template(deque_i) std::deque; + +%template(vector_b) std::vector; +%template(vector_i) std::vector; +%template(vector_c) std::vector >; +%template(vector_ui) std::vector; + +%template(bmatrix) std::vector >; +%template(imatrix) std::vector >; +%template(cmatrix) std::vector > >; + +%apply std::vector *INOUT {std::vector *INOUT2}; + +%inline +{ + typedef std::vector > imatrix; + imatrix midenti(const imatrix& v) + { + return v; + } + + typedef std::vector > bmatrix; + bmatrix midentb(const bmatrix& v) + { + return v; + } + + std::map mapidentc(const std::map& v) + { + return v; + } + + std::map mapidenti(const std::map& v) + { + return v; + } + + std::map mapident(const std::map& v) + { + return v; + } + + std::multimap mapident(const std::multimap& v) + { + return v; + } + + std::vector vident(const std::vector& v) + { + return v; + } + + std::set sident(const std::set& v) + { + return v; + } + + std::vector videntu(const std::vector& v) + { + return v; + } + + + int get_elem(const std::vector& v, int index) + { + return v[index]; + } + + std::pair pident(const std::pair& p) + { + return p; + } + + void + v_inout(std::vector *INOUT) { + *INOUT = *INOUT; + } + + void + v_inout2(std::vector *INOUT, std::vector *INOUT2) { + std::swap(*INOUT, *INOUT2); + } + +} + + +%{ + + template struct Param + { + }; +%} + + +template struct Param +{ +}; + + +%template(Param_c) Param >; +%inline +{ + int hello(Param > c) + { + return 0; + } +} + +%inline +{ + struct A + { + A(int aa = 0) : a(aa) + { + } + int a; + }; +} + +%template() std::pair; +%template(pair_iA) std::pair; +%template(vector_piA) std::vector >; + + +%inline { + std::pair ident(std::pair a, const std::pair& b) + { + return std::pair(); + } + + + std::vector > pia_vident(std::vector > a ) + { + return a; + } + + struct Foo + { + Foo(int i) { + } + }; + +} + + +%std_nodefconst_type(Foo); + +%template(vector_Foo) std::vector; +%template(deque_Foo) std::deque; +%template(list_Foo) std::list; + + diff --git a/Examples/test-suite/swigobject.i b/Examples/test-suite/python/swigobject.i similarity index 81% rename from Examples/test-suite/swigobject.i rename to Examples/test-suite/python/swigobject.i index 2ec064509..2e77969b9 100644 --- a/Examples/test-suite/swigobject.i +++ b/Examples/test-suite/python/swigobject.i @@ -10,7 +10,7 @@ const char* pointer_str(A *a){ static char result[1024]; - sprintf(result,"%p", a); + sprintf(result,"0x%lx", (unsigned long)(void *)a); return result; } diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index a906108e3..7f629e1d5 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -12,17 +12,11 @@ if a1.this != a2.this: lthis = long(a.this) -# match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p -xstr1 = "%016X" % (lthis,) -xstr1 = str.lstrip(xstr1, '0') +xstr1 = "0x%x" % (lthis,) xstr2 = pointer_str(a) -xstr2 = str.replace(xstr2, "0x", "") -xstr2 = str.replace(xstr2, "0X", "") -xstr2 = str.lstrip(xstr2, '0') -xstr2 = str.upper(xstr2) if xstr1 != xstr2: - print xstr1, xstr2 + print xstr1, xstr2 raise RuntimeError s = str(a.this) diff --git a/Examples/test-suite/python/tag_no_clash_with_variable_runme.i b/Examples/test-suite/python/tag_no_clash_with_variable_runme.i new file mode 100644 index 000000000..0f8fdafed --- /dev/null +++ b/Examples/test-suite/python/tag_no_clash_with_variable_runme.i @@ -0,0 +1,3 @@ +import enum_tag_no_clash_with_variable + +error_action = error_action diff --git a/Examples/test-suite/template_matrix.i b/Examples/test-suite/python/template_matrix.i similarity index 100% rename from Examples/test-suite/template_matrix.i rename to Examples/test-suite/python/template_matrix.i diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py index 04c599329..030fe02d8 100644 --- a/Examples/test-suite/python/template_typedef_cplx2_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py @@ -1,3 +1,4 @@ +import string from template_typedef_cplx2 import * # @@ -12,7 +13,7 @@ except: raise RuntimeError s = '%s' % d -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError @@ -24,7 +25,7 @@ except: raise RuntimeError s = '%s' % e -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError @@ -41,7 +42,7 @@ except: raise RuntimeError s = '%s' % c -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError @@ -53,7 +54,7 @@ except: raise RuntimeError s = '%s' % f -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError @@ -69,7 +70,7 @@ except: raise RuntimeError s = '%s' % g -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError @@ -82,7 +83,7 @@ except: raise RuntimeError s = '%s' % h -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print h, "is not an ArithUnaryFunction" raise RuntimeError diff --git a/Examples/test-suite/python/template_typedef_cplx_runme.py b/Examples/test-suite/python/template_typedef_cplx_runme.py index 2cd9c8348..99ffcb9aa 100644 --- a/Examples/test-suite/python/template_typedef_cplx_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx_runme.py @@ -1,3 +1,4 @@ +import string from template_typedef_cplx import * # @@ -12,7 +13,7 @@ except: raise RuntimeError s = '%s' % d -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError @@ -24,7 +25,7 @@ except: raise RuntimeError s = '%s' % e -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError @@ -41,7 +42,7 @@ except: raise RuntimeError s = '%s' % c -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError @@ -53,7 +54,7 @@ except: raise RuntimeError s = '%s' % f -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError @@ -69,7 +70,7 @@ except: raise RuntimeError s = '%s' % g -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError @@ -82,6 +83,6 @@ except: raise RuntimeError s = '%s' % h -if str.find(s, 'ArithUnaryFunction') == -1: +if string.find(s, 'ArithUnaryFunction') == -1: print h, "is not an ArithUnaryFunction" raise RuntimeError diff --git a/Examples/test-suite/python/vector.i b/Examples/test-suite/python/vector.i new file mode 100644 index 000000000..04c961cda --- /dev/null +++ b/Examples/test-suite/python/vector.i @@ -0,0 +1,51 @@ +%module vector +%{ +#include +%} + +%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) + public: + typedef size_t size_type; + typedef CTYPE value_type; + size_type size() const; + vector(); + %extend { + static std::vector *Repeat(const value_type& value, int count) /*throw (std::out_of_range)*/ { +// if (count < 0) +// throw std::out_of_range("count"); + return new std::vector(count, value); + } + } +%enddef + +namespace std { + // primary (unspecialized) class template for std::vector + // does not require operator== to be defined + template class vector { + SWIG_STD_VECTOR_MINIMUM(T, T) + }; +} + +%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) +namespace std { + template<> class vector { + SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE) + }; +} +%enddef + +SWIG_STD_VECTOR_SPECIALIZE(float, float) + +%inline %{ +typedef float Real; +%} + +#if 1 +//fails +namespace std { + %template(RealVector) vector; +} +#else +//works +%template(RealVector) std::vector; +#endif diff --git a/Examples/test-suite/python_abstractbase.i b/Examples/test-suite/python_abstractbase.i deleted file mode 100644 index f72688237..000000000 --- a/Examples/test-suite/python_abstractbase.i +++ /dev/null @@ -1,18 +0,0 @@ -%module python_abstractbase -%include -%include -%include -%include -%include -%include -%include - -namespace std -{ - %template(Mapii) map; - %template(Multimapii) multimap; - %template(IntSet) set; - %template(IntMultiset) multiset; - %template(IntVector) vector; - %template(IntList) list; -} diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i deleted file mode 100644 index 2dc9cb970..000000000 --- a/Examples/test-suite/python_append.i +++ /dev/null @@ -1,32 +0,0 @@ -/* -Testcase to test %pythonprepend and %pythonappend -*/ - -%module python_append - -%pythonappend Test::func %{ - pass -%} - -%pythonprepend Test::func %{ - pass -%} - -%pythonappend Test::static_func %{ -pass -%} - -%pythonprepend Test::static_func { - pass -} - -%inline %{ - -class Test { -public: - static void static_func() {}; - void func() {}; -}; - -%} - diff --git a/Examples/test-suite/python_pybuf.i b/Examples/test-suite/python_pybuf.i deleted file mode 100644 index 8e1302582..000000000 --- a/Examples/test-suite/python_pybuf.i +++ /dev/null @@ -1,64 +0,0 @@ -%module python_pybuf -%include -%include -/*functions for the test case*/ -%pybuffer_mutable_binary(char *buf1, int len); -%pybuffer_mutable_string(char *buf2); -%pybuffer_binary(const char *buf3, int len); -%pybuffer_string(const char *buf4); - -%inline %{ - void func1(char *buf1, int len) - { - int i; - for (i=0; i %include diff --git a/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb b/Examples/test-suite/ruby/li_std_speed_runme.rb similarity index 97% rename from Examples/test-suite/ruby/ruby_li_std_speed_runme.rb rename to Examples/test-suite/ruby/li_std_speed_runme.rb index 825f3c593..a67e618a3 100755 --- a/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb +++ b/Examples/test-suite/ruby/li_std_speed_runme.rb @@ -10,8 +10,8 @@ require 'benchmark' require 'mathn' -require 'ruby_li_std_speed' -include Ruby_li_std_speed +require 'li_std_speed' +include Li_std_speed def benchmark(f, phigh, sequences) diff --git a/Examples/test-suite/li_std_stack.i b/Examples/test-suite/ruby/li_std_stack.i similarity index 100% rename from Examples/test-suite/li_std_stack.i rename to Examples/test-suite/ruby/li_std_stack.i diff --git a/Examples/test-suite/ruby_naming.i b/Examples/test-suite/ruby/naming.i similarity index 98% rename from Examples/test-suite/ruby_naming.i rename to Examples/test-suite/ruby/naming.i index d8ef50ad3..75500ae34 100644 --- a/Examples/test-suite/ruby_naming.i +++ b/Examples/test-suite/ruby/naming.i @@ -1,4 +1,4 @@ -%module ruby_naming +%module naming %predicate predicateMethod(); %bang bangMethod(); diff --git a/Examples/test-suite/ruby/ruby_naming_runme.rb b/Examples/test-suite/ruby/naming_runme.rb similarity index 68% rename from Examples/test-suite/ruby/ruby_naming_runme.rb rename to Examples/test-suite/ruby/naming_runme.rb index 8ea5f13d3..dab3a50b6 100644 --- a/Examples/test-suite/ruby/ruby_naming_runme.rb +++ b/Examples/test-suite/ruby/naming_runme.rb @@ -9,86 +9,86 @@ require 'swig_assert' -require 'ruby_naming' +require 'naming' # Check class names -if not Ruby_naming - raise RuntimeError, 'Invalid module name for Ruby_naming' +if not Naming + raise RuntimeError, 'Invalid module name for Naming' end -if not Ruby_naming::MyClass +if not Naming::MyClass raise RuntimeError, 'Invalid class name for MyClass' end # Check constant names / values -if Ruby_naming::CONSTANT1 != 1 +if Naming::CONSTANT1 != 1 raise RuntimeError, "Incorrect value for CONSTANT1" end -if Ruby_naming::CONSTANT2 != 2 +if Naming::CONSTANT2 != 2 raise RuntimeError, "Incorrect value for CONSTANT2" end # Check constant names / values -if Ruby_naming::CONSTANT3 != 3 +if Naming::CONSTANT3 != 3 raise RuntimeError, "Incorrect value for CONSTANT3" end -if not Ruby_naming::methods.include?("constant4") +if not Naming::methods.include?("constant4") raise RuntimeError, "Incorrect mapping for constant4" end -if not Ruby_naming::methods.include?("constant5") +if not Naming::methods.include?("constant5") raise RuntimeError, "Incorrect mapping for constant5" end -if not Ruby_naming::methods.include?("constant6") +if not Naming::methods.include?("constant6") raise RuntimeError, "Incorrect mapping for constant6" end -if not Ruby_naming::TestConstants.instance_methods.include?("constant7") +if not Naming::TestConstants.instance_methods.include?("constant7") raise RuntimeError, "Incorrect mapping for constant7" end -if not Ruby_naming::TestConstants.methods.include?("constant8") +if not Naming::TestConstants.methods.include?("constant8") raise RuntimeError, "Incorrect mapping for constant8" end # There is no constant9 because it is illegal C++ -#if not Ruby_naming::TestConstants.instance_methods.include?("constant9") +#if not Naming::TestConstants.instance_methods.include?("constant9") # raise RuntimeError, "Incorrect mapping for constant9" #end -if Ruby_naming::TestConstants::CONSTANT10 != 10 +if Naming::TestConstants::CONSTANT10 != 10 raise RuntimeError, "Incorrect value for CONSTANT10" end -if not Ruby_naming::methods.include?("constant11") +if not Naming::methods.include?("constant11") raise RuntimeError, "Incorrect mapping for constant11" end # Check enums -if Ruby_naming::constants.include?("Color") +if Naming::constants.include?("Color") raise RuntimeError, "Color enum should not be exposed to Ruby" end -if Ruby_naming::Red != 0 +if Naming::Red != 0 raise RuntimeError, "Incorrect value for enum RED" end -if Ruby_naming::Green != 1 +if Naming::Green != 1 raise RuntimeError, "Incorrect value for enum GREEN" end -if Ruby_naming::Blue != 2 +if Naming::Blue != 2 raise RuntimeError, "Incorrect value for enum BLUE" end # Check method names -my_class = Ruby_naming::MyClass.new() +my_class = Naming::MyClass.new() if my_class.method_one != 1 raise RuntimeError, "Incorrect value for method_one" diff --git a/Examples/test-suite/stl_new.i b/Examples/test-suite/ruby/stl_new.i similarity index 100% rename from Examples/test-suite/stl_new.i rename to Examples/test-suite/ruby/stl_new.i diff --git a/Examples/test-suite/ruby_track_objects.i b/Examples/test-suite/ruby/track_objects.i similarity index 98% rename from Examples/test-suite/ruby_track_objects.i rename to Examples/test-suite/ruby/track_objects.i index f4bbb37e7..0a50e1fad 100644 --- a/Examples/test-suite/ruby_track_objects.i +++ b/Examples/test-suite/ruby/track_objects.i @@ -1,4 +1,4 @@ -%module ruby_track_objects +%module track_objects %include typemaps.i diff --git a/Examples/test-suite/ruby_track_objects_directors.i b/Examples/test-suite/ruby/track_objects_directors.i similarity index 88% rename from Examples/test-suite/ruby_track_objects_directors.i rename to Examples/test-suite/ruby/track_objects_directors.i index 131209828..adac8ae4d 100644 --- a/Examples/test-suite/ruby_track_objects_directors.i +++ b/Examples/test-suite/ruby/track_objects_directors.i @@ -1,4 +1,4 @@ -%module(directors="1") ruby_track_objects_directors +%module(directors="1") track_objects_directors %{ #include diff --git a/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb b/Examples/test-suite/ruby/track_objects_directors_runme.rb similarity index 74% rename from Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb rename to Examples/test-suite/ruby/track_objects_directors_runme.rb index fb55323a8..247d3e98b 100644 --- a/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb +++ b/Examples/test-suite/ruby/track_objects_directors_runme.rb @@ -9,9 +9,9 @@ require 'swig_assert' -require 'ruby_track_objects_directors' +require 'track_objects_directors' -class MyFoo < Ruby_track_objects_directors::Foo +class MyFoo < Track_objects_directors::Foo def ping "MyFoo::ping()" end @@ -22,12 +22,12 @@ a = MyFoo.new raise RuntimeError if a.ping != "MyFoo::ping()" raise RuntimeError if a.pong != "Foo::pong();MyFoo::ping()" -b = Ruby_track_objects_directors::Foo.new +b = Track_objects_directors::Foo.new raise RuntimeError if b.ping != "Foo::ping()" raise RuntimeError if b.pong != "Foo::pong();Foo::ping()" -container = Ruby_track_objects_directors::Container.new +container = Track_objects_directors::Container.new foo = MyFoo.new container.set_foo(foo) diff --git a/Examples/test-suite/ruby/ruby_track_objects_runme.rb b/Examples/test-suite/ruby/track_objects_runme.rb similarity index 78% rename from Examples/test-suite/ruby/ruby_track_objects_runme.rb rename to Examples/test-suite/ruby/track_objects_runme.rb index 7bc67a478..27d8f6da7 100644 --- a/Examples/test-suite/ruby/ruby_track_objects_runme.rb +++ b/Examples/test-suite/ruby/track_objects_runme.rb @@ -9,7 +9,7 @@ require 'swig_assert' -require 'ruby_track_objects' +require 'track_objects' def test_same_ruby_object(foo1, foo2) if not foo1.equal?(foo2) @@ -23,12 +23,12 @@ def test_same_cpp_object(foo1, foo2) end end -bar = Ruby_track_objects::Bar.new -foo1 = Ruby_track_objects::Foo.new() +bar = Track_objects::Bar.new +foo1 = Track_objects::Foo.new() bar.set_unowned_foo(foo1) # test_simple_identity -foo2 = Ruby_track_objects::Foo.new() +foo2 = Track_objects::Foo.new() foo3 = foo2 test_same_ruby_object(foo2, foo3) @@ -48,8 +48,8 @@ test_same_ruby_object(foo5, foo6) test_same_cpp_object(foo5, foo6) # test_new_foo_identity -foo7 = Ruby_track_objects::Bar.get_new_foo() -foo8 = Ruby_track_objects::Bar.get_new_foo() +foo7 = Track_objects::Bar.get_new_foo() +foo8 = Track_objects::Bar.get_new_foo() if foo7.equal?(foo8) raise "Ruby objects should be different." @@ -60,7 +60,7 @@ if foo7.cpp_equal(foo8) end # test_set_owned_identity -foo9 = Ruby_track_objects::Foo.new +foo9 = Track_objects::Foo.new bar.set_owned_foo(foo9) foo10 = bar.get_owned_foo() @@ -69,7 +69,7 @@ test_same_cpp_object(foo9, foo10) # test_set_owned_identity2 begin - foo11 = Ruby_track_objects::Foo.new + foo11 = Track_objects::Foo.new bar.set_owned_foo(foo11) foo11 = nil end @@ -90,20 +90,20 @@ test_same_ruby_object(foo13, foo14) test_same_cpp_object(foo13, foo14) # Now create the factory -factory = Ruby_track_objects::Factory.new +factory = Track_objects::Factory.new # Create itemA which is really an itemB itemA = factory.createItem # Check class -if itemA.class != Ruby_track_objects::ItemA +if itemA.class != Track_objects::ItemA raise RuntimeError, 'Item should have an ItemA class' end # Now downcast -itemB = Ruby_track_objects.downcast(itemA) +itemB = Track_objects.downcast(itemA) -if itemB.class != Ruby_track_objects::ItemB +if itemB.class != Track_objects::ItemB raise RuntimeError, 'Item should have an ItemB class' end diff --git a/Examples/test-suite/swig_examples_lock.h b/Examples/test-suite/swig_examples_lock.h index feef26d0f..7710f9361 100644 --- a/Examples/test-suite/swig_examples_lock.h +++ b/Examples/test-suite/swig_examples_lock.h @@ -1,10 +1,10 @@ +namespace SwigExamples { + # if defined(_WIN32) || defined(__WIN32__) #include -namespace SwigExamples { - class CriticalSection { public: CriticalSection() { @@ -27,18 +27,9 @@ private: CriticalSection &critical_section; }; -} - #else #include -#ifndef PTHREAD_MUTEX_RECURSIVE_NP - // For Cygwin and possibly other OSs: _NP is "non-portable" - #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE -#endif - -namespace SwigExamples { - class CriticalSection { public: CriticalSection() { @@ -64,7 +55,7 @@ private: CriticalSection &critical_section; }; -} - #endif +} + diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in index 7c4b7ed61..e26d77582 100644 --- a/Examples/test-suite/tcl/Makefile.in +++ b/Examples/test-suite/tcl/Makefile.in @@ -11,12 +11,15 @@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ primitive_types \ + li_cdata \ li_cstring \ li_cwstring C_TEST_CASES += \ + li_cdata \ li_cstring \ - li_cwstring + li_cwstring \ + union include $(srcdir)/../common.mk diff --git a/Examples/test-suite/union_parameter.i b/Examples/test-suite/tcl/union.i similarity index 97% rename from Examples/test-suite/union_parameter.i rename to Examples/test-suite/tcl/union.i index bb010d3fa..d8ac62bfb 100644 --- a/Examples/test-suite/union_parameter.i +++ b/Examples/test-suite/tcl/union.i @@ -1,4 +1,4 @@ -%module union_parameter +%module unions %inline %{ diff --git a/Examples/test-suite/tcl/union_parameter_runme.tcl b/Examples/test-suite/tcl/union_runme.tcl old mode 100644 new mode 100755 similarity index 92% rename from Examples/test-suite/tcl/union_parameter_runme.tcl rename to Examples/test-suite/tcl/union_runme.tcl index fb3e092b8..2c47ecef3 --- a/Examples/test-suite/tcl/union_parameter_runme.tcl +++ b/Examples/test-suite/tcl/union_runme.tcl @@ -1,4 +1,4 @@ -if [ catch { load ./union_parameter[info sharedlibextension] union_parameter} err_msg ] { +if [ catch { load ./union[info sharedlibextension] unions} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } diff --git a/Examples/test-suite/template_inherit_abstract.i b/Examples/test-suite/template_inherit_abstract.i index 2f83433a5..f676b3b3e 100644 --- a/Examples/test-suite/template_inherit_abstract.i +++ b/Examples/test-suite/template_inherit_abstract.i @@ -4,7 +4,7 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, Java, PHP multiple inheritance */ + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) oss::Module; /* C#, Java, Php4 multiple inheritance */ %inline %{ @@ -56,7 +56,7 @@ namespace oss %inline %{ namespace oss { -#if defined(SWIG) && defined(SWIGCSHARP) +#ifdef SWIGCSHARP %ignore HModule::get(); // Work around for lack of multiple inheritance support - base ModuleBase is ignored. #endif struct test : HModule diff --git a/Examples/test-suite/template_typedef_funcptr.i b/Examples/test-suite/template_typedef_funcptr.i index cec43e7c8..0175c7516 100644 --- a/Examples/test-suite/template_typedef_funcptr.i +++ b/Examples/test-suite/template_typedef_funcptr.i @@ -2,10 +2,6 @@ //Bug #1832613 -#if !defined(SWIGR) -// R Swig fails on this test. Because it tries to return a nil SEXP in -// an error - %include %inline %{ @@ -50,4 +46,3 @@ typedef MCContractPtr* ContractPtrPtr; // Plain pointers were also causing problems... %template(MCContractFactory2) ContractFactory; -#endif diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i index b3fa1a733..5375c43b6 100644 --- a/Examples/test-suite/typemap_namespace.i +++ b/Examples/test-suite/typemap_namespace.i @@ -27,7 +27,7 @@ namespace Foo { %typemap(javaout) Str1 * = char *; #endif %typemap(in) Str1 * = char *; -#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML)) +#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP)) %typemap(freearg) Str1 * = char *; #endif %typemap(typecheck) Str1 * = char *; diff --git a/Examples/test-suite/types_directive.i b/Examples/test-suite/types_directive.i index 26cb6aeeb..44312263d 100644 --- a/Examples/test-suite/types_directive.i +++ b/Examples/test-suite/types_directive.i @@ -1,13 +1,5 @@ %module types_directive -#if defined(SWIGR) -// Avoid conflict with Date class in R -#define Date DateSwig -%inline %{ -#define Date DateSwig -%} -#endif - %ignore Time2::operator Date *; %inline %{ diff --git a/Examples/test-suite/using_composition.i b/Examples/test-suite/using_composition.i index bd0f712b5..7bb6add2a 100644 --- a/Examples/test-suite/using_composition.i +++ b/Examples/test-suite/using_composition.i @@ -2,13 +2,13 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar; // C#, Java, Php4 multiple inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar2; // C#, Java, PHP multiple inheritance + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar2; // C#, Java, Php4 multiple inheritance %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar3; // C#, Java, PHP multiple inheritance + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar3; // C#, Java, Php4 multiple inheritance #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah; #endif diff --git a/Examples/test-suite/using_extend.i b/Examples/test-suite/using_extend.i index e14cc28e8..414ceedb4 100644 --- a/Examples/test-suite/using_extend.i +++ b/Examples/test-suite/using_extend.i @@ -2,7 +2,7 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) FooBar; // C#, Java, Php4 multiple inheritance #ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings %warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah; #endif diff --git a/Examples/test-suite/using_namespace.i b/Examples/test-suite/using_namespace.i index 799c7cfb5..1989b6a0d 100644 --- a/Examples/test-suite/using_namespace.i +++ b/Examples/test-suite/using_namespace.i @@ -5,7 +5,7 @@ %warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE, SWIGWARN_CSHARP_MULTIPLE_INHERITANCE, - SWIGWARN_PHP_MULTIPLE_INHERITANCE) Hi; // C#, Java, PHP multiple inheritance + SWIGWARN_PHP4_MULTIPLE_INHERITANCE) Hi; // C#, Java, Php4 multiple inheritance %inline %{ namespace hello diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg index 4479f6ac2..0ae8ed76c 100644 --- a/Lib/allegrocl/allegrocl.swg +++ b/Lib/allegrocl/allegrocl.swg @@ -26,76 +26,37 @@ %typemap(lout) SWIGTYPE "(cl::let* ((address $body)\n (new-inst (cl::make-instance '$lclass :foreign-address address)))\n (cl::unless (cl::zerop address)\n (excl:schedule-finalization new-inst #'$ldestructor))\n (cl::setq ACL_ffresult new-inst))"; -%typemap(lisptype) bool, const bool "cl:boolean"; -%typemap(lisptype) char, const char "cl:character"; -%typemap(lisptype) unsigned char, const unsigned char "cl:integer"; -%typemap(lisptype) signed char, const signed char "cl:integer"; +%typemap(lisptype) bool "cl:boolean"; +%typemap(lisptype) char "cl:character"; +%typemap(lisptype) unsigned char "cl:integer"; +%typemap(lisptype) signed char "cl:integer"; -%typemap(ffitype) bool, const bool ":int"; -%typemap(ffitype) char, const char, - signed char, const signed char ":char"; -%typemap(ffitype) unsigned char, const unsigned char ":unsigned-char"; -%typemap(ffitype) short, const short, - signed short, const signed short ":short"; -%typemap(ffitype) unsigned short, const unsigned short ":unsigned-short"; -%typemap(ffitype) int, const int, signed int, const signed int ":int"; -%typemap(ffitype) unsigned int, const unsigned int ":unsigned-int"; -%typemap(ffitype) long, const long, signed long, const signed long ":long"; -%typemap(ffitype) unsigned long, const unsigned long ":unsigned-long"; -%typemap(ffitype) float, const float ":float"; -%typemap(ffitype) double, const double ":double"; -%typemap(ffitype) char *, const char *, signed char *, - const signed char *, signed char &, - const signed char & "(* :char)"; -%typemap(ffitype) unsigned char *, const unsigned char *, - unsigned char &, const unsigned char & "(* :unsigned-char)"; -%typemap(ffitype) short *, const short *, short &, - const short & "(* :short)"; -%typemap(ffitype) unsigned short *, const unsigned short *, - unsigned short &, const unsigned short & "(* :unsigned-short)"; -%typemap(ffitype) int *, const int *, int &, const int & "(* :int)"; -%typemap(ffitype) unsigned int *, const unsigned int *, - unsigned int &, const unsigned int & "(* :unsigned-int)"; +%typemap(ffitype) bool ":int"; +%typemap(ffitype) char ":char"; +%typemap(ffitype) unsigned char ":unsigned-char"; +%typemap(ffitype) signed char ":char"; +%typemap(ffitype) short, signed short ":short"; +%typemap(ffitype) unsigned short ":unsigned-short"; +%typemap(ffitype) int, signed int ":int"; +%typemap(ffitype) unsigned int ":unsigned-int"; +%typemap(ffitype) long, signed long ":long"; +%typemap(ffitype) unsigned long ":unsigned-long"; +%typemap(ffitype) float ":float"; +%typemap(ffitype) double ":double"; +%typemap(ffitype) char * "(* :char)"; %typemap(ffitype) void * "(* :void)"; %typemap(ffitype) void ":void"; %typemap(ffitype) enum SWIGTYPE ":int"; %typemap(ffitype) SWIGTYPE & "(* :void)"; -/* const typemaps -idea: marshall all primitive c types to their respective lisp types -to maintain const corretness. For pointers/references, all bets -are off if you try to modify them. - -idea: add a constant-p slot to the base foreign-pointer class. For -constant pointer/references check this value when setting (around method?) -and error if a setf operation is performed on the address of this object. - -*/ - -/* -%exception %{ - try { - $action - } catch (...) { - return $null; - } -%} - -*/ - -// %typemap(throws) SWIGTYPE { -// (void)$1; -// SWIG_fail; -// } - -%typemap(ctype) bool, const bool "int"; +%typemap(ctype) bool "int"; %typemap(ctype) char, unsigned char, signed char, short, signed short, unsigned short, int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, - enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[], - SWIGTYPE[ANY], SWIGTYPE &, const SWIGTYPE "$1_ltype"; + enum SWIGTYPE, SWIGTYPE *, + SWIGTYPE[ANY], SWIGTYPE & "$1_ltype"; %typemap(ctype) SWIGTYPE "$&1_type"; %typemap(in) bool "$1 = (bool)$input;"; @@ -104,7 +65,7 @@ and error if a setf operation is performed on the address of this object. int, signed int, unsigned int, long, signed long, unsigned long, float, double, long double, char *, void *, void, - enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[], + enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE & "$1 = $input;"; %typemap(in) SWIGTYPE "$1 = *$input;"; @@ -161,8 +122,7 @@ SWIG_TYPECHECK_STRING_ARRAY 1140 long, signed long, unsigned long, enum SWIGTYPE { $1 = 1; }; %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, - SWIGTYPE[], SWIGTYPE[ANY], - SWIGTYPE { $1 = 1; }; + SWIGTYPE[ANY], SWIGTYPE { $1 = 1; }; /* This maps C/C++ types to Lisp classes for overload dispatch */ @@ -187,7 +147,7 @@ SWIG_TYPECHECK_STRING_ARRAY 1140 enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[ANY], SWIGTYPE & "$result = $1;"; #ifdef __cplusplus -%typemap(out) SWIGTYPE "$result = new $1_ltype($1);"; +%typemap(out) SWIGTYPE "$result = new $1_type($1);"; #else %typemap(out) SWIGTYPE { $result = ($&1_ltype) malloc(sizeof($1_type)); @@ -283,15 +243,12 @@ $body)" %rename(__funcall__) *::operator(); %rename(__aref__) *::operator[]; - -%rename(__bool__) *::operator bool(); -%rename(__bool__) *::operator bool() const; #endif %insert("lisphead") %{ ;; $Id$ -(eval-when (:compile-toplevel :load-toplevel :execute) +(eval-when (compile load eval) ;; avoid compiling ef-templates at runtime (excl:find-external-format :fat) @@ -339,30 +296,15 @@ $body)" sym)))) (cl::defun full-name (id type arity class) - ; We need some kind of a hack here to handle template classes - ; and other synonym types right. We need the original name. - (let*( (sym (read-symbol-from-string - (if (eq *swig-identifier-converter* 'identifier-convert-lispify) - (string-lispify id) - id))) - (sym-class (find-class sym nil)) - (id (cond ( (not sym-class) - id ) - ( (and sym-class - (not (eq (class-name sym-class) - sym))) - (class-name sym-class) ) - ( t - id ))) ) - (cl::case type - (:getter (cl::format nil "~@[~A_~]~A" class id)) - (:constructor (cl::format nil "new_~A~@[~A~]" id arity)) - (:destructor (cl::format nil "delete_~A" id)) - (:type (cl::format nil "ff_~A" id)) - (:slot id) - (:ff-operator (cl::format nil "ffi_~A" id)) - (otherwise (cl::format nil "~@[~A_~]~A~@[~A~]" - class id arity))))) + (cl::case type + (:getter (cl::format nil "~@[~A_~]~A" class id)) + (:constructor (cl::format nil "new_~A~@[~A~]" id arity)) + (:destructor (cl::format nil "delete_~A" id)) + (:type (cl::format nil "ff_~A" id)) + (:slot id) + (:ff-operator (cl::format nil "ffi_~A" id)) + (otherwise (cl::format nil "~@[~A_~]~A~@[~A~]" + class id arity)))) (cl::defun identifier-convert-null (id &key type class arity) (cl::if (cl::eq type :setter) @@ -370,27 +312,6 @@ $body)" id :type :getter :class class :arity arity)) (read-symbol-from-string (full-name id type arity class)))) -(cl::defun string-lispify (str) - (cl::let ( (cname (excl::replace-regexp str "_" "-")) - (lastcase :other) - newcase char res ) - (cl::dotimes (n (cl::length cname)) - (cl::setf char (cl::schar cname n)) - (excl::if* (cl::alpha-char-p char) - then - (cl::setf newcase (cl::if (cl::upper-case-p char) :upper :lower)) - (cl::when (cl::and (cl::eq lastcase :lower) - (cl::eq newcase :upper)) - ;; case change... add a dash - (cl::push #\- res) - (cl::setf newcase :other)) - (cl::push (cl::char-downcase char) res) - (cl::setf lastcase newcase) - else - (cl::push char res) - (cl::setf lastcase :other))) - (cl::coerce (cl::nreverse res) 'string))) - (cl::defun identifier-convert-lispify (cname &key type class arity) (cl::assert (cl::stringp cname)) (cl::when (cl::eq type :setter) @@ -400,7 +321,31 @@ $body)" (cl::setq cname (full-name cname type arity class)) (cl::if (cl::eq type :constant) (cl::setf cname (cl::format nil "*~A*" cname))) - (read-symbol-from-string (string-lispify cname))) + (cl::setf cname (excl::replace-regexp cname "_" "-")) + (cl::let ((lastcase :other) + newcase char res) + (cl::dotimes (n (cl::length cname)) + (cl::setf char (cl::schar cname n)) + (excl::if* (cl::alpha-char-p char) + then + (cl::setf newcase (cl::if (cl::upper-case-p char) :upper :lower)) + + (cl::when (cl::or (cl::and (cl::eq lastcase :upper) + (cl::eq newcase :lower)) + (cl::and (cl::eq lastcase :lower) + (cl::eq newcase :upper))) + ;; case change... add a dash + (cl::push #\- res) + (cl::setf newcase :other)) + + (cl::push (cl::char-downcase char) res) + + (cl::setf lastcase newcase) + + else + (cl::push char res) + (cl::setf lastcase :other))) + (read-symbol-from-string (cl::coerce (cl::nreverse res) 'string)))) (cl::defun id-convert-and-export (name &rest kwargs) (cl::multiple-value-bind (symbol package) @@ -418,7 +363,7 @@ $body)" (defswig2 swig-defconstant (string value) (cl::let ((symbol (id-convert-and-export string :type :constant))) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (cl::defconstant ,symbol ,value)))) (cl::defun maybe-reorder-args (funcname arglist) @@ -464,7 +409,7 @@ $body)" ) (cl::when (swig-anyvarargs-p ffargs) (cl::setq ffargs '())) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (excl::compiler-let ((*record-xref-info* nil)) (ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs)) (cl::macrolet ((swig-ff-call (&rest args) @@ -490,7 +435,7 @@ $body)" ffargs (cl::loop for (nil name nil . ffi) in ffargs collect `(,name ,@ffi))))) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (excl::compiler-let ((*record-xref-info* nil)) (ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs)) (cl::macrolet ((swig-ff-call (&rest args) @@ -502,7 +447,7 @@ $body)" (defswig1 swig-dispatcher ((name &key (type :operator) class arities)) (cl::let ((symbol (id-convert-and-export name :type type :class class))) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (cl::defun ,symbol (&rest args) (cl::case (cl::length args) ,@(cl::loop for arity in arities @@ -515,14 +460,14 @@ $body)" (defswig2 swig-def-foreign-stub (name) (cl::let ((lsymbol (id-convert-and-export name :type :class)) (symbol (id-convert-and-export name :type :type))) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (ff:def-foreign-type ,symbol (:class )) (cl::defclass ,lsymbol (ff:foreign-pointer) ())))) (defswig2 swig-def-foreign-class (name supers &rest rest) (cl::let ((lsymbol (id-convert-and-export name :type :class)) (symbol (id-convert-and-export name :type :type))) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (ff:def-foreign-type ,symbol ,@rest) (cl::defclass ,lsymbol ,supers ((foreign-type :initform ',symbol :initarg :foreign-type @@ -530,11 +475,11 @@ $body)" (defswig2 swig-def-foreign-type (name &rest rest) (cl::let ((symbol (id-convert-and-export name :type :type))) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (ff:def-foreign-type ,symbol ,@rest)))) (defswig2 swig-def-synonym-type (synonym of ff-synonym) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (cl::setf (cl::find-class ',synonym) (cl::find-class ',of)) (ff:def-foreign-type ,ff-synonym (:struct )))) @@ -554,24 +499,24 @@ $body)" (parent-strings (cl::mapcar #'package-name-for-namespace parent-namespaces)) (string (package-name-for-namespace namespace))) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (cl::defpackage ,string (:use :swig :ff #+ignore '(:common-lisp :ff :excl) ,@parent-strings ,*swig-module-name*) (:import-from :cl :* :nil :t))))) (cl::defmacro swig-in-package (namespace) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (cl::in-package ,(package-name-for-namespace namespace)))) (defswig2 swig-defvar (name mangled-name &key type (ftype :unsigned-natural)) (cl::let ((symbol (id-convert-and-export name :type type))) - `(cl::eval-when (:compile-toplevel :load-toplevel :execute) + `(cl::eval-when (compile load eval) (ff:def-foreign-variable (,symbol ,mangled-name) :type ,ftype)))) ) ;; eval-when -(cl::eval-when (:compile-toplevel :execute) +(cl::eval-when (compile eval) (cl::flet ((starts-with-p (str prefix) (cl::and (cl::>= (cl::length str) (cl::length prefix)) (cl::string= str prefix :end1 (cl::length prefix))))) @@ -582,7 +527,7 @@ $body)" %} -typedef void *__SWIGACL_FwdReference; + %{ @@ -594,8 +539,6 @@ typedef void *__SWIGACL_FwdReference; #define EXPORT EXTERN SWIGEXPORT -typedef void *__SWIGACL_FwdReference; - #include #include %} diff --git a/Lib/allegrocl/inout_typemaps.i b/Lib/allegrocl/inout_typemaps.i old mode 100644 new mode 100755 diff --git a/Lib/allegrocl/longlongs.i b/Lib/allegrocl/longlongs.i old mode 100644 new mode 100755 diff --git a/Lib/allegrocl/std_list.i b/Lib/allegrocl/std_list.i old mode 100644 new mode 100755 diff --git a/Lib/allegrocl/std_string.i b/Lib/allegrocl/std_string.i old mode 100644 new mode 100755 diff --git a/Lib/allkw.swg b/Lib/allkw.swg index 2a2fe18d8..dec6c7c03 100644 --- a/Lib/allkw.swg +++ b/Lib/allkw.swg @@ -19,7 +19,7 @@ %include %include %include -%include +%include %include %include %include diff --git a/Lib/cdata.i b/Lib/cdata.i index 67601f737..a9e74ed8a 100644 --- a/Lib/cdata.i +++ b/Lib/cdata.i @@ -29,11 +29,6 @@ typedef struct SWIGCDATA { $result = C_string(&string_space, $1.len, $1.data); } %typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); -#elif SWIGPHP -%typemap(out) SWIGCDATA { - ZVAL_STRINGL($result, $1.data, $1.len, 1); -} -%typemap(in) (const void *indata, int inlen) = (char *STRING, int LENGTH); #else %echo "cdata.i module not supported." #endif @@ -81,3 +76,7 @@ SWIGCDATA cdata_##NAME(TYPE *ptr, int nelements); /* Memory move function */ void memmove(void *data, const void *indata, int inlen); + + + + diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg index a8d1b5a57..d8b71874e 100644 --- a/Lib/chicken/chicken.swg +++ b/Lib/chicken/chicken.swg @@ -10,7 +10,6 @@ /* chicken.h has to appear first. */ %insert(runtime) %{ -#include #include %} diff --git a/Lib/chicken/chickenrun.swg b/Lib/chicken/chickenrun.swg index 8703ea65a..bd7242407 100644 --- a/Lib/chicken/chickenrun.swg +++ b/Lib/chicken/chickenrun.swg @@ -7,7 +7,6 @@ * ----------------------------------------------------------------------------- */ #include -#include #include #include #include diff --git a/Lib/csharp/arrays_csharp.i b/Lib/csharp/arrays_csharp.i deleted file mode 100644 index ea22da584..000000000 --- a/Lib/csharp/arrays_csharp.i +++ /dev/null @@ -1,140 +0,0 @@ -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * arrays_csharp.i - * - * This file contains a two approaches to marshaling arrays. The first uses - * default p/invoke marshaling and the second uses pinning of the arrays. - * - * Default marshaling approach - * ---------------------------- - * Array typemaps using default p/invoke marshaling. The data is copied to a separately - * allocated buffer when passing over the managed-native boundary. - * - * There are separate typemaps for in, out and inout arrays to enable avoiding - * unnecessary copying. - * - * Example usage: - * - * %include "arrays_csharp.i" - * %apply int INPUT[] { int* sourceArray } - * %apply int OUTPUT[] { int* targetArray } - * void myArrayCopy( int* sourceArray, int* targetArray, int nitems ); - * - * %apply int INOUT[] { int* array1, int *array2 } - * void myArraySwap( int* array1, int* array2, int nitems ); - * - * If handling large arrays you should consider using the pinning array typemaps - * described next. - * - * Pinning approach - * ---------------- - * Array typemaps using pinning. These typemaps pin the managed array given - * as parameter and pass a pointer to it to the c/c++ side. This is very - * efficient as no copying is done (unlike in the default array marshaling), - * but it makes garbage collection more difficult. When considering using - * these typemaps, think carefully whether you have callbacks that may cause - * the control to re-enter the managed side from within the call (and produce - * garbage for the gc) or whether other threads may produce enough garbage to - * trigger gc while the call is being executed. In those cases it may be - * wiser to use the default marshaling typemaps. - * - * Please note that when using fixed arrays, you have to mark your corresponding - * module class method unsafe using - * %csmethodmodifiers "public unsafe" - * (the visibility of the method is up to you). - * - * Example usage: - * - * %include "arrays_csharp.i" - * %apply int FIXED[] { int* sourceArray, int *targetArray } - * %csmethodmodifiers myArrayCopy "public unsafe"; - * void myArrayCopy( int *sourceArray, int* targetArray, int nitems ); - * - * ----------------------------------------------------------------------------- */ - -%define CSHARP_ARRAYS( CTYPE, CSTYPE ) - -// input only arrays - -%typemap(ctype) CTYPE INPUT[] "CTYPE*" -%typemap(cstype) CTYPE INPUT[] "CSTYPE[]" -%typemap(imtype, inattributes="[In, MarshalAs(UnmanagedType.LPArray)]") CTYPE INPUT[] "CSTYPE[]" -%typemap(csin) CTYPE INPUT[] "$csinput" - -%typemap(in) CTYPE INPUT[] "$1 = $input;" -%typemap(freearg) CTYPE INPUT[] "" -%typemap(argout) CTYPE INPUT[] "" - -// output only arrays - -%typemap(ctype) CTYPE OUTPUT[] "CTYPE*" -%typemap(cstype) CTYPE OUTPUT[] "CSTYPE[]" -%typemap(imtype, inattributes="[Out, MarshalAs(UnmanagedType.LPArray)]") CTYPE OUTPUT[] "CSTYPE[]" -%typemap(csin) CTYPE OUTPUT[] "$csinput" - -%typemap(in) CTYPE OUTPUT[] "$1 = $input;" -%typemap(freearg) CTYPE OUTPUT[] "" -%typemap(argout) CTYPE OUTPUT[] "" - -// inout arrays - -%typemap(ctype) CTYPE INOUT[] "CTYPE*" -%typemap(cstype) CTYPE INOUT[] "CSTYPE[]" -%typemap(imtype, inattributes="[In, Out, MarshalAs(UnmanagedType.LPArray)]") CTYPE INOUT[] "CSTYPE[]" -%typemap(csin) CTYPE INOUT[] "$csinput" - -%typemap(in) CTYPE INOUT[] "$1 = $input;" -%typemap(freearg) CTYPE INOUT[] "" -%typemap(argout) CTYPE INOUT[] "" - -%enddef // CSHARP_ARRAYS - -CSHARP_ARRAYS(signed char, sbyte) -CSHARP_ARRAYS(unsigned char, byte) -CSHARP_ARRAYS(short, short) -CSHARP_ARRAYS(unsigned short, ushort) -CSHARP_ARRAYS(int, int) -CSHARP_ARRAYS(unsigned int, uint) -// FIXME - on Unix 64 bit, long is 8 bytes but is 4 bytes on Windows 64 bit. -// How can this be handled sensibly? -// See e.g. http://www.xml.com/ldd/chapter/book/ch10.html -CSHARP_ARRAYS(long, int) -CSHARP_ARRAYS(unsigned long, uint) -CSHARP_ARRAYS(long long, long) -CSHARP_ARRAYS(unsigned long long, ulong) -CSHARP_ARRAYS(float, float) -CSHARP_ARRAYS(double, double) - - -%define CSHARP_ARRAYS_FIXED( CTYPE, CSTYPE ) - -%typemap(ctype) CTYPE FIXED[] "CTYPE*" -%typemap(imtype) CTYPE FIXED[] "IntPtr" -%typemap(cstype) CTYPE FIXED[] "CSTYPE[]" -%typemap(csin, - pre= " fixed ( CSTYPE* swig_ptrTo_$csinput = $csinput ) {", - terminator=" }") - CTYPE FIXED[] "(IntPtr)swig_ptrTo_$csinput" - -%typemap(in) CTYPE FIXED[] "$1 = $input;" -%typemap(freearg) CTYPE FIXED[] "" -%typemap(argout) CTYPE FIXED[] "" - - -%enddef // CSHARP_ARRAYS_FIXED - -CSHARP_ARRAYS_FIXED(signed char, sbyte) -CSHARP_ARRAYS_FIXED(unsigned char, byte) -CSHARP_ARRAYS_FIXED(short, short) -CSHARP_ARRAYS_FIXED(unsigned short, ushort) -CSHARP_ARRAYS_FIXED(int, int) -CSHARP_ARRAYS_FIXED(unsigned int, uint) -CSHARP_ARRAYS_FIXED(long, int) -CSHARP_ARRAYS_FIXED(unsigned long, uint) -CSHARP_ARRAYS_FIXED(long long, long) -CSHARP_ARRAYS_FIXED(unsigned long long, ulong) -CSHARP_ARRAYS_FIXED(float, float) -CSHARP_ARRAYS_FIXED(double, double) - diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i index 2cb687356..47fbaba1d 100644 --- a/Lib/csharp/boost_shared_ptr.i +++ b/Lib/csharp/boost_shared_ptr.i @@ -33,7 +33,7 @@ // plain reference %typemap(in, canthrow=1) CONST TYPE & %{ $1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0); - if (!$1) { + if(!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0); return $null; } %} @@ -199,26 +199,22 @@ %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { - if (swigCPtr.Handle != IntPtr.Zero) { - if (swigCMemOwnBase) { - swigCMemOwnBase = false; - $imcall; - } - swigCPtr = new HandleRef(null, IntPtr.Zero); + if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwnBase) { + swigCMemOwnBase = false; + $imcall; } + swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE { lock(this) { - if (swigCPtr.Handle != IntPtr.Zero) { - if (swigCMemOwnDerived) { - swigCMemOwnDerived = false; - $imcall; - } - swigCPtr = new HandleRef(null, IntPtr.Zero); + if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $imcall; } + swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); base.Dispose(); } diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg index 94f76a3ad..35e5c26d7 100644 --- a/Lib/csharp/csharp.swg +++ b/Lib/csharp/csharp.swg @@ -396,7 +396,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { SWIG_UnpackData($input, (void *)&$1, sizeof($1)); %} %typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input; - if (!$1) { + if(!$1) { SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0); return $null; } %} @@ -428,8 +428,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { %typemap(directorin) SWIGTYPE & %{ $input = ($1_ltype) &$1; %} -%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($iminput == IntPtr.Zero) ? null : new $csclassname($iminput, false)" -%typemap(csdirectorin) SWIGTYPE & "new $csclassname($iminput, false)" +%typemap(csdirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "new $csclassname($iminput, false)" %typemap(csdirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$csclassname.getCPtr($cscall).Handle" /* Default array handling */ @@ -885,26 +884,22 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) { %typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE { lock(this) { - if (swigCPtr.Handle != IntPtr.Zero) { - if (swigCMemOwn) { - swigCMemOwn = false; - $imcall; - } - swigCPtr = new HandleRef(null, IntPtr.Zero); + if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { + swigCMemOwn = false; + $imcall; } + swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); } } %typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE { lock(this) { - if (swigCPtr.Handle != IntPtr.Zero) { - if (swigCMemOwn) { - swigCMemOwn = false; - $imcall; - } - swigCPtr = new HandleRef(null, IntPtr.Zero); + if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) { + swigCMemOwn = false; + $imcall; } + swigCPtr = new HandleRef(null, IntPtr.Zero); GC.SuppressFinalize(this); base.Dispose(); } diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i old mode 100644 new mode 100755 index f4ad88bae..a04831f75 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -6,22 +6,15 @@ * * SWIG typemaps for std::vector * C# implementation - * The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection. - * For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code; then the C# wrapper is - * made to look and feel like a typesafe C# System.Collections.ArrayList. All the methods in IList - * are defined, but we don't derive from IList as this is a typesafe collection and the C++ operator== - * must always be defined for the collection type (which it isn't). + * The C# wrapper is made to look and feel like a typesafe C# System.Collections.ArrayList + * All the methods in IList are defined, but we don't derive from IList as this is a typesafe collection. + * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * * Very often the C# generated code will not compile as the C++ template type is not the same as the C# * proxy type, so use the SWIG_STD_VECTOR_SPECIALIZE or SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro, eg * * SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Klass, SomeNamespace::Klass) * %template(VectKlass) std::vector; - * - * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with - * C++ std::vector wrappers. - * - * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! * ----------------------------------------------------------------------------- */ // Warning: Use the typemaps here in the expectation that the macros they are in will change name. @@ -31,8 +24,8 @@ // MACRO for use within the std::vector class body // CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps -%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CONST_REFERENCE_TYPE, CSTYPE, CTYPE...) -%typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IEnumerable\n#endif\n"; +%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) +%typemap(csinterfaces) std::vector "IDisposable, System.Collections.IEnumerable"; %typemap(cscode) std::vector %{ public $csclassname(System.Collections.ICollection c) : this() { if (c == null) @@ -86,30 +79,15 @@ } } -#if SWIG_DOTNET_1 - public void CopyTo(System.Array array) -#else - public void CopyTo(CSTYPE[] array) -#endif - { + public void CopyTo(System.Array array) { CopyTo(0, array, 0, this.Count); } -#if SWIG_DOTNET_1 - public void CopyTo(System.Array array, int arrayIndex) -#else - public void CopyTo(CSTYPE[] array, int arrayIndex) -#endif - { + public void CopyTo(System.Array array, int arrayIndex) { CopyTo(0, array, arrayIndex, this.Count); } -#if SWIG_DOTNET_1 - public void CopyTo(int index, System.Array array, int arrayIndex, int count) -#else - public void CopyTo(int index, CSTYPE[] array, int arrayIndex, int count) -#endif - { + public void CopyTo(int index, System.Array array, int arrayIndex, int count) { if (array == null) throw new ArgumentNullException("array"); if (index < 0) @@ -119,19 +97,14 @@ if (count < 0) throw new ArgumentOutOfRangeException("count", "Value is less than zero"); if (array.Rank > 1) - throw new ArgumentException("Multi dimensional array.", "array"); + throw new ArgumentException("Multi dimensional array."); if (index+count > this.Count || arrayIndex+count > array.Length) throw new ArgumentException("Number of elements to copy is too large."); for (int i=0; i System.Collections.Generic.IEnumerable.GetEnumerator() { - return new $csclassnameEnumerator(this); - } -#endif - + // Type-safe version of IEnumerable.GetEnumerator System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { return new $csclassnameEnumerator(this); } @@ -145,11 +118,7 @@ /// whenever the collection is modified. This has been done for changes in the size of the /// collection but not when one of the elements of the collection is modified as it is a bit /// tricky to detect unmanaged code that modifies the collection under our feet. - public sealed class $csclassnameEnumerator : System.Collections.IEnumerator -#if !SWIG_DOTNET_1 - , System.Collections.Generic.IEnumerator -#endif - { + public sealed class $csclassnameEnumerator : System.Collections.IEnumerator { private $csclassname collectionRef; private int currentIndex; private object currentObject; @@ -201,20 +170,13 @@ throw new InvalidOperationException("Collection modified."); } } - -#if !SWIG_DOTNET_1 - public void Dispose() { - currentIndex = -1; - currentObject = null; - } -#endif } %} public: typedef size_t size_type; typedef CTYPE value_type; - typedef CONST_REFERENCE_TYPE const_reference; + typedef const value_type& const_reference; %rename(Clear) clear; void clear(); %rename(Add) push_back; @@ -324,14 +286,8 @@ } %enddef -%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) -SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, CSTYPE, CTYPE) -%enddef - - // Extra methods added to the collection class if operator== is defined for the class being wrapped // CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps -// The class will then implement IList<>, which adds extra functionality %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...) %extend { bool Contains(const value_type& value) { @@ -351,13 +307,10 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, CSTYPE, CTYPE) index = (int)(self->rend() - 1 - rit); return index; } - bool Remove(const value_type& value) { + void Remove(const value_type& value) { std::vector::iterator it = std::find(self->begin(), self->end(), value); - if (it != self->end()) { + if (it != self->end()) self->erase(it); - return true; - } - return false; } } %enddef @@ -381,6 +334,7 @@ namespace std { } %enddef + %{ #include #include @@ -407,15 +361,11 @@ namespace std { template class vector { SWIG_STD_VECTOR_MINIMUM(T, const T*) }; - // bool is a bit different in the C++ standard - template<> class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(bool, bool, bool) - SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool, bool) - }; } // template specializations for std::vector // these provide extra collections methods as operator== is defined +SWIG_STD_VECTOR_SPECIALIZE(bool, bool) SWIG_STD_VECTOR_SPECIALIZE(char, char) SWIG_STD_VECTOR_SPECIALIZE(sbyte, signed char) SWIG_STD_VECTOR_SPECIALIZE(byte, unsigned char) @@ -431,3 +381,4 @@ SWIG_STD_VECTOR_SPECIALIZE(float, float) SWIG_STD_VECTOR_SPECIALIZE(double, double) SWIG_STD_VECTOR_SPECIALIZE(string, std::string) // also requires a %include + diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i old mode 100644 new mode 100755 diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i old mode 100644 new mode 100755 diff --git a/Lib/intrusive_ptr.i b/Lib/intrusive_ptr.i deleted file mode 100644 index 7a686cfc5..000000000 --- a/Lib/intrusive_ptr.i +++ /dev/null @@ -1,96 +0,0 @@ -// Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1 -// For example for std::tr1, use: -// #define SWIG_SHARED_PTR_NAMESPACE std -// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 -// #define SWIG_INTRUSIVE_PTR_NAMESPACE boost -// #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE - -#if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE) -# define SWIG_INTRUSIVE_PTR_NAMESPACE boost -#endif - -#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) -# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE -#else -# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE -#endif - -namespace SWIG_INTRUSIVE_PTR_NAMESPACE { -#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) - namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE { -#endif - template class intrusive_ptr { - }; -#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE) - } -#endif -} - -%fragment("SWIG_intrusive_deleter", "header") { -template struct SWIG_intrusive_deleter -{ - void operator()(T * p) - { - if(p) intrusive_ptr_release(p); - } -}; -} - -%fragment("SWIG_null_deleter", "header") { -struct SWIG_null_deleter { - void operator() (void const *) const { - } -}; -%#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter() -%#define SWIG_NO_NULL_DELETER_1 -} - -// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types -// For plain classes, do not use for derived classes -%define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...) -SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE) -SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) -%enddef - -// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types -// For derived classes -%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) -SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE) -SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) -%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{ - *newmemory = SWIG_CAST_NEW_MEMORY; - return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from); - %} -%extend TYPE { - static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { - return swigSharedPtrUpcast; - } -} -%enddef - -// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types -// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy -// For plain classes, do not use for derived classes -%define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...) -SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE) -SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE) -%enddef - -// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types -// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy -// For derived classes -%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...) -SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE) -SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE) -%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{ - *newmemory = SWIG_CAST_NEW_MEMORY; - return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from); -%} -%extend TYPE { - static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { - return swigSharedPtrUpcast; - } -} -%enddef - - diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i deleted file mode 100644 index 48f6c317b..000000000 --- a/Lib/java/boost_intrusive_ptr.i +++ /dev/null @@ -1,460 +0,0 @@ -%include - -%define SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) - -%naturalvar TYPE; -%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; - -// destructor mods -%feature("unref") TYPE "(void)arg1; delete smartarg1;" - - -%typemap(in) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - // plain value - argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; - if (!argp) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); - return $null; - } - $1 = *argp; -%} -%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{ - //plain value(out) - $1_ltype* resultp = new $1_ltype(($1_ltype &)$1); - intrusive_ptr_add_ref(resultp); - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >()); -%} - -%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - // plain pointer - smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; - $1 = (TYPE *)(smartarg ? smartarg->get() : 0); -%} -%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{ - //plain pointer(out) - #if ($owner) - if ($1) { - intrusive_ptr_add_ref($1); - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); - } else { - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; - } - #else - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; - #endif -%} - -%typemap(in) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - // plain reference - $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); - if(!$1) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); - return $null; - } -%} -%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{ - //plain reference(out) - #if ($owner) - if ($1) { - intrusive_ptr_add_ref($1); - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >()); - } else { - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; - } - #else - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0; - #endif -%} - -%typemap(in) CONST TYPE *& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - // plain pointer by reference - temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); - $1 = &temp; -%} -%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE *& %{ - // plain pointer by reference(out) - #if ($owner) - if (*$1) { - intrusive_ptr_add_ref(*$1); - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >()); - } else { - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; - } - #else - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0); - #endif -%} - -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ - // intrusive_ptr by value - smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; - if (smartarg) { - $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); - } -%} -%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{ - if ($1) { - intrusive_ptr_add_ref(result.get()); - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >()); - } else { - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; - } -%} - -%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ - // shared_ptr by value - smartarg = *($&1_ltype*)&$input; - if (smartarg) $1 = *smartarg; -%} -%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ - *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; -%} - -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ - // intrusive_ptr by reference - if ( $input ) { - smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; - temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); - $1 = &temp; - } else { - $1 = &tempnull; - } -%} -%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ - delete &($1); - if ($self) { - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); - $1 = *temp; - } -%} -%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{ - if (*$1) { - intrusive_ptr_add_ref($1->get()); - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); - } else { - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; - } -%} - -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ - // intrusive_ptr by pointer - if ( $input ) { - smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; - temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); - $1 = &temp; - } else { - $1 = &tempnull; - } -%} -%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ - delete $1; - if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input); -%} -%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{ - if ($1 && *$1) { - intrusive_ptr_add_ref($1->get()); - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >()); - } else { - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; - } - if ($owner) delete $1; -%} - -%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{ - // intrusive_ptr by pointer reference - smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input; - if ($input) { - temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true); - } - tempp = &temp; - $1 = &tempp; -%} -%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ - if ($self) $1 = *$input; -%} -%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{ - if (*$1 && **$1) { - intrusive_ptr_add_ref((*$1)->get()); - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >()); - } else { - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0; - } -%} - -// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug -%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ -#error "typemaps for $1_type not available" -%} -%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ -#error "typemaps for $1_type not available" -%} - - -%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "jlong" -%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "long" -%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS" -%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >, - SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *, - SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($javainput)" - -%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > { - long cPtr = $jnicall; - return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); - } -%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { - long cPtr = $jnicall; - return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); - } -%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & { - long cPtr = $jnicall; - return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); - } -%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * { - long cPtr = $jnicall; - return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); - } -%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& { - long cPtr = $jnicall; - return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); - } - - -%typemap(javaout) CONST TYPE { - return new PROXYCLASS($jnicall, true); - } -%typemap(javaout) CONST TYPE & { - return new PROXYCLASS($jnicall, true); - } -%typemap(javaout) CONST TYPE * { - long cPtr = $jnicall; - return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); - } -%typemap(javaout) CONST TYPE *& { - long cPtr = $jnicall; - return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); - } - -// Base proxy classes -%typemap(javabody) TYPE %{ - private long swigCPtr; - private boolean swigCMemOwnBase; - - protected $javaclassname(long cPtr, boolean cMemoryOwn) { - swigCMemOwnBase = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr($javaclassname obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -%} - -// Derived proxy classes -%typemap(javabody_derived) TYPE %{ - private long swigCPtr; - private boolean swigCMemOwnDerived; - - protected $javaclassname(long cPtr, boolean cMemoryOwn) { - super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true); - swigCMemOwnDerived = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr($javaclassname obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -%} - -%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { - if(swigCPtr != 0 && swigCMemOwnBase) { - swigCMemOwnBase = false; - $jnicall; - } - swigCPtr = 0; - } - -%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { - if(swigCPtr != 0 && swigCMemOwnDerived) { - swigCMemOwnDerived = false; - $jnicall; - } - swigCPtr = 0; - super.delete(); - } - -// CONST version needed ???? also for C# -%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" -%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" - - -%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; -%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >; -%enddef - - -///////////////////////////////////////////////////////////////////// - - -%include - -%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, CONST, TYPE...) - -%naturalvar TYPE; -%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; - -// destructor mods -%feature("unref") TYPE "(void)arg1; delete smartarg1;" - - -// plain value -%typemap(in) CONST TYPE ($&1_type argp = 0) %{ - argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0; - if (!argp) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type"); - return $null; - } - $1 = *argp; %} -%typemap(out) CONST TYPE -%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %} - -// plain pointer -%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{ - smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input; - $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %} -%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{ - *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0; -%} - -// plain reference -%typemap(in) CONST TYPE & %{ - $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); - if (!$1) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); - return $null; - } %} -%typemap(out, fragment="SWIG_null_deleter") CONST TYPE & -%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %} - -// plain pointer by reference -%typemap(in) CONST TYPE *& ($*1_ltype temp = 0) -%{ temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); - $1 = &temp; %} -%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *& -%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %} - -%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{ - // shared_ptr by value - smartarg = *($&1_ltype*)&$input; - if (smartarg) $1 = *smartarg; -%} -%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{ - *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0; -%} - -// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug -%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ -#error "typemaps for $1_type not available" -%} -%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{ -#error "typemaps for $1_type not available" -%} - - -%typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "jlong" -%typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "long" -%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "PROXYCLASS" -%typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "PROXYCLASS.getCPtr($javainput)" -%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > { - long cPtr = $jnicall; - return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); - } - -%typemap(javaout) CONST TYPE { - return new PROXYCLASS($jnicall, true); - } -%typemap(javaout) CONST TYPE & { - return new PROXYCLASS($jnicall, true); - } -%typemap(javaout) CONST TYPE * { - long cPtr = $jnicall; - return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); - } -%typemap(javaout) CONST TYPE *& { - long cPtr = $jnicall; - return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true); - } - -// Base proxy classes -%typemap(javabody) TYPE %{ - private long swigCPtr; - private boolean swigCMemOwnBase; - - protected $javaclassname(long cPtr, boolean cMemoryOwn) { - swigCMemOwnBase = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr($javaclassname obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -%} - -// Derived proxy classes -%typemap(javabody_derived) TYPE %{ - private long swigCPtr; - private boolean swigCMemOwnDerived; - - protected $javaclassname(long cPtr, boolean cMemoryOwn) { - super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true); - swigCMemOwnDerived = cMemoryOwn; - swigCPtr = cPtr; - } - - protected static long getCPtr($javaclassname obj) { - return (obj == null) ? 0 : obj.swigCPtr; - } -%} - -%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { - if (swigCPtr != 0) { - if (swigCMemOwnBase) { - swigCMemOwnBase = false; - $jnicall; - } - swigCPtr = 0; - } - } - -%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { - if (swigCPtr != 0) { - if (swigCMemOwnDerived) { - swigCMemOwnDerived = false; - $jnicall; - } - swigCPtr = 0; - } - super.delete(); - } - -// CONST version needed ???? also for C# -%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long" -%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long" - - -%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >; -%enddef - diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i index 75762f84f..1f555bf85 100644 --- a/Lib/java/boost_shared_ptr.i +++ b/Lib/java/boost_shared_ptr.i @@ -33,7 +33,7 @@ // plain reference %typemap(in) CONST TYPE & %{ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0); - if (!$1) { + if(!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} @@ -166,23 +166,19 @@ %} %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE { - if (swigCPtr != 0) { - if (swigCMemOwnBase) { - swigCMemOwnBase = false; - $jnicall; - } - swigCPtr = 0; + if(swigCPtr != 0 && swigCMemOwnBase) { + swigCMemOwnBase = false; + $jnicall; } + swigCPtr = 0; } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE { - if (swigCPtr != 0) { - if (swigCMemOwnDerived) { - swigCMemOwnDerived = false; - $jnicall; - } - swigCPtr = 0; + if(swigCPtr != 0 && swigCMemOwnDerived) { + swigCMemOwnDerived = false; + $jnicall; } + swigCPtr = 0; super.delete(); } diff --git a/Lib/java/java.swg b/Lib/java/java.swg index bd2357a86..b7c5607c3 100644 --- a/Lib/java/java.swg +++ b/Lib/java/java.swg @@ -364,7 +364,7 @@ } %typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); } -%typemap(out, noblock=1) char * { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } +%typemap(out, noblock=1) char * { if($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } %typemap(javadirectorin) char * "$jniinput" %typemap(javadirectorout) char * "$javacall" @@ -378,7 +378,7 @@ $1 = &temp; } %typemap(freearg, noblock=1) char *& { if ($1 && *$1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)*$1); } -%typemap(out, noblock=1) char *& { if (*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); } +%typemap(out, noblock=1) char *& { if(*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); } %typemap(out) void "" %typemap(javadirectorin) void "$jniinput" @@ -597,7 +597,7 @@ /* Generic pointers and references */ %typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %} %typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input; - if (!$1) { + if(!$1) { SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null"); return $null; } %} @@ -620,8 +620,7 @@ %typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE & %{ *($&1_ltype)&$input = ($1_ltype) &$1; %} -%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*) "($jniinput == 0) ? null : new $javaclassname($jniinput, false)" -%typemap(javadirectorin) SWIGTYPE & "new $javaclassname($jniinput, false)" +%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "new $javaclassname($jniinput, false)" %typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE & "$javaclassname.getCPtr($javacall)" /* Default array handling */ @@ -656,7 +655,7 @@ %typemap(argout) char[ANY], char[] "" %typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); } -%typemap(out, noblock=1) char[ANY], char[] { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } +%typemap(out, noblock=1) char[ANY], char[] { if($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); } %typemap(javadirectorin) char[ANY], char[] "$jniinput" %typemap(javadirectorout) char[ANY], char[] "$javacall" @@ -1148,23 +1147,19 @@ SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME) SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) %typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - $jnicall; - } - swigCPtr = 0; + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + $jnicall; } + swigCPtr = 0; } %typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE { - if (swigCPtr != 0) { - if (swigCMemOwn) { - swigCMemOwn = false; - $jnicall; - } - swigCPtr = 0; + if(swigCPtr != 0 && swigCMemOwn) { + swigCMemOwn = false; + $jnicall; } + swigCPtr = 0; super.delete(); } @@ -1195,8 +1190,7 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE) #define %javaenum(wrapapproach) %feature("java:enum","wrapapproach") #define %javamethodmodifiers %feature("java:methodmodifiers") #define %javaexception(exceptionclasses) %feature("except",throws=exceptionclasses) -#define %nojavaexception %feature("except","0",throws="") -#define %clearjavaexception %feature("except","",throws="") +#define %nojavaexception %feature("except","",throws="") %pragma(java) jniclassclassmodifiers="class" %pragma(java) moduleclassmodifiers="public class" diff --git a/Lib/java/javahead.swg b/Lib/java/javahead.swg index fc4c4e267..4aa0c84b5 100644 --- a/Lib/java/javahead.swg +++ b/Lib/java/javahead.swg @@ -34,7 +34,7 @@ %insert(runtime) %{ /* Fix for jlong on some versions of gcc on Windows */ -#if defined(__GNUC__) && !defined(__INTEL_COMPILER) +#if defined(__GNUC__) && !defined(__INTELC__) typedef long long __int64; #endif diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 29439606b..92fa25ac2 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -46,40 +46,6 @@ namespace std { } } }; - - // bool specialization - template<> class vector { - public: - typedef size_t size_type; - typedef bool value_type; - typedef bool const_reference; - vector(); - vector(size_type n); - size_type size() const; - size_type capacity() const; - void reserve(size_type n); - %rename(isEmpty) empty; - bool empty() const; - void clear(); - %rename(add) push_back; - void push_back(const value_type& x); - %extend { - const_reference get(int i) throw (std::out_of_range) { - int size = int(self->size()); - if (i>=0 && isize()); - if (i>=0 && i=0),"number must not be negative") -$1 = ($type)lua_tonumber(L, $input);%} %typemap(out) int,short,long, unsigned int,unsigned short,unsigned long, @@ -45,20 +41,15 @@ $1 = ($type)lua_tonumber(L, $input);%} %typemap(in,checkfn="lua_isnumber") const int&($basetype temp) %{ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} -%typemap(in,checkfn="lua_isnumber") const unsigned int&($basetype temp) -%{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative") -temp=($basetype)lua_tonumber(L,$input); $1=&temp;%} - -%typemap(out) const int&, const unsigned int& +%typemap(out) const int& %{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%} // for the other numbers we can just use an apply statement to cover them -%apply const int & {const short&,const long&,const signed char&, +%apply const int & {const short&,const long&, + const unsigned int&,const unsigned short&,const unsigned long&, + const signed char&,const unsigned char&, const float&,const double&}; -%apply const unsigned int & {const unsigned short&,const unsigned long&, - const unsigned char&}; - /* enums have to be handled slightly differently VC++ .net will not allow a cast from lua_Number(double) to enum directly. */ diff --git a/Lib/ocaml/std_deque.i b/Lib/ocaml/std_deque.i index baadb4e53..44815ebda 100644 --- a/Lib/ocaml/std_deque.i +++ b/Lib/ocaml/std_deque.i @@ -28,4 +28,4 @@ } }; -%include +%include <_std_deque.i> diff --git a/Lib/octave/carrays.i b/Lib/octave/carrays.i index 014de37ff..454762aa1 100644 --- a/Lib/octave/carrays.i +++ b/Lib/octave/carrays.i @@ -1,5 +1,5 @@ %define %array_class(TYPE,NAME) - %array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__) + %array_class_wrap(TYPE,NAME,__paren,__paren_asgn) %enddef %include diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg index afc3ed147..bb1122a7b 100644 --- a/Lib/octave/octcontainer.swg +++ b/Lib/octave/octcontainer.swg @@ -204,7 +204,7 @@ namespace swig operator T () const { - // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, _index); + // swig::PyObject_var item = OctSequence_GetItem(_seq, _index); octave_value item; // * todo try { return swig::as(item, true); @@ -410,7 +410,7 @@ namespace swig { int s = size(); for (int i = 0; i < s; ++i) { - // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, i); + // swig::PyObject_var item = OctSequence_GetItem(_seq, i); octave_value item; // * todo if (!swig::check(item)) { if (set_err) { @@ -453,7 +453,7 @@ namespace swig $result = Cell(tmpc); } - %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="OctSequence_Cont") {} + %fragment("PyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="OctSequence_Cont") {} %typemap(out,fragment="OctPairBoolOutputIterator") std::pair, std::pair { @@ -513,11 +513,11 @@ namespace swig return x; } - value_type __paren__(difference_type i) throw (std::out_of_range) { + value_type __paren(difference_type i) throw (std::out_of_range) { return *(swig::cgetpos(self, i)); } - void __paren_asgn__(difference_type i, value_type x) throw (std::out_of_range) { + void __paren_asgn(difference_type i, value_type x) throw (std::out_of_range) { *(swig::getpos(self,i)) = x; } diff --git a/Lib/octave/octopers.swg b/Lib/octave/octopers.swg index c38e64d8c..a9ccf44b8 100644 --- a/Lib/octave/octopers.swg +++ b/Lib/octave/octopers.swg @@ -6,68 +6,68 @@ // operators supported in Octave, and the methods they are routed to -// __brace__ a{args} -// __brace_asgn__ a{args} = rhs -// __paren__ a(args) -// __paren_asgn__ a(args) = rhs -// __str__ generates string rep +// __brace a{args} +// __brace_asgn a{args} = rhs +// __paren a(args) +// __paren_asgn a(args) = rhs +// __str generates string rep -// __not__ !a -// __uplus__ +a -// __uminus__ -a -// __transpose__ a.' -// __hermitian__ a' -// __incr__ a++ -// __decr__ a-- -// __add__ a + b -// __sub__ a - b -// __mul__ a * b -// __div__ a / b -// __pow__ a ^ b -// __ldiv__ a \ b -// __lshift__ a << b -// __rshift__ a >> b -// __lt__ a < b -// __le__ a <= b -// __eq__ a == b -// __ge__ a >= b -// __gt__ a > b -// __ne__ a != b -// __el_mul__ a .* b -// __el_div__ a ./ b -// __el_pow__ a .^ b -// __el_ldiv__ a .\ b -// __el_and__ a & b -// __el_or__ a | b +// __not !a +// __uplus +a +// __uminus -a +// __transpose a.' +// __hermitian a' +// __incr a++ +// __decr a-- +// __add a + b +// __sub a - b +// __mul a * b +// __div a / b +// __pow a ^ b +// __ldiv a \ b +// __lshift a << b +// __rshift a >> b +// __lt a < b +// __le a <= b +// __eq a == b +// __ge a >= b +// __gt a > b +// __ne a != b +// __el_mul a .* b +// __el_div a ./ b +// __el_pow a .^ b +// __el_ldiv a .\ b +// __el_and a & b +// __el_or a | b // operators supported in C++, and the methods that route to them -%rename(__add__) *::operator+; -%rename(__add__) *::operator+(); -%rename(__add__) *::operator+() const; -%rename(__sub__) *::operator-; -%rename(__uminus__) *::operator-(); -%rename(__uminus__) *::operator-() const; -%rename(__mul__) *::operator*; -%rename(__div__) *::operator/; -%rename(__mod__) *::operator%; -%rename(__lshift__) *::operator<<; -%rename(__rshift__) *::operator>>; -%rename(__el_and__) *::operator&&; -%rename(__el_or__) *::operator||; -%rename(__xor__) *::operator^; -%rename(__invert__) *::operator~; -%rename(__lt__) *::operator<; -%rename(__le__) *::operator<=; -%rename(__gt__) *::operator>; -%rename(__ge__) *::operator>=; -%rename(__eq__) *::operator==; -%rename(__ne__) *::operator!=; -%rename(__not__) *::operator!; -%rename(__incr__) *::operator++; -%rename(__decr__) *::operator--; -%rename(__paren__) *::operator(); -%rename(__brace__) *::operator[]; +%rename(__add) *::operator+; +%rename(__add) *::operator+(); +%rename(__add) *::operator+() const; +%rename(__sub) *::operator-; +%rename(__uminus) *::operator-(); +%rename(__uminus) *::operator-() const; +%rename(__mul) *::operator*; +%rename(__div) *::operator/; +%rename(__mod) *::operator%; +%rename(__lshift) *::operator<<; +%rename(__rshift) *::operator>>; +%rename(__el_and) *::operator&&; +%rename(__el_or) *::operator||; +%rename(__xor) *::operator^; +%rename(__invert) *::operator~; +%rename(__lt) *::operator<; +%rename(__le) *::operator<=; +%rename(__gt) *::operator>; +%rename(__ge) *::operator>=; +%rename(__eq) *::operator==; +%rename(__ne) *::operator!=; +%rename(__not) *::operator!; +%rename(__incr) *::operator++; +%rename(__decr) *::operator--; +%rename(__paren) *::operator(); +%rename(__brace) *::operator[]; // Ignored inplace operators %ignoreoperator(PLUSEQ) operator+=; diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index c48310e27..07aa47cb5 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -589,7 +589,7 @@ namespace Swig { // index operator else { if (ops[skip] == '(' || ops[skip] == '{') { - const char *op_name = ops[skip] == '(' ? "__paren__" : "__brace__"; + const char *op_name = ops[skip] == '(' ? "__paren" : "__brace"; octave_value_list args; args.append(*idx_it++); ++skip; @@ -628,7 +628,7 @@ namespace Swig { } else if (ops[skip] == '(' || ops[skip] == '{') { - const char *op_name = ops[skip] == '(' ? "__paren_asgn__" : "__brace_asgn__"; + const char *op_name = ops[skip] == '(' ? "__paren_asgn" : "__brace_asgn"; member_value_pair *m = find_member(op_name, false); if (m) { octave_value_list args; @@ -666,27 +666,40 @@ namespace Swig { virtual bool is_string() const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); - return !!nc_this->find_member("__str__", false); + return !!nc_this->find_member("__str", false); } virtual std::string string_value(bool force = false) const { octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); - member_value_pair *m = nc_this->find_member("__str__", false); + member_value_pair *m = nc_this->find_member("__str", false); if (!m) { - error("__str__ method not defined"); + error("__str method not defined"); return std::string(); } octave_value_list outarg = nc_this->member_invoke(m, octave_value_list(nc_this->as_value()), 1); if (outarg.length() < 1 || !outarg(0).is_string()) { - error("__str__ method did not return a string"); + error("__str method did not return a string"); return std::string(); } return outarg(0).string_value(); } + /* virtual Octave_map map_value() const { - return Octave_map(); + octave_swig_type *nc_this = const_cast < octave_swig_type *>(this); + member_value_pair *m = nc_this->find_member("__str", false); + if (!m) { + error("__map method not defined"); + return std::string(); + } + octave_value_list outarg = nc_this->member_invoke(m, octave_value_list(nc_this->as_value()), 1); + if (outarg.length() < 1 || !outarg(0).is_map()) { + error("__map method did not return a string"); + return std::string(); + } + return outarg(0).map_value(); } + */ virtual string_vector map_keys() const { member_map tmp; @@ -700,35 +713,6 @@ namespace Swig { return keys; } - virtual bool save_ascii (std::ostream& os) { - return true; - } - - virtual bool load_ascii (std::istream& is) { - return true; - } - - virtual bool save_binary (std::ostream& os, bool& save_as_floats) { - return true; - } - - virtual bool load_binary (std::istream& is, bool swap, - oct_mach_info::float_format fmt) { - return true; - } - -#if defined (HAVE_HDF5) - virtual bool - save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { - return true; - } - - virtual bool - load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) { - return true; - } -#endif - virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const { return string_value(); } @@ -753,7 +737,7 @@ namespace Swig { assert(ost); octave_value ret; - if (ost->dispatch_unary_op(std::string("__") + op_name + std::string("__"), ret)) + if (ost->dispatch_unary_op(std::string("__") + op_name, ret)) return ret; std::string symbol = "op_" + ost->swig_type_name() + "_" + op_name; octave_value_list args; @@ -770,7 +754,7 @@ namespace Swig { octave_swig_type *rhs_ost = Swig::swig_value_deref(rhs); octave_value ret; - if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name + std::string("__"), rhs, ret)) + if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name, rhs, ret)) return ret; std::string symbol; @@ -892,35 +876,9 @@ namespace Swig { virtual std::string string_value(bool force = false) const { return ptr->string_value(force); } - virtual Octave_map map_value() const - { return ptr->map_value(); } - virtual string_vector map_keys() const { return ptr->map_keys(); } - virtual bool save_ascii (std::ostream& os) - { return ptr->save_ascii(os); } - - virtual bool load_ascii (std::istream& is) - { return ptr->load_ascii(is); } - - virtual bool save_binary (std::ostream& os, bool& save_as_floats) - { return ptr->save_binary(os, save_as_floats); } - - virtual bool load_binary (std::istream& is, bool swap, - oct_mach_info::float_format fmt) - { return ptr->load_binary(is, swap, fmt); } - -#if defined (HAVE_HDF5) - virtual bool - save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) - { return ptr->save_hdf5(loc_id, name, save_as_floats); } - - virtual bool - load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) - { return ptr->load_hdf5(loc_id, name, have_h5giterate_bug); } -#endif - virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const { return ptr->convert_to_str(pad, force, type); } @@ -969,37 +927,6 @@ namespace Swig { void print(std::ostream &os, bool pr_as_read_syntax = false) const { os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size() << std::endl; } - - - virtual bool save_ascii (std::ostream& os) { - return true; - } - - virtual bool load_ascii (std::istream& is) { - return true; - } - - virtual bool save_binary (std::ostream& os, bool& save_as_floats) { - return true; - } - - virtual bool load_binary (std::istream& is, bool swap, - oct_mach_info::float_format fmt) { - return true; - } - -#if defined (HAVE_HDF5) - virtual bool - save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) { - return true; - } - - virtual bool - load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) { - return true; - } -#endif - private: DECLARE_OCTAVE_ALLOCATOR; DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA; diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index 82a17285a..dd68ca4c1 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -3,7 +3,6 @@ #include #include #include -#include %} %insert(runtime) "swigrun.swg"; diff --git a/Lib/octave/octstdcommon.swg b/Lib/octave/octstdcommon.swg index 96923f40a..e69c7e629 100644 --- a/Lib/octave/octstdcommon.swg +++ b/Lib/octave/octstdcommon.swg @@ -42,7 +42,7 @@ namespace swig { struct traits_asptr { static int asptr(const octave_value& obj, Type **val) { Type *p; - int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); + int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0; if (SWIG_IsOK(res)) { if (val) *val = p; } diff --git a/Lib/octave/std_basic_string.i b/Lib/octave/std_basic_string.i index 9fc0b0730..f2dac405a 100644 --- a/Lib/octave/std_basic_string.i +++ b/Lib/octave/std_basic_string.i @@ -1,6 +1,5 @@ #if !defined(SWIG_STD_STRING) #define SWIG_STD_BASIC_STRING -#define SWIG_STD_MODERN_STL %include @@ -10,22 +9,39 @@ %fragment(SWIG_AsPtr_frag(std::basic_string),"header", fragment="SWIG_AsCharPtrAndSize") { SWIGINTERN int -SWIG_AsPtr(std::basic_string)(octave_value obj, std::string **val) +SWIG_AsPtr(std::basic_string)(PyObject* obj, std::string **val) { - if (obj.is_string()) { - if (val) - *val = new std::string(obj.string_value()); - return SWIG_NEWOBJ; + static swig_type_info* string_info = + SWIG_TypeQuery("std::basic_string *"); + std::string *vptr; + if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) { + if (val) *val = vptr; + return SWIG_OLDOBJ; + } else { + PyErr_Clear(); + char* buf = 0 ; size_t size = 0; int alloc = 0; + if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) { + if (buf) { + if (val) *val = new std::string(buf, size - 1); + if (alloc == SWIG_NEWOBJ) %delete_array(buf); + return SWIG_NEWOBJ; + } + } else { + PyErr_Clear(); + } + if (val) { + SWIG_PYTHON_THREAD_BEGIN_BLOCK; + PyErr_SetString(PyExc_TypeError,"a string is expected"); + SWIG_PYTHON_THREAD_END_BLOCK; + } + return 0; } - if (val) - error("a string is expected"); - return 0; -} +} } %fragment(SWIG_From_frag(std::basic_string),"header", fragment="SWIG_FromCharPtrAndSize") { -SWIGINTERNINLINE octave_value +SWIGINTERNINLINE PyObject* SWIG_From(std::basic_string)(const std::string& s) { return SWIG_FromCharPtrAndSize(s.data(), s.size()); diff --git a/Lib/octave/std_carray.i b/Lib/octave/std_carray.i index 9e2338a61..1477479da 100644 --- a/Lib/octave/std_carray.i +++ b/Lib/octave/std_carray.i @@ -17,7 +17,7 @@ namespace swig { %extend std::carray { %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header", - fragment="SwigPyIterator_T", + fragment="PySwigIterator_T", fragment=SWIG_Traits_frag(_Type), fragment="StdCarrayTraits") { namespace swig { @@ -36,7 +36,7 @@ namespace swig { %typemap(out,noblock=1) iterator, const_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1), - swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN); } inline size_t __len__() const { return self->size(); } @@ -46,7 +46,7 @@ namespace swig { inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; } - swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) { + swig::PySwigIterator* __iter__(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } } diff --git a/Lib/octave/std_map.i b/Lib/octave/std_map.i index 20003df58..a54e5f753 100644 --- a/Lib/octave/std_map.i +++ b/Lib/octave/std_map.i @@ -22,7 +22,7 @@ /* int res = SWIG_ERROR; if (PyDict_Check(obj)) { - SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); + PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL); res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; @@ -58,8 +58,8 @@ } PyObject *obj = PyDict_New(); for (const_iterator i= map.begin(); i!= map.end(); ++i) { - swig::SwigVar_PyObject key = swig::from(i->first); - swig::SwigVar_PyObject val = swig::from(i->second); + swig::PyObject_var key = swig::from(i->first); + swig::PyObject_var val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; @@ -92,10 +92,10 @@ }; template - struct OctMapIterator_T : SwigPyIteratorClosed_T + struct OctMapIterator_T : PySwigIteratorClosed_T { OctMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq) - : SwigPyIteratorClosed_T(curr, first, last, seq) + : PySwigIteratorClosed_T(curr, first, last, seq) { } }; @@ -112,7 +112,7 @@ }; template - inline SwigPyIterator* + inline PySwigIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = octave_value()) { return new OctMapKeyIterator_T(current, begin, end, seq); @@ -130,7 +130,7 @@ template - inline SwigPyIterator* + inline PySwigIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = 0) { return new OctMapValueIterator_T(current, begin, end, seq); diff --git a/Lib/perl5/noembed.h b/Lib/perl5/noembed.h index 55c3752aa..a29de61f5 100644 --- a/Lib/perl5/noembed.h +++ b/Lib/perl5/noembed.h @@ -91,9 +91,3 @@ #ifdef open #undef open #endif -#ifdef readdir - #undef readdir -#endif -#ifdef bind - #undef bind -#endif diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index 6fb2968f0..54d098d9b 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -205,32 +205,13 @@ SWIG_Perl_TypeProxyName(const swig_type_info *type) { } } -/* Identical to SWIG_TypeCheck, except for strcmp comparison */ SWIGRUNTIME swig_cast_info * SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if ( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) || - (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0)) ) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; + SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) + || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty); } + /* Function for getting a pointer value */ SWIGRUNTIME int diff --git a/Lib/perl5/perlstrings.swg b/Lib/perl5/perlstrings.swg index 242a9c967..2083f0bba 100644 --- a/Lib/perl5/perlstrings.swg +++ b/Lib/perl5/perlstrings.swg @@ -6,11 +6,6 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc) { - if (SvMAGICAL(obj)) { - SV *tmp = sv_newmortal(); - SvSetSV(tmp, obj); - obj = tmp; - } if (SvPOK(obj)) { STRLEN len = 0; char *cstr = SvPV(obj, len); diff --git a/Lib/perl5/perltypemaps.swg b/Lib/perl5/perltypemaps.swg index a59f84689..c17e410b9 100644 --- a/Lib/perl5/perltypemaps.swg +++ b/Lib/perl5/perltypemaps.swg @@ -43,7 +43,6 @@ /* Perl types */ #define SWIG_Object SV * -#define VOID_Object sv_newmortal() /* Perl $shadow flag */ #define %newpointer_flags $shadow diff --git a/Lib/perl5/std_vector.i b/Lib/perl5/std_vector.i index 7c4f72919..b1f722d4b 100644 --- a/Lib/perl5/std_vector.i +++ b/Lib/perl5/std_vector.i @@ -105,9 +105,9 @@ namespace std { } } %typemap(out) vector { - size_t len = $1.size(); + int len = $1.size(); SV **svs = new SV*[len]; - for (size_t i=0; i // PHP initialization routine. +%include // Php4 initialization routine. %include // Global variables. %include @@ -73,13 +73,6 @@ $1 = ($1_ltype) Z_STRVAL_PP($input); } -%typemap(in) (char *STRING, int LENGTH) -{ - convert_to_string_ex($input); - $1 = ($1_ltype) Z_STRVAL_PP($input); - $2 = ($2_ltype) Z_STRLEN_PP($input); -} - /* Object passed by value. Convert to a pointer */ %typemap(in) SWIGTYPE ($&1_ltype tmp) { @@ -110,7 +103,6 @@ SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor"); } } - %typemap(argout) SWIGTYPE *, SWIGTYPE [], SWIGTYPE&; @@ -205,15 +197,15 @@ %typemap(out) SWIGTYPE *, SWIGTYPE [], SWIGTYPE & -%{ - SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); -%} +{ + SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner); +} %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC { - swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); - SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner); + swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1); + SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner); } %typemap(out) SWIGTYPE @@ -225,7 +217,7 @@ #else { $&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type)); - memcpy(resultobj, &$1, sizeof($1_type)); + memmove(resultobj, &$1, sizeof($1_type)); SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1); } #endif @@ -234,9 +226,7 @@ %typemap(out) char [ANY] { - int len = 0; - while (len < $1_dim0 && $1[len]) ++len; - RETVAL_STRINGL($1, len, 1); + RETVAL_STRINGL($1,$1_dim0,1); } // This typecheck does hard checking for proper argument type. If you want @@ -267,24 +257,19 @@ %php_typecheck(double,SWIG_TYPECHECK_BOOL,IS_DOUBLE) %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE -{ - void *tmp; - _v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0); -} + " /* typecheck SWIGTYPE */ " %typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE [], SWIGTYPE & { void *tmp; - _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0); + _v = (SWIG_ConvertPtr( *$input, (void**)&tmp, $1_descriptor, 0) >= 0); } %typecheck(SWIG_TYPECHECK_VOIDPTR) void * -{ - void *tmp; - _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, 0, 0) >= 0); -} + " /* typecheck void * */ " + /* Exception handling */ @@ -310,4 +295,4 @@ /* php keywords */ -%include +%include diff --git a/Lib/php/phpinit.swg b/Lib/php4/php4init.swg similarity index 100% rename from Lib/php/phpinit.swg rename to Lib/php4/php4init.swg diff --git a/Lib/php/phpkw.swg b/Lib/php4/php4kw.swg similarity index 99% rename from Lib/php/phpkw.swg rename to Lib/php4/php4kw.swg index 3d1a62511..a6b519445 100644 --- a/Lib/php/phpkw.swg +++ b/Lib/php4/php4kw.swg @@ -2,7 +2,7 @@ * See the LICENSE file for information on copyright, usage and redistribution * of SWIG, and the README file for authors - http://www.swig.org/release.html. * - * phpkw.swg + * php4kw.swg * * The 'keywords' in PHP are global, ie, the following names are fine * when used as class methods. @@ -67,7 +67,7 @@ PHPKW(include_once); PHPKW(isset); PHPKW(list); PHPKW(new); -// PHPKW(old_function); /* No longer reserved in PHP5 */ +PHPKW(old_function); /* No longer reserved in PHP5 */ PHPKW(or); PHPKW(print); PHPKW(require); diff --git a/Lib/php/phprun.swg b/Lib/php4/php4run.swg similarity index 96% rename from Lib/php/phprun.swg rename to Lib/php4/php4run.swg index 5196b95b4..d38452764 100644 --- a/Lib/php/phprun.swg +++ b/Lib/php4/php4run.swg @@ -2,9 +2,9 @@ * See the LICENSE file for information on copyright, usage and redistribution * of SWIG, and the README file for authors - http://www.swig.org/release.html. * - * phprun.swg + * php4run.swg * - * PHP runtime library + * PHP4 runtime library * ----------------------------------------------------------------------------- */ #ifdef __cplusplus @@ -70,8 +70,8 @@ static int default_error_code = E_ERROR; if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else /* Standard SWIG API */ -#define SWIG_GetModule(clientdata) SWIG_Php_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer) +#define SWIG_GetModule(clientdata) SWIG_Php4_GetModule() +#define SWIG_SetModule(clientdata, pointer) SWIG_Php4_SetModule(pointer) /* used to wrap returned objects in so we know whether they are newobject and need freeing, or not */ @@ -199,7 +199,7 @@ SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC } static char const_name[] = "swig_runtime_data_type_pointer"; -static swig_module_info *SWIG_Php_GetModule() { +static swig_module_info *SWIG_Php4_GetModule() { zval *pointer; swig_module_info *ret = 0; @@ -216,7 +216,7 @@ static swig_module_info *SWIG_Php_GetModule() { return ret; } -static void SWIG_Php_SetModule(swig_module_info *pointer) { +static void SWIG_Php4_SetModule(swig_module_info *pointer) { TSRMLS_FETCH(); REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0); } diff --git a/Lib/php/phppointers.i b/Lib/php4/phppointers.i similarity index 100% rename from Lib/php/phppointers.i rename to Lib/php4/phppointers.i diff --git a/Lib/php/std_common.i b/Lib/php4/std_common.i similarity index 100% rename from Lib/php/std_common.i rename to Lib/php4/std_common.i diff --git a/Lib/php/std_deque.i b/Lib/php4/std_deque.i similarity index 100% rename from Lib/php/std_deque.i rename to Lib/php4/std_deque.i diff --git a/Lib/php/std_map.i b/Lib/php4/std_map.i similarity index 97% rename from Lib/php/std_map.i rename to Lib/php4/std_map.i index c6721806b..c35f21dc7 100644 --- a/Lib/php/std_map.i +++ b/Lib/php4/std_map.i @@ -30,7 +30,6 @@ namespace std { map(const map &); unsigned int size() const; - %rename(is_empty) empty; bool empty() const; void clear(); %extend { @@ -70,7 +69,6 @@ namespace std { map(const map &); unsigned int size() const; - %rename(is_empty) empty; bool empty() const; void clear(); %extend { @@ -107,7 +105,6 @@ namespace std { map(const map &); unsigned int size() const; - %rename(is_empty) empty; bool empty() const; void clear(); %extend { @@ -145,7 +142,6 @@ namespace std { map(const map &); unsigned int size() const; - %rename(is_empty) empty; bool empty() const; void clear(); %extend { diff --git a/Lib/php/std_pair.i b/Lib/php4/std_pair.i similarity index 100% rename from Lib/php/std_pair.i rename to Lib/php4/std_pair.i diff --git a/Lib/php/std_string.i b/Lib/php4/std_string.i similarity index 100% rename from Lib/php/std_string.i rename to Lib/php4/std_string.i diff --git a/Lib/php/std_vector.i b/Lib/php4/std_vector.i similarity index 98% rename from Lib/php/std_vector.i rename to Lib/php4/std_vector.i index b54181618..fe084aca4 100644 --- a/Lib/php/std_vector.i +++ b/Lib/php4/std_vector.i @@ -48,7 +48,6 @@ namespace std { public: vector(unsigned int size = 0); unsigned int size() const; - %rename(is_empty) empty; bool empty() const; void clear(); %rename(push) push_back; @@ -87,7 +86,6 @@ namespace std { public: vector(unsigned int size = 0); unsigned int size() const; - %rename(is_empty) empty; bool empty() const; void clear(); %rename(push) push_back; diff --git a/Lib/php/stl.i b/Lib/php4/stl.i similarity index 100% rename from Lib/php/stl.i rename to Lib/php4/stl.i diff --git a/Lib/php/typemaps.i b/Lib/php4/typemaps.i similarity index 62% rename from Lib/php/typemaps.i rename to Lib/php4/typemaps.i index 7af301d0d..c388fdf96 100644 --- a/Lib/php/typemaps.i +++ b/Lib/php4/typemaps.i @@ -4,7 +4,7 @@ * * typemaps.i. * - * SWIG Typemap library for PHP. + * SWIG Typemap library for PHP4. * * This library provides standard typemaps for modifying SWIG's behavior. * With enough entries in this file, I hope that very few people actually @@ -96,96 +96,16 @@ int_typemap(unsigned short); int_typemap(unsigned long); int_typemap(unsigned char); -int_typemap(long long); -%typemap(argout,fragment="t_output_helper") long long *OUTPUT -{ - zval *o; - MAKE_STD_ZVAL(o); - if ((long long)LONG_MIN <= temp$argnum && temp$argnum <= (long long)LONG_MAX) { - ZVAL_LONG(o, temp$argnum); - } else { - char temp[256]; - sprintf(temp, "%lld", temp$argnum); - ZVAL_STRING(o, temp, 1); - } - t_output_helper( &$result, o ); -} -%typemap(in) TYPE *REFERENCE (long long lvalue) -%{ - // FIXME won't work for values which don't fit in a long... - convert_to_long_ex($input); - lvalue = (long long) (*$input)->value.lval; - $1 = &lvalue; -%} -%typemap(argout) long long *REFERENCE -%{ - if ((long long)LONG_MIN <= lvalue$argnum && lvalue$argnum <= (long long)LONG_MAX) { - (*$arg)->value.lval = (long)(lvalue$argnum); - (*$arg)->type = IS_LONG; - } else { - char temp[256]; - sprintf(temp, "%lld", lvalue$argnum); - ZVAL_STRING((*$arg), temp, 1); - } -%} -int_typemap(unsigned long long); -%typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT -{ - zval *o; - MAKE_STD_ZVAL(o); - if (temp$argnum <= (unsigned long long)LONG_MAX) { - ZVAL_LONG(o, temp$argnum); - } else { - char temp[256]; - sprintf(temp, "%llu", temp$argnum); - ZVAL_STRING(o, temp, 1); - } - t_output_helper( &$result, o ); -} -%typemap(in) TYPE *REFERENCE (unsigned long long lvalue) -%{ - // FIXME won't work for values which don't fit in a long... - convert_to_long_ex($input); - lvalue = (unsigned long long) (*$input)->value.lval; - $1 = &lvalue; -%} -%typemap(argout) unsigned long long *REFERENCE -%{ - if (lvalue$argnum <= (unsigned long long)LONG_MAX) { - (*$arg)->value.lval = (long)(lvalue$argnum); - (*$arg)->type = IS_LONG; - } else { - char temp[256]; - sprintf(temp, "%llu", lvalue$argnum); - ZVAL_STRING((*$arg), temp, 1); - } -%} - %typemap(in) float *INOUT = float *INPUT; %typemap(in) double *INOUT = double *INPUT; %typemap(in) int *INOUT = int *INPUT; %typemap(in) short *INOUT = short *INPUT; %typemap(in) long *INOUT = long *INPUT; -%typemap(in) long long *INOUT = long long *INPUT; %typemap(in) unsigned *INOUT = unsigned *INPUT; %typemap(in) unsigned short *INOUT = unsigned short *INPUT; %typemap(in) unsigned long *INOUT = unsigned long *INPUT; %typemap(in) unsigned char *INOUT = unsigned char *INPUT; -%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT; - -%typemap(in) float &INOUT = float *INPUT; -%typemap(in) double &INOUT = double *INPUT; - -%typemap(in) int &INOUT = int *INPUT; -%typemap(in) short &INOUT = short *INPUT; -%typemap(in) long &INOUT = long *INPUT; -%typemap(in) long long &INOUT = long long *INPUT; -%typemap(in) unsigned &INOUT = unsigned *INPUT; -%typemap(in) unsigned short &INOUT = unsigned short *INPUT; -%typemap(in) unsigned long &INOUT = unsigned long *INPUT; -%typemap(in) unsigned char &INOUT = unsigned char *INPUT; -%typemap(in) unsigned long long &INOUT = unsigned long long *INPUT; %typemap(argout) float *INOUT = float *OUTPUT; %typemap(argout) double *INOUT= double *OUTPUT; @@ -193,23 +113,9 @@ int_typemap(unsigned long long); %typemap(argout) int *INOUT = int *OUTPUT; %typemap(argout) short *INOUT = short *OUTPUT; %typemap(argout) long *INOUT= long *OUTPUT; -%typemap(argout) long long *INOUT= long long *OUTPUT; %typemap(argout) unsigned short *INOUT= unsigned short *OUTPUT; %typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT; %typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT; -%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT; - -%typemap(argout) float &INOUT = float *OUTPUT; -%typemap(argout) double &INOUT= double *OUTPUT; - -%typemap(argout) int &INOUT = int *OUTPUT; -%typemap(argout) short &INOUT = short *OUTPUT; -%typemap(argout) long &INOUT= long *OUTPUT; -%typemap(argout) long long &INOUT= long long *OUTPUT; -%typemap(argout) unsigned short &INOUT= unsigned short *OUTPUT; -%typemap(argout) unsigned long &INOUT = unsigned long *OUTPUT; -%typemap(argout) unsigned char &INOUT = unsigned char *OUTPUT; -%typemap(argout) unsigned long long &INOUT = unsigned long long *OUTPUT; %typemap(in) char INPUT[ANY] ( char temp[$1_dim0] ) %{ diff --git a/Lib/php/utils.i b/Lib/php4/utils.i similarity index 86% rename from Lib/php/utils.i rename to Lib/php4/utils.i index facf54196..f7241187c 100644 --- a/Lib/php/utils.i +++ b/Lib/php4/utils.i @@ -24,23 +24,19 @@ %enddef %define CONVERT_STRING_IN(lvar,t,invar) - if ((*invar)->type==IS_NULL) { - lvar = (t) 0; - } else { - convert_to_string_ex(invar); - lvar = (t) Z_STRVAL_PP(invar); - } + convert_to_string_ex(invar); + lvar = (t) Z_STRVAL_PP(invar); %enddef %define %pass_by_val( TYPE, CONVERT_IN ) -%typemap(in) TYPE, const TYPE & +%typemap(in) TYPE %{ CONVERT_IN($1,$1_ltype,$input); %} %enddef %fragment("t_output_helper","header") %{ -static void +void t_output_helper( zval **target, zval *o) { if ( (*target)->type == IS_ARRAY ) { /* it's already an array, just append */ diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i index b4c0b5b83..2e34290ac 100644 --- a/Lib/python/boost_shared_ptr.i +++ b/Lib/python/boost_shared_ptr.i @@ -1,11 +1,5 @@ %include -// Set SHARED_PTR_DISOWN to $disown if required, for example -// #define SHARED_PTR_DISOWN $disown -#if !defined(SHARED_PTR_DISOWN) -#define SHARED_PTR_DISOWN 0 -#endif - %define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...) %naturalvar TYPE; @@ -57,10 +51,10 @@ } // plain pointer -// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance +// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) { int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } @@ -145,10 +139,10 @@ } // plain pointer by reference -// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance +// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance %typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) { int newmem = 0; - res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem); + res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem); if (!SWIG_IsOK(res)) { %argument_fail(res, "$type", $symname, $argnum); } diff --git a/Lib/python/director.swg b/Lib/python/director.swg index 836d107ce..176ee3336 100644 --- a/Lib/python/director.swg +++ b/Lib/python/director.swg @@ -107,7 +107,7 @@ namespace Swig { /* memory handler */ struct GCItem { - virtual ~GCItem() {} + virtual ~GCItem() = 0; virtual int get_own() const { @@ -115,6 +115,10 @@ namespace Swig { } }; + GCItem::~GCItem() + { + } + struct GCItem_var { GCItem_var(GCItem *item = 0) : _item(item) @@ -208,7 +212,10 @@ namespace Swig { swig_msg += msg; } if (!PyErr_Occurred()) { + swig_msg.insert(0, ": "); PyErr_SetString(error, getMessage()); + } else { + SWIG_Python_AddErrorMsg(getMessage()); } SWIG_PYTHON_THREAD_END_BLOCK; } diff --git a/Lib/python/file.i b/Lib/python/file.i index 294ab9178..c0e7d5ea9 100644 --- a/Lib/python/file.i +++ b/Lib/python/file.i @@ -20,13 +20,11 @@ SWIG_AsValFilePtr(PyObject *obj, FILE **val) { if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) { if (val) *val = (FILE *)vptr; return SWIG_OK; - } -%#if PY_VERSION_HEX < 0x03000000 + } if (PyFile_Check(obj)) { if (val) *val = PyFile_AsFile(obj); return SWIG_OK; } -%#endif return SWIG_TypeError; } } diff --git a/Lib/python/pyabc.i b/Lib/python/pyabc.i deleted file mode 100644 index 3da06b5a9..000000000 --- a/Lib/python/pyabc.i +++ /dev/null @@ -1,10 +0,0 @@ -%define %pythonabc(Type, Abc) - %feature("python:abc", #Abc) Type; -%enddef -%pythoncode {import collections}; -%pythonabc(std::vector, collections.MutableSequence); -%pythonabc(std::list, collections.MutableSequence); -%pythonabc(std::map, collections.MutableMapping); -%pythonabc(std::multimap, collections.MutableMapping); -%pythonabc(std::set, collections.MutableSet); -%pythonabc(std::multiset, collections.MutableSet); diff --git a/Lib/python/pyapi.swg b/Lib/python/pyapi.swg index d980f9263..1d5148dbf 100644 --- a/Lib/python/pyapi.swg +++ b/Lib/python/pyapi.swg @@ -27,20 +27,6 @@ typedef struct swig_const_info { swig_type_info **ptype; } swig_const_info; - -/* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *self, PyObject *func) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyInstanceMethod_New(func); -#else - return NULL; -#endif -} - #ifdef __cplusplus #if 0 { /* cc-mode */ diff --git a/Lib/python/pybuffer.i b/Lib/python/pybuffer.i deleted file mode 100644 index 121cd709f..000000000 --- a/Lib/python/pybuffer.i +++ /dev/null @@ -1,107 +0,0 @@ -/* Implementing buffer protocol typemaps */ - -/* %pybuffer_mutable_binary(TYPEMAP, SIZE) - * - * Macro for functions accept mutable buffer pointer with a size. - * This can be used for both input and output. For example: - * - * %pybuffer_mutable_binary(char *buff, int size); - * void foo(char *buff, int size) { - * for(int i=0; i; + std::vector; or as a member variable: struct A { - SwigPtr_PyObject obj; + PyObject_ptr obj; A(PyObject *o) : _obj(o) { } }; or as a input/output value - SwigPtr_PyObject func(SwigPtr_PyObject obj) { - SwigPtr_PyObject out = PyString_FromFormat("hello %s", PyObject_AsString(obj)); + PyObject_ptr func(PyObject_ptr obj) { + PyObject_ptr out = PyString_FromFormat("hello %s", PyObject_AsString(obj)); Py_DECREF(out); return out; } just remember to pair the object creation with the proper DECREF, - the same as with plain PyObject *ptr, since SwigPtr_PyObject always add + the same as with plain PyObject *ptr, since PyObject_ptr always add one reference at construction. - SwigPtr_PyObject is 'visible' at the wrapped side, so you can do: + PyObject_ptr is 'visible' at the wrapped side, so you can do: - %template(pyvector) std::vector; + %template(pyvector) std::vector; and all the proper typemaps will be used. */ namespace swig { - %ignore SwigPtr_PyObject; - struct SwigPtr_PyObject {}; - %apply PyObject * {SwigPtr_PyObject}; - %apply PyObject * const& {SwigPtr_PyObject const&}; + %ignore PyObject_ptr; + struct PyObject_ptr {}; + %apply PyObject * {PyObject_ptr}; + %apply PyObject * const& {PyObject_ptr const&}; /* For output */ - %typemap(out,noblock=1) SwigPtr_PyObject { + %typemap(out,noblock=1) PyObject_ptr { $result = (PyObject *)$1; Py_INCREF($result); } - %typemap(out,noblock=1) SwigPtr_PyObject const & { + %typemap(out,noblock=1) PyObject_ptr const & { $result = (PyObject *)*$1; Py_INCREF($result); } @@ -58,28 +58,28 @@ namespace swig { %{ namespace swig { - class SwigPtr_PyObject { + class PyObject_ptr { protected: PyObject *_obj; public: - SwigPtr_PyObject() :_obj(0) + PyObject_ptr() :_obj(0) { } - SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj) + PyObject_ptr(const PyObject_ptr& item) : _obj(item._obj) { Py_XINCREF(_obj); } - SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj) + PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj) { if (initial_ref) { Py_XINCREF(_obj); } } - SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) + PyObject_ptr & operator=(const PyObject_ptr& item) { Py_XINCREF(item._obj); Py_XDECREF(_obj); @@ -87,7 +87,7 @@ namespace swig { return *this; } - ~SwigPtr_PyObject() + ~PyObject_ptr() { Py_XDECREF(_obj); } @@ -106,33 +106,33 @@ namespace swig { %} /* - SwigVar_PyObject is used to manage 'in the scope' PyObject * variables, + PyObject_var is used to manage 'in the scope' PyObject * variables, as in int func () { - SwigVar_PyObject obj = PyString_FromString("hello"); + PyObject_var obj = PyString_FromString("hello"); } ie, 'obj' is created and destructed in the same scope from a python object that carries at least one reference value. - SwigVar_PyObject just take care of applying the proper Py_DECREF. + PyObject_var just take care of applying the proper Py_DECREF. Hence, this class is purely internal and not visible at the wrapped side. */ namespace swig { - %ignore SwigVar_PyObject; - struct SwigVar_PyObject {}; - %apply PyObject * {SwigVar_PyObject}; - %apply PyObject * const& {SwigVar_PyObject const&}; + %ignore PyObject_var; + struct PyObject_var {}; + %apply PyObject * {PyObject_var}; + %apply PyObject * const& {PyObject_var const&}; } %{ namespace swig { - struct SwigVar_PyObject : SwigPtr_PyObject { - SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { } + struct PyObject_var : PyObject_ptr { + PyObject_var(PyObject* obj = 0) : PyObject_ptr(obj, false) { } - SwigVar_PyObject & operator = (PyObject* obj) + PyObject_var & operator = (PyObject* obj) { Py_XDECREF(_obj); _obj = obj; diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 6fd1d56f9..ed0eb7f0b 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -36,15 +36,15 @@ %include -%fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") { +%fragment(SWIG_Traits_frag(swig::PyObject_ptr),"header",fragment="StdTraits") { namespace swig { - template <> struct traits { + template <> struct traits { typedef value_category category; - static const char* type_name() { return "SwigPtr_PyObject"; } + static const char* type_name() { return "PyObject_ptr"; } }; - template <> struct traits_from { - typedef SwigPtr_PyObject value_type; + template <> struct traits_from { + typedef PyObject_ptr value_type; static PyObject *from(const value_type& val) { PyObject *obj = static_cast(val); Py_XINCREF(obj); @@ -53,14 +53,14 @@ namespace swig { }; template <> - struct traits_check { - static bool check(SwigPtr_PyObject) { + struct traits_check { + static bool check(PyObject_ptr) { return true; } }; - template <> struct traits_asval { - typedef SwigPtr_PyObject value_type; + template <> struct traits_asval { + typedef PyObject_ptr value_type; static int asval(PyObject *obj, value_type *val) { if (val) *val = obj; return SWIG_OK; @@ -69,15 +69,15 @@ namespace swig { } } -%fragment(SWIG_Traits_frag(swig::SwigVar_PyObject),"header",fragment="StdTraits") { +%fragment(SWIG_Traits_frag(swig::PyObject_var),"header",fragment="StdTraits") { namespace swig { - template <> struct traits { + template <> struct traits { typedef value_category category; - static const char* type_name() { return "SwigVar_PyObject"; } + static const char* type_name() { return "PyObject_var"; } }; - template <> struct traits_from { - typedef SwigVar_PyObject value_type; + template <> struct traits_from { + typedef PyObject_var value_type; static PyObject *from(const value_type& val) { PyObject *obj = static_cast(val); Py_XINCREF(obj); @@ -86,14 +86,14 @@ namespace swig { }; template <> - struct traits_check { - static bool check(SwigVar_PyObject) { + struct traits_check { + static bool check(PyObject_var) { return true; } }; - template <> struct traits_asval { - typedef SwigVar_PyObject value_type; + template <> struct traits_asval { + typedef PyObject_var value_type; static int asval(PyObject *obj, value_type *val) { if (val) *val = obj; return SWIG_OK; @@ -102,7 +102,7 @@ namespace swig { } } -%fragment("SwigPySequence_Base","header") +%fragment("PySequence_Base","header") { %#include @@ -115,38 +115,27 @@ namespace std { { bool res; SWIG_PYTHON_THREAD_BEGIN_BLOCK; - res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false; - /* This may fall into a case of inconsistent - eg. ObjA > ObjX > ObjB - but ObjA < ObjB - */ - if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) ) - { - /* Objects can't be compared, this mostly occured in Python 3.0 */ - /* Compare their ptr directly for a workaround */ - res = (v < w); - PyErr_Clear(); - } + res = PyObject_Compare(v, w) < 0; SWIG_PYTHON_THREAD_END_BLOCK; return res; } }; template <> - struct less : public binary_function + struct less : public binary_function { bool - operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const + operator()(const swig::PyObject_ptr& v, const swig::PyObject_ptr& w) const { return std::less()(v, w); } }; template <> - struct less : public binary_function + struct less : public binary_function { bool - operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const + operator()(const swig::PyObject_var& v, const swig::PyObject_var& w) const { return std::less()(v, w); } @@ -288,24 +277,24 @@ namespace swig { } } -%fragment("SwigPySequence_Cont","header", +%fragment("PySequence_Cont","header", fragment="StdTraits", - fragment="SwigPySequence_Base", - fragment="SwigPyIterator_T") + fragment="PySequence_Base", + fragment="PySwigIterator_T") { namespace swig { template - struct SwigPySequence_Ref + struct PySequence_Ref { - SwigPySequence_Ref(PyObject* seq, int index) + PySequence_Ref(PyObject* seq, int index) : _seq(seq), _index(index) { } operator T () const { - swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index); + swig::PyObject_var item = PySequence_GetItem(_seq, _index); try { return swig::as(item, true); } catch (std::exception& e) { @@ -320,7 +309,7 @@ namespace swig } } - SwigPySequence_Ref& operator=(const T& v) + PySequence_Ref& operator=(const T& v) { PySequence_SetItem(_seq, _index, swig::from(v)); return *this; @@ -332,18 +321,18 @@ namespace swig }; template - struct SwigPySequence_ArrowProxy + struct PySequence_ArrowProxy { - SwigPySequence_ArrowProxy(const T& x): m_value(x) {} + PySequence_ArrowProxy(const T& x): m_value(x) {} const T* operator->() const { return &m_value; } operator const T*() const { return &m_value; } T m_value; }; template - struct SwigPySequence_InputIterator + struct PySequence_InputIterator { - typedef SwigPySequence_InputIterator self; + typedef PySequence_InputIterator self; typedef std::random_access_iterator_tag iterator_category; typedef Reference reference; @@ -351,11 +340,11 @@ namespace swig typedef T* pointer; typedef int difference_type; - SwigPySequence_InputIterator() + PySequence_InputIterator() { } - SwigPySequence_InputIterator(PyObject* seq, int index) + PySequence_InputIterator(PyObject* seq, int index) : _seq(seq), _index(index) { } @@ -365,9 +354,9 @@ namespace swig return reference(_seq, _index); } - SwigPySequence_ArrowProxy + PySequence_ArrowProxy operator->() const { - return SwigPySequence_ArrowProxy(operator*()); + return PySequence_ArrowProxy(operator*()); } bool operator==(const self& ri) const @@ -436,19 +425,19 @@ namespace swig }; template - struct SwigPySequence_Cont + struct PySequence_Cont { - typedef SwigPySequence_Ref reference; - typedef const SwigPySequence_Ref const_reference; + typedef PySequence_Ref reference; + typedef const PySequence_Ref const_reference; typedef T value_type; typedef T* pointer; typedef int difference_type; typedef int size_type; typedef const pointer const_pointer; - typedef SwigPySequence_InputIterator iterator; - typedef SwigPySequence_InputIterator const_iterator; + typedef PySequence_InputIterator iterator; + typedef PySequence_InputIterator const_iterator; - SwigPySequence_Cont(PyObject* seq) : _seq(0) + PySequence_Cont(PyObject* seq) : _seq(0) { if (!PySequence_Check(seq)) { throw std::invalid_argument("a sequence is expected"); @@ -457,7 +446,7 @@ namespace swig Py_INCREF(_seq); } - ~SwigPySequence_Cont() + ~PySequence_Cont() { Py_XDECREF(_seq); } @@ -506,7 +495,7 @@ namespace swig { int s = size(); for (int i = 0; i < s; ++i) { - swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i); + swig::PyObject_var item = PySequence_GetItem(_seq, i); if (!swig::check(item)) { if (set_err) { char msg[1024]; @@ -533,40 +522,40 @@ namespace swig class const_iterator; class const_reverse_iterator; - %typemap(out,noblock=1,fragment="SwigPySequence_Cont") + %typemap(out,noblock=1,fragment="PySequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)), - swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN); } - %typemap(out,noblock=1,fragment="SwigPySequence_Cont") + %typemap(out,noblock=1,fragment="PySequence_Cont") std::pair, std::pair { $result = PyTuple_New(2); PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), - swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN)); PyTuple_SetItem($result,1,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second), - swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN)); } - %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="SwigPySequence_Cont") {} + %fragment("PyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="PySequence_Cont") {} - %typemap(out,noblock=1,fragment="SwigPyPairBoolOutputIterator") + %typemap(out,noblock=1,fragment="PyPairBoolOutputIterator") std::pair, std::pair { $result = PyTuple_New(2); PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first), - swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN)); + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN)); PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second)); } - %typemap(in,noblock=1,fragment="SwigPySequence_Cont") - iterator(swig::SwigPyIterator *iter = 0, int res), - reverse_iterator(swig::SwigPyIterator *iter = 0, int res), - const_iterator(swig::SwigPyIterator *iter = 0, int res), - const_reverse_iterator(swig::SwigPyIterator *iter = 0, int res) { - res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); + %typemap(in,noblock=1,fragment="PySequence_Cont") + iterator(swig::PySwigIterator *iter = 0, int res), + reverse_iterator(swig::PySwigIterator *iter = 0, int res), + const_iterator(swig::PySwigIterator *iter = 0, int res), + const_reverse_iterator(swig::PySwigIterator *iter = 0, int res) { + res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0); if (!SWIG_IsOK(res) || !iter) { %argument_fail(SWIG_TypeError, "$type", $symname, $argnum); } else { - swig::SwigPyIterator_T<$type > *iter_t = dynamic_cast *>(iter); + swig::PySwigIterator_T<$type > *iter_t = dynamic_cast *>(iter); if (iter_t) { $1 = iter_t->get_current(); } else { @@ -575,18 +564,18 @@ namespace swig } } - %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SwigPySequence_Cont") + %typecheck(%checkcode(ITERATOR),noblock=1,fragment="PySequence_Cont") iterator, reverse_iterator, const_iterator, const_reverse_iterator { - swig::SwigPyIterator *iter = 0; - int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0); - $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); + swig::PySwigIterator *iter = 0; + int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0); + $1 = (SWIG_IsOK(res) && iter && (dynamic_cast *>(iter) != 0)); } - %fragment("SwigPySequence_Cont"); + %fragment("PySequence_Cont"); %newobject iterator(PyObject **PYTHON_SELF); %extend { - swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF) { + swig::PySwigIterator* iterator(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } @@ -608,11 +597,6 @@ namespace swig return !(self->empty()); } - /* Alias for Python 3 compatibility */ - bool __bool__() const { - return !(self->empty()); - } - size_type __len__() const { return self->size(); } @@ -623,7 +607,7 @@ namespace swig %swig_sequence_iterator(%arg(Sequence)) %swig_container_methods(%arg(Sequence)) - %fragment("SwigPySequence_Base"); + %fragment("PySequence_Base"); %extend { value_type pop() throw (std::out_of_range) { @@ -634,14 +618,6 @@ namespace swig return x; } - /* typemap for slice object support */ - %typemap(in) PySliceObject* { - $1 = (PySliceObject *) $input; - } - %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) PySliceObject* { - $1 = PySlice_Check($input); - } - Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) { return swig::getslice(self, i, j); } @@ -658,43 +634,6 @@ namespace swig void __delitem__(difference_type i) throw (std::out_of_range) { self->erase(swig::getpos(self,i)); } - - - /* Overloaded methods for Python 3 compatibility - * (Also useful in Python 2.x) - */ - Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range) { - Py_ssize_t i, j, step; - if( !PySlice_Check(slice) ) { - SWIG_Error(SWIG_TypeError, "Slice object expected."); - return NULL; - } - PySlice_GetIndices(slice, self->size(), &i, &j, &step); - return swig::getslice(self, i, j); - } - - void __setitem__(PySliceObject *slice, const Sequence& v) - throw (std::out_of_range, std::invalid_argument) { - Py_ssize_t i, j, step; - if( !PySlice_Check(slice) ) { - SWIG_Error(SWIG_TypeError, "Slice object expected."); - return; - } - PySlice_GetIndices(slice, self->size(), &i, &j, &step); - swig::setslice(self, i, j, v); - } - - void __delitem__(PySliceObject *slice) - throw (std::out_of_range) { - Py_ssize_t i, j, step; - if( !PySlice_Check(slice) ) { - SWIG_Error(SWIG_TypeError, "Slice object expected."); - return; - } - PySlice_GetIndices(slice, self->size(), &i, &j, &step); - swig::delslice(self, i,j); - } - } %enddef @@ -740,16 +679,16 @@ namespace swig %fragment("StdSequenceTraits","header", fragment="StdTraits", - fragment="SwigPySequence_Cont") + fragment="PySequence_Cont") { namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, Seq* seq) { - // seq->assign(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented - typedef typename SwigPySeq::value_type value_type; - typename SwigPySeq::const_iterator it = swigpyseq.begin(); - for (;it != swigpyseq.end(); ++it) { + assign(const PySeq& pyseq, Seq* seq) { + // seq->assign(pyseq.begin(), pyseq.end()); // not used as not always implemented + typedef typename PySeq::value_type value_type; + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } @@ -769,14 +708,14 @@ namespace swig { } } else if (PySequence_Check(obj)) { try { - SwigPySequence_Cont swigpyseq(obj); + PySequence_Cont pyseq(obj); if (seq) { sequence *pseq = new sequence(); - assign(swigpyseq, pseq); + assign(pyseq, pseq); *seq = pseq; return SWIG_NEWOBJ; } else { - return swigpyseq.check() ? SWIG_OK : SWIG_ERROR; + return pyseq.check() ? SWIG_OK : SWIG_ERROR; } } catch (std::exception& e) { if (seq) { diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg index fe7313554..e287e2fc8 100644 --- a/Lib/python/pyerrors.swg +++ b/Lib/python/pyerrors.swg @@ -55,16 +55,15 @@ SWIG_Python_AddErrorMsg(const char* mesg) if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); if (value) { - char *tmp; PyObject *old_str = PyObject_Str(value); PyErr_Clear(); Py_XINCREF(type); - - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); - SWIG_Python_str_DelForPy3(tmp); + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); Py_DECREF(old_str); Py_DECREF(value); } else { PyErr_SetString(PyExc_RuntimeError, mesg); } } + + diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index 732d4689e..7839511bc 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -1,64 +1,3 @@ -/* Compatibility marcos for Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - -#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) -#define PyInt_Check(x) PyLong_Check(x) -#define PyInt_AsLong(x) PyLong_AsLong(x) -#define PyInt_FromLong(x) PyLong_FromLong(x) -#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) - -#endif - -#ifndef Py_TYPE -# define Py_TYPE(op) ((op)->ob_type) -#endif - -/* SWIG APIs for compatibility of both Python 2 & 3 */ - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_FromFormat PyUnicode_FromFormat -#else -# define SWIG_Python_str_FromFormat PyString_FromFormat -#endif - - -/* Warning: This function will allocate a new string in Python 3, - * so please call SWIG_Python_str_DelForPy3(x) to free the space. - */ -SWIGINTERN char* -SWIG_Python_str_AsChar(PyObject *str) -{ -#if PY_VERSION_HEX >= 0x03000000 - char *cstr; - char *newstr; - int len; - str = PyUnicode_AsUTF8String(str); - PyBytes_AsStringAndSize(str, &cstr, &len); - newstr = (char *) malloc(len+1); - memcpy(newstr, cstr, len+1); - Py_XDECREF(str); - return newstr; -#else - return PyString_AsString(str); -#endif -} - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) -#else -# define SWIG_Python_str_DelForPy3(x) -#endif - - -SWIGINTERN PyObject* -SWIG_Python_str_FromChar(const char *c) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromString(c); -#else - return PyString_FromString(c); -#endif -} /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 @@ -105,7 +44,6 @@ PyString_FromFormat(const char *fmt, ...) { # define PyObject_GenericGetAttr 0 # endif #endif - /* Py_NotImplemented is defined in 2.1 and up. */ #if PY_VERSION_HEX < 0x02010000 # ifndef Py_NotImplemented @@ -113,6 +51,7 @@ PyString_FromFormat(const char *fmt, ...) { # endif #endif + /* A crude PyString_AsStringAndSize implementation for old Pythons */ #if PY_VERSION_HEX < 0x02010000 # ifndef PyString_AsStringAndSize @@ -127,6 +66,7 @@ PyString_FromFormat(const char *fmt, ...) { # endif #endif + /* PyBool_FromLong for old Pythons */ #if PY_VERSION_HEX < 0x02030000 static diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg index 286e7fb68..e6109b7bd 100644 --- a/Lib/python/pyinit.swg +++ b/Lib/python/pyinit.swg @@ -33,58 +33,26 @@ typedef struct swig_varlinkobject { SWIGINTERN PyObject * swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) { -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_InternFromString(""); -#else return PyString_FromString(""); -#endif } SWIGINTERN PyObject * swig_varlink_str(swig_varlinkobject *v) { -#if PY_VERSION_HEX >= 0x03000000 - PyObject *str = PyUnicode_InternFromString("("); - PyObject *tail; - PyObject *joined; - swig_globalvar *var; - for (var = v->vars; var; var=var->next) { - tail = PyUnicode_FromString(var->name); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; - if (var->next) { - tail = PyUnicode_InternFromString(", "); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; - } - } - tail = PyUnicode_InternFromString(")"); - joined = PyUnicode_Concat(str, tail); - Py_DecRef(str); - Py_DecRef(tail); - str = joined; -#else PyObject *str = PyString_FromString("("); - swig_globalvar *var; + swig_globalvar *var; for (var = v->vars; var; var=var->next) { PyString_ConcatAndDel(&str,PyString_FromString(var->name)); if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", ")); } PyString_ConcatAndDel(&str,PyString_FromString(")")); -#endif return str; } SWIGINTERN int swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { - char *tmp; PyObject *str = swig_varlink_str(v); fprintf(fp,"Swig global variables "); - fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str)); - SWIG_Python_str_DelForPy3(tmp); + fprintf(fp,"%s\n", PyString_AsString(str)); Py_DECREF(str); return 0; } @@ -142,13 +110,8 @@ swig_varlink_type(void) { if (!type_init) { const PyTypeObject tmp = { - /* PyObject header changed in Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else PyObject_HEAD_INIT(NULL) 0, /* Number of items in variable part (ob_size) */ -#endif (char *)"swigvarlink", /* Type name (tp_name) */ sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */ 0, /* Itemsize (tp_itemsize) */ @@ -184,10 +147,7 @@ swig_varlink_type(void) { #endif }; varlink_type = tmp; - /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ -#if PY_VERSION_HEX < 0x03000000 varlink_type.ob_type = &PyType_Type; -#endif type_init = 1; } return &varlink_type; @@ -312,37 +272,13 @@ SWIG_Python_FixMethods(PyMethodDef *methods, #ifdef __cplusplus extern "C" #endif - -SWIGEXPORT -#if PY_VERSION_HEX >= 0x03000000 - PyObject* -#else - void -#endif -SWIG_init(void) { - PyObject *m, *d; -#if PY_VERSION_HEX >= 0x03000000 - static struct PyModuleDef SWIG_module = { - PyModuleDef_HEAD_INIT, - (char *) SWIG_name, - NULL, - -1, - SwigMethods, - NULL, - NULL, - NULL, - NULL - }; -#endif - +SWIGEXPORT void SWIG_init(void) { + PyObject *m, *d; + /* Fix SwigMethods to carry the callback ptrs when needed */ SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial); - -#if PY_VERSION_HEX >= 0x03000000 - m = PyModule_Create(&SWIG_module); -#else + m = Py_InitModule((char *) SWIG_name, SwigMethods); -#endif d = PyModule_GetDict(m); SWIG_InitializeModule(0); diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg index 9cd795d7c..38f1791a9 100644 --- a/Lib/python/pyiterators.swg +++ b/Lib/python/pyiterators.swg @@ -6,56 +6,56 @@ * * Implement a python 'output' iterator for Python 2.2 or higher. * - * Users can derive form the SwigPyIterator to implement their + * Users can derive form the PySwigIterator to implement their * own iterators. As an example (real one since we use it for STL/STD - * containers), the template SwigPyIterator_T does the + * containers), the template PySwigIterator_T does the * implementation for genereic C++ iterators. * ----------------------------------------------------------------------------- */ %include -%fragment("SwigPyIterator","header") { +%fragment("PySwigIterator","header") { namespace swig { struct stop_iteration { }; - struct SwigPyIterator { + struct PySwigIterator { private: - SwigPtr_PyObject _seq; + PyObject_ptr _seq; protected: - SwigPyIterator(PyObject *seq) : _seq(seq) + PySwigIterator(PyObject *seq) : _seq(seq) { } public: - virtual ~SwigPyIterator() {} + virtual ~PySwigIterator() {} // Access iterator method, required by Python virtual PyObject *value() const = 0; // Forward iterator method, required by Python - virtual SwigPyIterator *incr(size_t n = 1) = 0; + virtual PySwigIterator *incr(size_t n = 1) = 0; // Backward iterator method, very common in C++, but not required in Python - virtual SwigPyIterator *decr(size_t /*n*/ = 1) + virtual PySwigIterator *decr(size_t /*n*/ = 1) { throw stop_iteration(); } // Random access iterator methods, but not required in Python - virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const + virtual ptrdiff_t distance(const PySwigIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } - virtual bool equal (const SwigPyIterator &/*x*/) const + virtual bool equal (const PySwigIterator &/*x*/) const { throw std::invalid_argument("operation not supported"); } // C++ common/needed methods - virtual SwigPyIterator *copy() const = 0; + virtual PySwigIterator *copy() const = 0; PyObject *next() { @@ -66,12 +66,6 @@ namespace swig { return obj; } - /* Make an alias for Python 3.x */ - PyObject *__next__() - { - return next(); - } - PyObject *previous() { SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads @@ -81,42 +75,42 @@ namespace swig { return obj; } - SwigPyIterator *advance(ptrdiff_t n) + PySwigIterator *advance(ptrdiff_t n) { return (n > 0) ? incr(n) : decr(-n); } - bool operator == (const SwigPyIterator& x) const + bool operator == (const PySwigIterator& x) const { return equal(x); } - bool operator != (const SwigPyIterator& x) const + bool operator != (const PySwigIterator& x) const { return ! operator==(x); } - SwigPyIterator& operator += (ptrdiff_t n) + PySwigIterator& operator += (ptrdiff_t n) { return *advance(n); } - SwigPyIterator& operator -= (ptrdiff_t n) + PySwigIterator& operator -= (ptrdiff_t n) { return *advance(-n); } - SwigPyIterator* operator + (ptrdiff_t n) const + PySwigIterator* operator + (ptrdiff_t n) const { return copy()->advance(n); } - SwigPyIterator* operator - (ptrdiff_t n) const + PySwigIterator* operator - (ptrdiff_t n) const { return copy()->advance(-n); } - ptrdiff_t operator - (const SwigPyIterator& x) const + ptrdiff_t operator - (const PySwigIterator& x) const { return x.distance(*this); } @@ -125,7 +119,7 @@ namespace swig { static int init = 0; static swig_type_info* desc = 0; if (!init) { - desc = SWIG_TypeQuery("swig::SwigPyIterator *"); + desc = SWIG_TypeQuery("swig::PySwigIterator *"); init = 1; } return desc; @@ -134,18 +128,18 @@ namespace swig { } } -%fragment("SwigPyIterator_T","header",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") { +%fragment("PySwigIterator_T","header",fragment="PySwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") { namespace swig { template - class SwigPyIterator_T : public SwigPyIterator + class PySwigIterator_T : public PySwigIterator { public: typedef OutIterator out_iterator; typedef typename std::iterator_traits::value_type value_type; - typedef SwigPyIterator_T self_type; + typedef PySwigIterator_T self_type; - SwigPyIterator_T(out_iterator curr, PyObject *seq) - : SwigPyIterator(seq), current(curr) + PySwigIterator_T(out_iterator curr, PyObject *seq) + : PySwigIterator(seq), current(curr) { } @@ -155,7 +149,7 @@ namespace swig { } - bool equal (const SwigPyIterator &iter) const + bool equal (const PySwigIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { @@ -165,7 +159,7 @@ namespace swig { } } - ptrdiff_t distance(const SwigPyIterator &iter) const + ptrdiff_t distance(const PySwigIterator &iter) const { const self_type *iters = dynamic_cast(&iter); if (iters) { @@ -193,17 +187,17 @@ namespace swig { template::value_type, typename FromOper = from_oper > - class SwigPyIteratorOpen_T : public SwigPyIterator_T + class PySwigIteratorOpen_T : public PySwigIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; - typedef SwigPyIterator_T base; - typedef SwigPyIteratorOpen_T self_type; + typedef PySwigIterator_T base; + typedef PySwigIteratorOpen_T self_type; - SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq) - : SwigPyIterator_T(curr, seq) + PySwigIteratorOpen_T(out_iterator curr, PyObject *seq) + : PySwigIterator_T(curr, seq) { } @@ -211,12 +205,12 @@ namespace swig { return from(static_cast(*(base::current))); } - SwigPyIterator *copy() const + PySwigIterator *copy() const { return new self_type(*this); } - SwigPyIterator *incr(size_t n = 1) + PySwigIterator *incr(size_t n = 1) { while (n--) { ++base::current; @@ -224,7 +218,7 @@ namespace swig { return this; } - SwigPyIterator *decr(size_t n = 1) + PySwigIterator *decr(size_t n = 1) { while (n--) { --base::current; @@ -236,17 +230,17 @@ namespace swig { template::value_type, typename FromOper = from_oper > - class SwigPyIteratorClosed_T : public SwigPyIterator_T + class PySwigIteratorClosed_T : public PySwigIterator_T { public: FromOper from; typedef OutIterator out_iterator; typedef ValueType value_type; - typedef SwigPyIterator_T base; - typedef SwigPyIteratorClosed_T self_type; + typedef PySwigIterator_T base; + typedef PySwigIteratorClosed_T self_type; - SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq) - : SwigPyIterator_T(curr, seq), begin(first), end(last) + PySwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq) + : PySwigIterator_T(curr, seq), begin(first), end(last) { } @@ -258,12 +252,12 @@ namespace swig { } } - SwigPyIterator *copy() const + PySwigIterator *copy() const { return new self_type(*this); } - SwigPyIterator *incr(size_t n = 1) + PySwigIterator *incr(size_t n = 1) { while (n--) { if (base::current == end) { @@ -275,7 +269,7 @@ namespace swig { return this; } - SwigPyIterator *decr(size_t n = 1) + PySwigIterator *decr(size_t n = 1) { while (n--) { if (base::current == begin) { @@ -293,23 +287,23 @@ namespace swig { }; template - inline SwigPyIterator* + inline PySwigIterator* make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0) { - return new SwigPyIteratorClosed_T(current, begin, end, seq); + return new PySwigIteratorClosed_T(current, begin, end, seq); } template - inline SwigPyIterator* + inline PySwigIterator* make_output_iterator(const OutIter& current, PyObject *seq = 0) { - return new SwigPyIteratorOpen_T(current, seq); + return new PySwigIteratorOpen_T(current, seq); } } } -%fragment("SwigPyIterator"); +%fragment("PySwigIterator"); namespace swig { /* @@ -327,67 +321,65 @@ namespace swig /* Mark methods that return new objects */ - %newobject SwigPyIterator::copy; - %newobject SwigPyIterator::operator + (ptrdiff_t n) const; - %newobject SwigPyIterator::operator - (ptrdiff_t n) const; + %newobject PySwigIterator::copy; + %newobject PySwigIterator::operator + (ptrdiff_t n) const; + %newobject PySwigIterator::operator - (ptrdiff_t n) const; - %nodirector SwigPyIterator; - %extend SwigPyIterator { + %nodirector PySwigIterator; + %extend PySwigIterator { %pythoncode {def __iter__(self): return self} } - %catches(swig::stop_iteration) SwigPyIterator::value() const; - %catches(swig::stop_iteration) SwigPyIterator::incr(size_t n = 1); - %catches(swig::stop_iteration) SwigPyIterator::decr(size_t n = 1); - %catches(std::invalid_argument) SwigPyIterator::distance(const SwigPyIterator &x) const; - %catches(std::invalid_argument) SwigPyIterator::equal (const SwigPyIterator &x) const; - %catches(swig::stop_iteration) SwigPyIterator::__next__(); - %catches(swig::stop_iteration) SwigPyIterator::next(); - %catches(swig::stop_iteration) SwigPyIterator::previous(); - %catches(swig::stop_iteration) SwigPyIterator::advance(ptrdiff_t n); - %catches(swig::stop_iteration) SwigPyIterator::operator += (ptrdiff_t n); - %catches(swig::stop_iteration) SwigPyIterator::operator -= (ptrdiff_t n); - %catches(swig::stop_iteration) SwigPyIterator::operator + (ptrdiff_t n) const; - %catches(swig::stop_iteration) SwigPyIterator::operator - (ptrdiff_t n) const; + %catches(swig::stop_iteration) PySwigIterator::value() const; + %catches(swig::stop_iteration) PySwigIterator::incr(size_t n = 1); + %catches(swig::stop_iteration) PySwigIterator::decr(size_t n = 1); + %catches(std::invalid_argument) PySwigIterator::distance(const PySwigIterator &x) const; + %catches(std::invalid_argument) PySwigIterator::equal (const PySwigIterator &x) const; + %catches(swig::stop_iteration) PySwigIterator::next(); + %catches(swig::stop_iteration) PySwigIterator::previous(); + %catches(swig::stop_iteration) PySwigIterator::advance(ptrdiff_t n); + %catches(swig::stop_iteration) PySwigIterator::operator += (ptrdiff_t n); + %catches(swig::stop_iteration) PySwigIterator::operator -= (ptrdiff_t n); + %catches(swig::stop_iteration) PySwigIterator::operator + (ptrdiff_t n) const; + %catches(swig::stop_iteration) PySwigIterator::operator - (ptrdiff_t n) const; - struct SwigPyIterator + struct PySwigIterator { protected: - SwigPyIterator(PyObject *seq); + PySwigIterator(PyObject *seq); public: - virtual ~SwigPyIterator(); + virtual ~PySwigIterator(); // Access iterator method, required by Python virtual PyObject *value() const = 0; // Forward iterator method, required by Python - virtual SwigPyIterator *incr(size_t n = 1) = 0; + virtual PySwigIterator *incr(size_t n = 1) = 0; // Backward iterator method, very common in C++, but not required in Python - virtual SwigPyIterator *decr(size_t n = 1); + virtual PySwigIterator *decr(size_t n = 1); // Random access iterator methods, but not required in Python - virtual ptrdiff_t distance(const SwigPyIterator &x) const; + virtual ptrdiff_t distance(const PySwigIterator &x) const; - virtual bool equal (const SwigPyIterator &x) const; + virtual bool equal (const PySwigIterator &x) const; // C++ common/needed methods - virtual SwigPyIterator *copy() const = 0; + virtual PySwigIterator *copy() const = 0; PyObject *next(); - PyObject *__next__(); PyObject *previous(); - SwigPyIterator *advance(ptrdiff_t n); + PySwigIterator *advance(ptrdiff_t n); - bool operator == (const SwigPyIterator& x) const; - bool operator != (const SwigPyIterator& x) const; - SwigPyIterator& operator += (ptrdiff_t n); - SwigPyIterator& operator -= (ptrdiff_t n); - SwigPyIterator* operator + (ptrdiff_t n) const; - SwigPyIterator* operator - (ptrdiff_t n) const; - ptrdiff_t operator - (const SwigPyIterator& x) const; + bool operator == (const PySwigIterator& x) const; + bool operator != (const PySwigIterator& x) const; + PySwigIterator& operator += (ptrdiff_t n); + PySwigIterator& operator -= (ptrdiff_t n); + PySwigIterator* operator + (ptrdiff_t n) const; + PySwigIterator* operator - (ptrdiff_t n) const; + ptrdiff_t operator - (const PySwigIterator& x) const; }; } diff --git a/Lib/python/pyname_compat.i b/Lib/python/pyname_compat.i deleted file mode 100644 index cdda38f80..000000000 --- a/Lib/python/pyname_compat.i +++ /dev/null @@ -1,88 +0,0 @@ -/* -* From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py, -* since they are inappropriate and discouraged in Python documentation -* (from http://www.python.org/doc/2.5.2/api/includes.html): -* -* "All user visible names defined by Python.h (except those defined by the included -* standard headers) have one of the prefixes "Py" or "_Py". Names beginning with -* "_Py" are for internal use by the Python implementation and should not be used -* by extension writers. Structure member names do not have a reserved prefix. -* -* Important: user code should never define names that begin with "Py" or "_Py". -* This confuses the reader, and jeopardizes the portability of the user code to -* future Python versions, which may define additional names beginning with one -* of these prefixes." -* -* This file defined macros to provide backward compatibility for these deprecated -* symbols. In the case you have these symbols in your interface file, you can simply -* include this file at begining of it. -* -* However, this file may be removed in future release of SWIG, so using this file to -* keep these inappropriate names in your SWIG interface file is also not recommanded. -* Instead, we provide a simple tool for converting your interface files to -* the new naming convention. You can download the tool here: -* https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py -*/ - -%fragment("PySequence_Base", "header", fragment="SwigPySequence_Base") {} -%fragment("PySequence_Cont", "header", fragment="SwigPySequence_Cont") {} -%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} -%fragment("PyPairBoolOutputIterator", "header", fragment="SwigPyPairBoolOutputIterator") {} -%fragment("PySwigIterator", "header", fragment="SwigPyIterator") {} -%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {} - -%inline %{ -#define PyMapIterator_T SwigPyMapIterator_T -#define PyMapKeyIterator_T SwigPyMapKeyIterator_T -#define PyMapValueIterator_T SwigPyMapValueITerator_T -#define PyObject_ptr SwigPtr_PyObject -#define PyObject_var SwigVar_PyObject -#define PyOper SwigPyOper -#define PySeq SwigPySeq -#define PySequence_ArrowProxy SwigPySequence_ArrowProxy -#define PySequence_Cont SwigPySequence_Cont -#define PySequence_InputIterator SwigPySequence_InputIterator -#define PySequence_Ref SwigPySequence_Ref -#define PySwigClientData SwigPyClientData -#define PySwigClientData_Del SwigPyClientData_Del -#define PySwigClientData_New SwigPyClientData_New -#define PySwigIterator SwigPyIterator -#define PySwigIteratorClosed_T SwigPyIteratorClosed_T -#define PySwigIteratorOpen_T SwigPyIteratorOpen_T -#define PySwigIterator_T SwigPyIterator_T -#define PySwigObject SwigPyObject -#define PySwigObject_Check SwigPyObject_Check -#define PySwigObject_GetDesc SwigPyObject_GetDesc -#define PySwigObject_New SwigPyObject_New -#define PySwigObject_acquire SwigPyObject_acquire -#define PySwigObject_append SwigPyObject_append -#define PySwigObject_as_number SwigPyObject_as_number -#define PySwigObject_compare SwigPyObject_compare -#define PySwigObject_dealloc SwigPyObject_dealloc -#define PySwigObject_disown SwigPyObject_disown -#define PySwigObject_format SwigPyObject_format -#define PySwigObject_getattr SwigPyObject_getattr -#define PySwigObject_hex SwigPyObject_hex -#define PySwigObject_long SwigPyObject_long -#define PySwigObject_next SwigPyObject_next -#define PySwigObject_oct SwigPyObject_oct -#define PySwigObject_own SwigPyObject_own -#define PySwigObject_print SwigPyObject_print -#define PySwigObject_repr SwigPyObject_repr -#define PySwigObject_richcompare SwigPyObject_richcompare -#define PySwigObject_str SwigPyObject_str -#define PySwigObject_type SwigPyObject_type -#define PySwigPacked SwigPyPacked -#define PySwigPacked_Check SwigPyPacked_Check -#define PySwigPacked_New SwigPyPacked_New -#define PySwigPacked_UnpackData SwigPyPacked_UnpackData -#define PySwigPacked_compare SwigPyPacked_compare -#define PySwigPacked_dealloc SwigPyPacked_dealloc -#define PySwigPacked_print SwigPyPacked_print -#define PySwigPacked_repr SwigPyPacked_repr -#define PySwigPacked_str SwigPyPacked_str -#define PySwigPacked_type SwigPyPacked_type -#define pyseq swigpyseq -#define pyswigobject_type swigpyobject_type -#define pyswigpacked_type swigpypacked_type -%} diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg index 30775b84e..76f1e6789 100644 --- a/Lib/python/pyopers.swg +++ b/Lib/python/pyopers.swg @@ -33,12 +33,6 @@ /* Special cases */ %rename(__invert__) *::operator~; %rename(__call__) *::operator(); - -%feature("shadow") *::operator bool %{ -def __nonzero__(self): - return $action(self) -__bool__ = __nonzero__ -%}; %rename(__nonzero__) *::operator bool; /* Ignored operators */ @@ -90,7 +84,7 @@ __bool__ = __nonzero__ */ -#define %pyinplaceoper(SwigPyOper, Oper) %delobject Oper; %newobject Oper; %rename(SwigPyOper) Oper +#define %pyinplaceoper(PyOper, Oper) %delobject Oper; %newobject Oper; %rename(PyOper) Oper %pyinplaceoper(__iadd__ , *::operator +=); %pyinplaceoper(__isub__ , *::operator -=); diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg index 5a1b1230e..844a66bec 100644 --- a/Lib/python/pyrun.swg +++ b/Lib/python/pyrun.swg @@ -42,7 +42,7 @@ #define SWIG_GetModule(clientdata) SWIG_Python_GetModule() #define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) +#define SWIG_NewClientData(obj) PySwigClientData_New(obj) #define SWIG_SetErrorObj SWIG_Python_SetErrorObj #define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg @@ -238,7 +238,7 @@ SWIG_Py_Void(void) return none; } -/* SwigPyClientData */ +/* PySwigClientData */ typedef struct { PyObject *klass; @@ -247,30 +247,30 @@ typedef struct { PyObject *destroy; int delargs; int implicitconv; -} SwigPyClientData; +} PySwigClientData; SWIGRUNTIMEINLINE int SWIG_Python_CheckImplicit(swig_type_info *ty) { - SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; + PySwigClientData *data = (PySwigClientData *)ty->clientdata; return data ? data->implicitconv : 0; } SWIGRUNTIMEINLINE PyObject * SWIG_Python_ExceptionType(swig_type_info *desc) { - SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; + PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; PyObject *klass = data ? data->klass : 0; return (klass ? klass : PyExc_RuntimeError); } -SWIGRUNTIME SwigPyClientData * -SwigPyClientData_New(PyObject* obj) +SWIGRUNTIME PySwigClientData * +PySwigClientData_New(PyObject* obj) { if (!obj) { return 0; } else { - SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); + PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); /* the klass element */ data->klass = obj; Py_INCREF(data->klass); @@ -318,14 +318,14 @@ SwigPyClientData_New(PyObject* obj) } SWIGRUNTIME void -SwigPyClientData_Del(SwigPyClientData* data) +PySwigClientData_Del(PySwigClientData* data) { Py_XDECREF(data->newraw); Py_XDECREF(data->newargs); Py_XDECREF(data->destroy); } -/* =============== SwigPyObject =====================*/ +/* =============== PySwigObject =====================*/ typedef struct { PyObject_HEAD @@ -333,28 +333,24 @@ typedef struct { swig_type_info *ty; int own; PyObject *next; -} SwigPyObject; +} PySwigObject; SWIGRUNTIME PyObject * -SwigPyObject_long(SwigPyObject *v) +PySwigObject_long(PySwigObject *v) { return PyLong_FromVoidPtr(v->ptr); } SWIGRUNTIME PyObject * -SwigPyObject_format(const char* fmt, SwigPyObject *v) +PySwigObject_format(const char* fmt, PySwigObject *v) { PyObject *res = NULL; PyObject *args = PyTuple_New(1); if (args) { - if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { - PyObject *ofmt = SWIG_Python_str_FromChar(fmt); + if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { + PyObject *ofmt = PyString_FromString(fmt); if (ofmt) { -#if PY_VERSION_HEX >= 0x03000000 - res = PyUnicode_Format(ofmt,args); -#else res = PyString_Format(ofmt,args); -#endif Py_DECREF(ofmt); } Py_DECREF(args); @@ -364,59 +360,49 @@ SwigPyObject_format(const char* fmt, SwigPyObject *v) } SWIGRUNTIME PyObject * -SwigPyObject_oct(SwigPyObject *v) +PySwigObject_oct(PySwigObject *v) { - return SwigPyObject_format("%o",v); + return PySwigObject_format("%o",v); } SWIGRUNTIME PyObject * -SwigPyObject_hex(SwigPyObject *v) +PySwigObject_hex(PySwigObject *v) { - return SwigPyObject_format("%x",v); + return PySwigObject_format("%x",v); } SWIGRUNTIME PyObject * #ifdef METH_NOARGS -SwigPyObject_repr(SwigPyObject *v) +PySwigObject_repr(PySwigObject *v) #else -SwigPyObject_repr(SwigPyObject *v, PyObject *args) +PySwigObject_repr(PySwigObject *v, PyObject *args) #endif { const char *name = SWIG_TypePrettyName(v->ty); - PyObject *hex = SwigPyObject_hex(v); - PyObject *repr = SWIG_Python_str_FromFormat("", name, hex); + PyObject *hex = PySwigObject_hex(v); + PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); Py_DECREF(hex); if (v->next) { #ifdef METH_NOARGS - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); + PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); #else - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); + PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); #endif -#if PY_VERSION_HEX >= 0x03000000 - PyObject *joined = PyUnicode_Concat(repr, nrep); - Py_DecRef(repr); - Py_DecRef(nrep); - repr = joined; -#else PyString_ConcatAndDel(&repr,nrep); -#endif } return repr; } SWIGRUNTIME int -SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { - char *str; #ifdef METH_NOARGS - PyObject *repr = SwigPyObject_repr(v); + PyObject *repr = PySwigObject_repr(v); #else - PyObject *repr = SwigPyObject_repr(v, NULL); + PyObject *repr = PySwigObject_repr(v, NULL); #endif if (repr) { - str = SWIG_Python_str_AsChar(repr); - fputs(str, fp); - SWIG_Python_str_DelForPy3(str); + fputs(PyString_AsString(repr), fp); Py_DECREF(repr); return 0; } else { @@ -425,71 +411,53 @@ SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) } SWIGRUNTIME PyObject * -SwigPyObject_str(SwigPyObject *v) +PySwigObject_str(PySwigObject *v) { char result[SWIG_BUFFER_SIZE]; return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - SWIG_Python_str_FromChar(result) : 0; + PyString_FromString(result) : 0; } SWIGRUNTIME int -SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) +PySwigObject_compare(PySwigObject *v, PySwigObject *w) { void *i = v->ptr; void *j = w->ptr; return (i < j) ? -1 : ((i > j) ? 1 : 0); } -/* Added for Python 3.x, whould it also useful for Python 2.x? */ -SWIGRUNTIME PyObject* -SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) -{ - PyObject* res; - if( op != Py_EQ && op != Py_NE ) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - if( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ) - res = Py_True; - else - res = Py_False; - Py_INCREF(res); - return res; -} - - SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); SWIGRUNTIME PyTypeObject* -SwigPyObject_type(void) { +PySwigObject_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); return type; } SWIGRUNTIMEINLINE int -SwigPyObject_Check(PyObject *op) { - return (Py_TYPE(op) == SwigPyObject_type()) - || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); +PySwigObject_Check(PyObject *op) { + return ((op)->ob_type == PySwigObject_type()) + || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); } SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own); +PySwigObject_New(void *ptr, swig_type_info *ty, int own); SWIGRUNTIME void -SwigPyObject_dealloc(PyObject *v) +PySwigObject_dealloc(PyObject *v) { - SwigPyObject *sobj = (SwigPyObject *) v; + PySwigObject *sobj = (PySwigObject *) v; PyObject *next = sobj->next; if (sobj->own == SWIG_POINTER_OWN) { swig_type_info *ty = sobj->ty; - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; PyObject *destroy = data ? data->destroy : 0; if (destroy) { /* destroy is always a VARARGS method */ PyObject *res; if (data->delargs) { /* we need to create a temporal object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); + PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); res = SWIG_Python_CallFunctor(destroy, tmp); Py_DECREF(tmp); } else { @@ -511,15 +479,15 @@ SwigPyObject_dealloc(PyObject *v) } SWIGRUNTIME PyObject* -SwigPyObject_append(PyObject* v, PyObject* next) +PySwigObject_append(PyObject* v, PyObject* next) { - SwigPyObject *sobj = (SwigPyObject *) v; + PySwigObject *sobj = (PySwigObject *) v; #ifndef METH_O PyObject *tmp = 0; if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; next = tmp; #endif - if (!SwigPyObject_Check(next)) { + if (!PySwigObject_Check(next)) { return NULL; } sobj->next = next; @@ -529,12 +497,12 @@ SwigPyObject_append(PyObject* v, PyObject* next) SWIGRUNTIME PyObject* #ifdef METH_NOARGS -SwigPyObject_next(PyObject* v) +PySwigObject_next(PyObject* v) #else -SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { - SwigPyObject *sobj = (SwigPyObject *) v; + PySwigObject *sobj = (PySwigObject *) v; if (sobj->next) { Py_INCREF(sobj->next); return sobj->next; @@ -545,30 +513,30 @@ SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) SWIGINTERN PyObject* #ifdef METH_NOARGS -SwigPyObject_disown(PyObject *v) +PySwigObject_disown(PyObject *v) #else -SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { - SwigPyObject *sobj = (SwigPyObject *)v; + PySwigObject *sobj = (PySwigObject *)v; sobj->own = 0; return SWIG_Py_Void(); } SWIGINTERN PyObject* #ifdef METH_NOARGS -SwigPyObject_acquire(PyObject *v) +PySwigObject_acquire(PyObject *v) #else -SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) +PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) #endif { - SwigPyObject *sobj = (SwigPyObject *)v; + PySwigObject *sobj = (PySwigObject *)v; sobj->own = SWIG_POINTER_OWN; return SWIG_Py_Void(); } SWIGINTERN PyObject* -SwigPyObject_own(PyObject *v, PyObject *args) +PySwigObject_own(PyObject *v, PyObject *args) { PyObject *val = 0; #if (PY_VERSION_HEX < 0x02020000) @@ -581,20 +549,20 @@ SwigPyObject_own(PyObject *v, PyObject *args) } else { - SwigPyObject *sobj = (SwigPyObject *)v; + PySwigObject *sobj = (PySwigObject *)v; PyObject *obj = PyBool_FromLong(sobj->own); if (val) { #ifdef METH_NOARGS if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v); + PySwigObject_acquire(v); } else { - SwigPyObject_disown(v); + PySwigObject_disown(v); } #else if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v,args); + PySwigObject_acquire(v,args); } else { - SwigPyObject_disown(v,args); + PySwigObject_disown(v,args); } #endif } @@ -605,30 +573,30 @@ SwigPyObject_own(PyObject *v, PyObject *args) #ifdef METH_O static PyMethodDef swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, + {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #else static PyMethodDef swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, + {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, + {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, + {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, + {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, + {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, + {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, {0, 0, 0, 0} }; #endif #if PY_VERSION_HEX < 0x02020000 SWIGINTERN PyObject * -SwigPyObject_getattr(SwigPyObject *sobj,char *name) +PySwigObject_getattr(PySwigObject *sobj,char *name) { return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); } @@ -638,14 +606,11 @@ SWIGRUNTIME PyTypeObject* _PySwigObject_type(void) { static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyNumberMethods SwigPyObject_as_number = { + static PyNumberMethods PySwigObject_as_number = { (binaryfunc)0, /*nb_add*/ (binaryfunc)0, /*nb_subtract*/ (binaryfunc)0, /*nb_multiply*/ - /* nb_divide removed in Python 3 */ -#if PY_VERSION_HEX < 0x03000000 (binaryfunc)0, /*nb_divide*/ -#endif (binaryfunc)0, /*nb_remainder*/ (binaryfunc)0, /*nb_divmod*/ (ternaryfunc)0,/*nb_power*/ @@ -659,23 +624,13 @@ _PySwigObject_type(void) { 0, /*nb_and*/ 0, /*nb_xor*/ 0, /*nb_or*/ -#if PY_VERSION_HEX < 0x03000000 - 0, /*nb_coerce*/ -#endif - (unaryfunc)SwigPyObject_long, /*nb_int*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_long, /*nb_long*/ -#else - 0, /*nb_reserved*/ -#endif + (coercion)0, /*nb_coerce*/ + (unaryfunc)PySwigObject_long, /*nb_int*/ + (unaryfunc)PySwigObject_long, /*nb_long*/ (unaryfunc)0, /*nb_float*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_oct, /*nb_oct*/ - (unaryfunc)SwigPyObject_hex, /*nb_hex*/ -#endif -#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ -#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ + (unaryfunc)PySwigObject_oct, /*nb_oct*/ + (unaryfunc)PySwigObject_hex, /*nb_hex*/ +#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ #elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ @@ -684,41 +639,32 @@ _PySwigObject_type(void) { #endif }; - static PyTypeObject swigpyobject_type; + static PyTypeObject pyswigobject_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { - /* PyOjbect header changed in Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else PyObject_HEAD_INIT(NULL) 0, /* ob_size */ -#endif - (char *)"SwigPyObject", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ + (char *)"PySwigObject", /* tp_name */ + sizeof(PySwigObject), /* tp_basicsize */ 0, /* tp_itemsize */ - (destructor)SwigPyObject_dealloc, /* tp_dealloc */ - (printfunc)SwigPyObject_print, /* tp_print */ + (destructor)PySwigObject_dealloc, /* tp_dealloc */ + (printfunc)PySwigObject_print, /* tp_print */ #if PY_VERSION_HEX < 0x02020000 - (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ + (getattrfunc)PySwigObject_getattr, /* tp_getattr */ #else (getattrfunc)0, /* tp_getattr */ #endif (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_reserved in 3.0.1 */ -#else - (cmpfunc)SwigPyObject_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyObject_repr, /* tp_repr */ - &SwigPyObject_as_number, /* tp_as_number */ + (cmpfunc)PySwigObject_compare, /* tp_compare */ + (reprfunc)PySwigObject_repr, /* tp_repr */ + &PySwigObject_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ (hashfunc)0, /* tp_hash */ (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyObject_str, /* tp_str */ + (reprfunc)PySwigObject_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -726,7 +672,7 @@ _PySwigObject_type(void) { swigobject_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - (richcmpfunc)SwigPyObject_richcompare, /* tp_richcompare */ + 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ #if PY_VERSION_HEX >= 0x02020000 0, /* tp_iter */ @@ -743,11 +689,11 @@ _PySwigObject_type(void) { 0, /* tp_alloc */ 0, /* tp_new */ 0, /* tp_free */ - 0, /* tp_is_gc */ + 0, /* tp_is_gc */ 0, /* tp_bases */ 0, /* tp_mro */ 0, /* tp_cache */ - 0, /* tp_subclasses */ + 0, /* tp_subclasses */ 0, /* tp_weaklist */ #endif #if PY_VERSION_HEX >= 0x02030000 @@ -757,20 +703,17 @@ _PySwigObject_type(void) { 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; - swigpyobject_type = tmp; - /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ -#if PY_VERSION_HEX < 0x03000000 - swigpyobject_type.ob_type = &PyType_Type; -#endif + pyswigobject_type = tmp; + pyswigobject_type.ob_type = &PyType_Type; type_init = 1; } - return &swigpyobject_type; + return &pyswigobject_type; } SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own) +PySwigObject_New(void *ptr, swig_type_info *ty, int own) { - SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); + PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); if (sobj) { sobj->ptr = ptr; sobj->ty = ty; @@ -789,10 +732,10 @@ typedef struct { void *pack; swig_type_info *ty; size_t size; -} SwigPyPacked; +} PySwigPacked; SWIGRUNTIME int -SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) +PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) { char result[SWIG_BUFFER_SIZE]; fputs("pack, v->size, 0, sizeof(result))) { - return SWIG_Python_str_FromFormat("", result, v->ty->name); + return PyString_FromFormat("", result, v->ty->name); } else { - return SWIG_Python_str_FromFormat("", v->ty->name); + return PyString_FromFormat("", v->ty->name); } } SWIGRUNTIME PyObject * -SwigPyPacked_str(SwigPyPacked *v) +PySwigPacked_str(PySwigPacked *v) { char result[SWIG_BUFFER_SIZE]; if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); + return PyString_FromFormat("%s%s", result, v->ty->name); } else { - return SWIG_Python_str_FromChar(v->ty->name); + return PyString_FromString(v->ty->name); } } SWIGRUNTIME int -SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) +PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) { size_t i = v->size; size_t j = w->size; @@ -839,22 +782,22 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); SWIGRUNTIME PyTypeObject* -SwigPyPacked_type(void) { +PySwigPacked_type(void) { static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); return type; } SWIGRUNTIMEINLINE int -SwigPyPacked_Check(PyObject *op) { +PySwigPacked_Check(PyObject *op) { return ((op)->ob_type == _PySwigPacked_type()) - || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); + || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); } SWIGRUNTIME void -SwigPyPacked_dealloc(PyObject *v) +PySwigPacked_dealloc(PyObject *v) { - if (SwigPyPacked_Check(v)) { - SwigPyPacked *sobj = (SwigPyPacked *) v; + if (PySwigPacked_Check(v)) { + PySwigPacked *sobj = (PySwigPacked *) v; free(sobj->pack); } PyObject_DEL(v); @@ -863,37 +806,28 @@ SwigPyPacked_dealloc(PyObject *v) SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void) { static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject swigpypacked_type; + static PyTypeObject pyswigpacked_type; static int type_init = 0; if (!type_init) { const PyTypeObject tmp = { - /* PyObject header changed in Python 3 */ -#if PY_VERSION_HEX>=0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - (char *)"SwigPyPacked", /* tp_name */ - sizeof(SwigPyPacked), /* tp_basicsize */ + 0, /* ob_size */ + (char *)"PySwigPacked", /* tp_name */ + sizeof(PySwigPacked), /* tp_basicsize */ 0, /* tp_itemsize */ - (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ - (printfunc)SwigPyPacked_print, /* tp_print */ + (destructor)PySwigPacked_dealloc, /* tp_dealloc */ + (printfunc)PySwigPacked_print, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX>=0x03000000 - 0, /* tp_reserved in 3.0.1 */ -#else - (cmpfunc)SwigPyPacked_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ + (cmpfunc)PySwigPacked_compare, /* tp_compare */ + (reprfunc)PySwigPacked_repr, /* tp_repr */ + 0, /* tp_as_number */ 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyPacked_str, /* tp_str */ + 0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)PySwigPacked_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ @@ -932,20 +866,17 @@ _PySwigPacked_type(void) { 0,0,0,0 /* tp_alloc -> tp_next */ #endif }; - swigpypacked_type = tmp; - /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */ -#if PY_VERSION_HEX < 0x03000000 - swigpypacked_type.ob_type = &PyType_Type; -#endif + pyswigpacked_type = tmp; + pyswigpacked_type.ob_type = &PyType_Type; type_init = 1; } - return &swigpypacked_type; + return &pyswigpacked_type; } SWIGRUNTIME PyObject * -SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) +PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) { - SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); + PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); if (sobj) { void *pack = malloc(size); if (pack) { @@ -962,10 +893,10 @@ SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) } SWIGRUNTIME swig_type_info * -SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) +PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) { - if (SwigPyPacked_Check(obj)) { - SwigPyPacked *sobj = (SwigPyPacked *)obj; + if (PySwigPacked_Check(obj)) { + PySwigPacked *sobj = (PySwigPacked *)obj; if (sobj->size != size) return 0; memcpy(ptr, sobj->pack, size); return sobj->ty; @@ -981,7 +912,7 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) SWIGRUNTIMEINLINE PyObject * _SWIG_This(void) { - return SWIG_Python_str_FromChar("this"); + return PyString_FromString("this"); } SWIGRUNTIME PyObject * @@ -993,16 +924,11 @@ SWIG_This(void) /* #define SWIG_PYTHON_SLOW_GETSET_THIS */ -/* TODO: I don't know how to implement the fast getset in Python 3 right now */ -#if PY_VERSION_HEX>=0x03000000 -#define SWIG_PYTHON_SLOW_GETSET_THIS -#endif - -SWIGRUNTIME SwigPyObject * +SWIGRUNTIME PySwigObject * SWIG_Python_GetSwigThis(PyObject *pyobj) { - if (SwigPyObject_Check(pyobj)) { - return (SwigPyObject *) pyobj; + if (PySwigObject_Check(pyobj)) { + return (PySwigObject *) pyobj; } else { PyObject *obj = 0; #if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) @@ -1038,12 +964,12 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) return 0; } #endif - if (obj && !SwigPyObject_Check(obj)) { + if (obj && !PySwigObject_Check(obj)) { /* a PyObject is called 'this', try to get the 'real this' - SwigPyObject from it */ + PySwigObject from it */ return SWIG_Python_GetSwigThis(obj); } - return (SwigPyObject *)obj; + return (PySwigObject *)obj; } } @@ -1052,7 +978,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj) SWIGRUNTIME int SWIG_Python_AcquirePtr(PyObject *obj, int own) { if (own == SWIG_POINTER_OWN) { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); + PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); if (sobj) { int oldown = sobj->own; sobj->own = own; @@ -1071,7 +997,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int if (ptr) *ptr = 0; return SWIG_OK; } else { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); + PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); if (own) *own = 0; while (sobj) { @@ -1085,7 +1011,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } else { swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); if (!tc) { - sobj = (SwigPyObject *)sobj->next; + sobj = (PySwigObject *)sobj->next; } else { if (ptr) { int newmemory = 0; @@ -1114,7 +1040,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int } else { int res = SWIG_ERROR; if (flags & SWIG_POINTER_IMPLICIT_CONV) { - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; + PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; if (data && !data->implicitconv) { PyObject *klass = data->klass; if (klass) { @@ -1127,7 +1053,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int impconv = 0; } if (impconv) { - SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); + PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); if (iobj) { void *vptr; res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); @@ -1189,7 +1115,7 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { SWIGRUNTIME int SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); + swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); if (!to) return SWIG_ERROR; if (ty) { if (to != ty) { @@ -1211,7 +1137,7 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t */ SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) +SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) { #if (PY_VERSION_HEX >= 0x02020000) PyObject *inst = 0; @@ -1235,16 +1161,10 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) #endif } } else { -#if PY_VERSION_HEX >= 0x03000000 - inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; -#else PyObject *dict = PyDict_New(); PyDict_SetItem(dict, SWIG_This(), swig_this); inst = PyInstance_NewRaw(data->newargs, dict); Py_DECREF(dict); -#endif } return inst; #else @@ -1307,9 +1227,9 @@ SWIG_Python_InitShadowInstance(PyObject *args) { if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { return NULL; } else { - SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); + PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); if (sthis) { - SwigPyObject_append((PyObject*) sthis, obj[1]); + PySwigObject_append((PyObject*) sthis, obj[1]); } else { SWIG_Python_SetSwigThis(obj[0], obj[1]); } @@ -1325,8 +1245,8 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { return SWIG_Py_Void(); } else { int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - PyObject *robj = SwigPyObject_New(ptr, type, own); - SwigPyClientData *clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; + PyObject *robj = PySwigObject_New(ptr, type, own); + PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); if (inst) { @@ -1342,7 +1262,7 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { SWIGRUNTIMEINLINE PyObject * SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); + return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); } /* -----------------------------------------------------------------------------* @@ -1413,8 +1333,8 @@ SWIG_Python_DestroyModule(void *vptr) for (i =0; i < swig_module->size; ++i) { swig_type_info *ty = types[i]; if (ty->owndata) { - SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; - if (data) SwigPyClientData_Del(data); + PySwigClientData *data = (PySwigClientData *) ty->clientdata; + if (data) PySwigClientData_Del(data); } } Py_DECREF(SWIG_This()); @@ -1424,13 +1344,8 @@ SWIGRUNTIME void SWIG_Python_SetModule(swig_module_info *swig_module) { static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ -#if PY_VERSION_HEX >= 0x03000000 - /* Add a dummy module object into sys.modules */ - PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); -#else PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table); -#endif PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); if (pointer && module) { PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); @@ -1450,7 +1365,7 @@ SWIGRUNTIME swig_type_info * SWIG_Python_TypeQuery(const char *type) { PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = SWIG_Python_str_FromChar(type); + PyObject *key = PyString_FromString(type); PyObject *obj = PyDict_GetItem(cache, key); swig_type_info *descriptor; if (obj) { @@ -1477,23 +1392,21 @@ SWIG_Python_TypeQuery(const char *type) SWIGRUNTIME int SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ +{ if (PyErr_Occurred()) { PyObject *type = 0; PyObject *value = 0; PyObject *traceback = 0; PyErr_Fetch(&type, &value, &traceback); if (value) { - char *tmp; PyObject *old_str = PyObject_Str(value); Py_XINCREF(type); PyErr_Clear(); if (infront) { - PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); + PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); } else { - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); + PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); } - SWIG_Python_str_DelForPy3(tmp); Py_DECREF(old_str); } return 1; @@ -1516,9 +1429,9 @@ SWIG_Python_ArgFail(int argnum) } SWIGRUNTIMEINLINE const char * -SwigPyObject_GetDesc(PyObject *self) +PySwigObject_GetDesc(PyObject *self) { - SwigPyObject *v = (SwigPyObject *)self; + PySwigObject *v = (PySwigObject *)self; swig_type_info *ty = v ? v->ty : 0; return ty ? ty->str : (char*)""; } @@ -1528,10 +1441,10 @@ SWIG_Python_TypeError(const char *type, PyObject *obj) { if (type) { #if defined(SWIG_COBJECT_TYPES) - if (obj && SwigPyObject_Check(obj)) { - const char *otype = (const char *) SwigPyObject_GetDesc(obj); + if (obj && PySwigObject_Check(obj)) { + const char *otype = (const char *) PySwigObject_GetDesc(obj); if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", + PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", type, otype); return; } @@ -1541,11 +1454,10 @@ SWIG_Python_TypeError(const char *type, PyObject *obj) const char *otype = (obj ? obj->ob_type->tp_name : 0); if (otype) { PyObject *str = PyObject_Str(obj); - const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; + const char *cstr = str ? PyString_AsString(str) : 0; if (cstr) { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", type, otype, cstr); - SWIG_Python_str_DelForPy3(cstr); } else { PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", type, otype); @@ -1567,12 +1479,10 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) void *result; if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { PyErr_Clear(); -#if SWIG_POINTER_EXCEPTION - if (flags) { + if (flags & SWIG_POINTER_EXCEPTION) { SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); SWIG_Python_ArgFail(argnum); } -#endif } return result; } diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg index 7e9720cc0..48b1fdcd5 100644 --- a/Lib/python/pystdcommon.swg +++ b/Lib/python/pystdcommon.swg @@ -46,7 +46,7 @@ namespace swig { struct traits_asptr { static int asptr(PyObject *obj, Type **val) { Type *p; - int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); + int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0; if (SWIG_IsOK(res)) { if (val) *val = p; } diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg index 1983037a5..d4d60c42b 100644 --- a/Lib/python/pystrings.swg +++ b/Lib/python/pystrings.swg @@ -5,28 +5,10 @@ SWIGINTERN int SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) { -%#if PY_VERSION_HEX>=0x03000000 - if (PyUnicode_Check(obj)) -%#else - if (PyString_Check(obj)) -%#endif - { + if (PyString_Check(obj)) { char *cstr; Py_ssize_t len; -%#if PY_VERSION_HEX>=0x03000000 - if (!alloc && cptr) { - /* We can't allow converting without allocation, since the internal - representation of string in Python 3 is UCS-2/UCS-4 but we require - a UTF-8 representation. - TODO(bhy) More detailed explanation */ - return SWIG_RuntimeError; - } - obj = PyUnicode_AsUTF8String(obj); - PyBytes_AsStringAndSize(obj, &cstr, &len); - if(alloc) *alloc = SWIG_NEWOBJ; -%#else PyString_AsStringAndSize(obj, &cstr, &len); -%#endif - if (cptr) { + if (cptr) { if (alloc) { /* In python the user should not be able to modify the inner @@ -51,16 +33,10 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc) *alloc = SWIG_OLDOBJ; } } else { - %#if PY_VERSION_HEX>=0x03000000 - assert(0); /* Should never reach here in Python 3 */ - %#endif - *cptr = SWIG_Python_str_AsChar(obj); + *cptr = PyString_AsString(obj); } } if (psize) *psize = len + 1; -%#if PY_VERSION_HEX>=0x03000000 - Py_XDECREF(obj); -%#endif return SWIG_OK; } else { swig_type_info* pchar_descriptor = SWIG_pchar_descriptor(); @@ -88,11 +64,7 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size) return pchar_descriptor ? SWIG_NewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void(); } else { -%#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int)); -%#else return PyString_FromStringAndSize(carray, %numeric_cast(size,int)); -%#endif } } else { return SWIG_Py_Void(); diff --git a/Lib/python/pytypemaps.swg b/Lib/python/pytypemaps.swg index e8df069ef..2d0aa576c 100644 --- a/Lib/python/pytypemaps.swg +++ b/Lib/python/pytypemaps.swg @@ -88,7 +88,7 @@ if ($result) { PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL); if (robj && !PyErr_Occurred()) { - SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result), + PySwigObject_append((PyObject *) SWIG_Python_GetSwigThis($result), (PyObject *) SWIG_Python_GetSwigThis(robj)); Py_DECREF(robj); } diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg index 7c36f248d..8254bf8f7 100644 --- a/Lib/python/pywstrings.swg +++ b/Lib/python/pywstrings.swg @@ -8,16 +8,14 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc) { PyObject *tmp = 0; int isunicode = PyUnicode_Check(obj); -%#if PY_VERSION_HEX < 0x03000000 if (!isunicode && PyString_Check(obj)) { if (cptr) { obj = tmp = PyUnicode_FromObject(obj); } isunicode = 1; } -%#endif if (isunicode) { - Py_ssize_t len = PyUnicode_GetSize(obj); + int len = PyUnicode_GetSize(obj); if (cptr) { *cptr = %new_array(len + 1, wchar_t); PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len); diff --git a/Lib/python/std_carray.i b/Lib/python/std_carray.i index 680d67115..2e40757f2 100644 --- a/Lib/python/std_carray.i +++ b/Lib/python/std_carray.i @@ -17,7 +17,7 @@ namespace swig { %extend std::carray { %fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header", - fragment="SwigPyIterator_T", + fragment="PySwigIterator_T", fragment=SWIG_Traits_frag(_Type), fragment="StdCarrayTraits") { namespace swig { @@ -36,7 +36,7 @@ namespace swig { %typemap(out,noblock=1) iterator, const_iterator { $result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1), - swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN); + swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN); } inline size_t __len__() const { return self->size(); } @@ -46,7 +46,7 @@ namespace swig { inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; } - swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) { + swig::PySwigIterator* __iter__(PyObject **PYTHON_SELF) { return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } } diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i index c93ffe61b..12dc23ccf 100644 --- a/Lib/python/std_map.i +++ b/Lib/python/std_map.i @@ -5,12 +5,12 @@ %fragment("StdMapTraits","header",fragment="StdSequenceTraits") { namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::map *map) { + assign(const PySeq& pyseq, std::map *map) { typedef typename std::map::value_type value_type; - typename SwigPySeq::const_iterator it = swigpyseq.begin(); - for (;it != swigpyseq.end(); ++it) { + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { map->insert(value_type(it->first, it->second)); } } @@ -21,11 +21,7 @@ static int asptr(PyObject *obj, map_type **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { - SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); -%#if PY_VERSION_HEX >= 0x03000000 - /* In Python 3.x the ".items()" method return a dict_items object */ - items = PySequence_Fast(items, ".items() havn't returned a sequence!"); -%#endif + PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL); res = traits_asptr_stdseq, std::pair >::asptr(items, val); } else { map_type *p; @@ -58,8 +54,8 @@ } PyObject *obj = PyDict_New(); for (const_iterator i= map.begin(); i!= map.end(); ++i) { - swig::SwigVar_PyObject key = swig::from(i->first); - swig::SwigVar_PyObject val = swig::from(i->second); + swig::PyObject_var key = swig::from(i->first); + swig::PyObject_var val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; @@ -90,10 +86,10 @@ }; template - struct SwigPyMapIterator_T : SwigPyIteratorClosed_T + struct PyMapIterator_T : PySwigIteratorClosed_T { - SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyIteratorClosed_T(curr, first, last, seq) + PyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : PySwigIteratorClosed_T(curr, first, last, seq) { } }; @@ -101,37 +97,37 @@ template > - struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T + struct PyMapKeyIterator_T : PyMapIterator_T { - SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapIterator_T(curr, first, last, seq) + PyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : PyMapIterator_T(curr, first, last, seq) { } }; template - inline SwigPyIterator* + inline PySwigIterator* make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { - return new SwigPyMapKeyIterator_T(current, begin, end, seq); + return new PyMapKeyIterator_T(current, begin, end, seq); } template > - struct SwigPyMapValueITerator_T : SwigPyMapIterator_T + struct PyMapValueIterator_T : PyMapIterator_T { - SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) - : SwigPyMapIterator_T(curr, first, last, seq) + PyMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq) + : PyMapIterator_T(curr, first, last, seq) { } }; template - inline SwigPyIterator* + inline PySwigIterator* make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0) { - return new SwigPyMapValueITerator_T(current, begin, end, seq); + return new PyMapValueIterator_T(current, begin, end, seq); } } } @@ -222,12 +218,12 @@ } %newobject key_iterator(PyObject **PYTHON_SELF); - swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) { + swig::PySwigIterator* key_iterator(PyObject **PYTHON_SELF) { return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } %newobject value_iterator(PyObject **PYTHON_SELF); - swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) { + swig::PySwigIterator* value_iterator(PyObject **PYTHON_SELF) { return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF); } diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i index 58336bc4b..f923af06b 100644 --- a/Lib/python/std_multimap.i +++ b/Lib/python/std_multimap.i @@ -6,12 +6,12 @@ %fragment("StdMultimapTraits","header",fragment="StdSequenceTraits") { namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::multimap *multimap) { + assign(const PySeq& pyseq, std::multimap *multimap) { typedef typename std::multimap::value_type value_type; - typename SwigPySeq::const_iterator it = swigpyseq.begin(); - for (;it != swigpyseq.end(); ++it) { + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { multimap->insert(value_type(it->first, it->second)); } } @@ -22,7 +22,7 @@ static int asptr(PyObject *obj, std::multimap **val) { int res = SWIG_ERROR; if (PyDict_Check(obj)) { - SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL); + PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL); return traits_asptr_stdseq, std::pair >::asptr(items, val); } else { multimap_type *p; @@ -55,8 +55,8 @@ } PyObject *obj = PyDict_New(); for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) { - swig::SwigVar_PyObject key = swig::from(i->first); - swig::SwigVar_PyObject val = swig::from(i->second); + swig::PyObject_var key = swig::from(i->first); + swig::PyObject_var val = swig::from(i->second); PyDict_SetItem(obj, key, val); } return obj; diff --git a/Lib/python/std_multiset.i b/Lib/python/std_multiset.i index ac430334c..35a689026 100644 --- a/Lib/python/std_multiset.i +++ b/Lib/python/std_multiset.i @@ -7,13 +7,13 @@ %fragment("StdMultisetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::multiset* seq) { - // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented - typedef typename SwigPySeq::value_type value_type; - typename SwigPySeq::const_iterator it = swigpyseq.begin(); - for (;it != swigpyseq.end(); ++it) { + assign(const PySeq& pyseq, std::multiset* seq) { + // seq->insert(pyseq.begin(), pyseq.end()); // not used as not always implemented + typedef typename PySeq::value_type value_type; + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i index bc8ccaade..673e85eef 100644 --- a/Lib/python/std_pair.i +++ b/Lib/python/std_pair.i @@ -42,8 +42,8 @@ } } else if (PySequence_Check(obj)) { if (PySequence_Size(obj) == 2) { - swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); - swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); + swig::PyObject_var first = PySequence_GetItem(obj,0); + swig::PyObject_var second = PySequence_GetItem(obj,1); res = get_pair(first, second, val); } } else { @@ -92,8 +92,8 @@ } } else if (PySequence_Check(obj)) { if (PySequence_Size(obj) == 2) { - swig::SwigVar_PyObject first = PySequence_GetItem(obj,0); - swig::SwigVar_PyObject second = PySequence_GetItem(obj,1); + swig::PyObject_var first = PySequence_GetItem(obj,0); + swig::PyObject_var second = PySequence_GetItem(obj,1); res = get_pair(first, second, val); } } else { diff --git a/Lib/python/std_set.i b/Lib/python/std_set.i index 59f69cdc9..94ef667e2 100644 --- a/Lib/python/std_set.i +++ b/Lib/python/std_set.i @@ -5,13 +5,13 @@ %fragment("StdSetTraits","header",fragment="StdSequenceTraits") %{ namespace swig { - template + template inline void - assign(const SwigPySeq& swigpyseq, std::set* seq) { - // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented - typedef typename SwigPySeq::value_type value_type; - typename SwigPySeq::const_iterator it = swigpyseq.begin(); - for (;it != swigpyseq.end(); ++it) { + assign(const PySeq& pyseq, std::set* seq) { + // seq->insert(pyseq.begin(), pyseq.end()); // not used as not always implemented + typedef typename PySeq::value_type value_type; + typename PySeq::const_iterator it = pyseq.begin(); + for (;it != pyseq.end(); ++it) { seq->insert(seq->end(),(value_type)(*it)); } } diff --git a/Lib/r/r.swg b/Lib/r/r.swg index 7fd6d761f..0ab7e11a0 100644 --- a/Lib/r/r.swg +++ b/Lib/r/r.swg @@ -55,62 +55,13 @@ SWIG_InitializeModule(0); %typemap(out) void ""; -%typemap(in) int *, int[ANY], - signed int *, signed int[ANY], - unsigned int *, unsigned int[ANY], - short *, short[ANY], - signed short *, signed short[ANY], - unsigned short *, unsigned short[ANY], - long *, long[ANY], - signed long *, signed long[ANY], - unsigned long *, unsigned long[ANY], - long long *, long long[ANY], - signed long long *, signed long long[ANY], - unsigned long long *, unsigned long long[ANY] - -{ -{ int _rswigi; - int _rswiglen = LENGTH($input); - $1 = %static_cast(calloc(sizeof($1_basetype), _rswiglen), $1_ltype); - for (_rswigi=0; _rswigi< _rswiglen; _rswigi++) { - $1[_rswigi] = INTEGER($input)[_rswigi]; - } -} -} - -%typemap(in) float *, float[ANY], - double *, double[ANY] - -{ -{ int _rswigi; - int _rswiglen = LENGTH($input); - $1 = %static_cast(calloc(sizeof($1_basetype), _rswiglen), $1_ltype); - for (_rswigi=0; _rswigi<_rswiglen; _rswigi++) { - $1[_rswigi] = REAL($input)[_rswigi]; - } -} -} - -%typemap(freearg,noblock=1) int *, int[ANY], - signed int *, signed int[ANY], - unsigned int *, unsigned int[ANY], - short *, short[ANY], - signed short *, signed short[ANY], - unsigned short *, unsigned short[ANY], - long *, long[ANY], - signed long *, signed long[ANY], - unsigned long *, unsigned long[ANY], - long long *, long long[ANY], - signed long long *, signed long long[ANY], - unsigned long long *, unsigned long long[ANY], - float *, float[ANY], - double *, double[ANY] -%{ - free($1); +%typemap(in) int *, int[ANY] %{ + $1 = INTEGER($input); %} - - +%typemap(in) double *, double[ANY] %{ + $1 = REAL($input); +%} /* Shoul dwe recycle to make the length correct. And warn if length() > the dimension. @@ -126,9 +77,9 @@ SWIG_InitializeModule(0); %} -%typemap(scheck) int, long %{ +%typemap(scheck) int %{ if(length($input) > 1) { - warning("using only the first element of $input") + Rf_warning("using only the first element of $input") } %} @@ -140,6 +91,8 @@ SWIG_InitializeModule(0); %include %include +%apply int[ANY] { enum SWIGTYPE[ANY] }; + %typemap(in,noblock=1) enum SWIGTYPE[ANY] { $1 = %reinterpret_cast(INTEGER($input), $1_ltype); } @@ -204,12 +157,11 @@ $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype); } -%typemap(in,noblock=1) int, long -{ +%typemap(in,noblock=1) int { $1 = %static_cast(INTEGER($input)[0], $1_ltype); } -%typemap(out,noblock=1) int, long +%typemap(out,noblock=1) int "$result = Rf_ScalarInteger($1);"; @@ -220,16 +172,18 @@ $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype); %typemap(out,noblock=1) bool "$result = Rf_ScalarLogical($1);"; -%typemap(in,noblock=1) +%typemap(in,noblock=1) unsigned int, + unsigned long, float, - double + double, + long { $1 = %static_cast(REAL($input)[0], $1_ltype); } -/* Why is this here ? */ -/* %typemap(out,noblock=1) unsigned int * - "$result = ScalarReal(*($1));"; */ + +%typemap(out,noblock=1) unsigned int * + "$result = ScalarReal(*($1));"; %Rruntime %{ setMethod('[', "ExternalReference", diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg index 32946c7b5..b5375c213 100644 --- a/Lib/r/rrun.swg +++ b/Lib/r/rrun.swg @@ -16,6 +16,8 @@ extern "C" { #include #include +#define SWIGR 1 + #if R_VERSION >= R_Version(2,6,0) #define VMAXTYPE void * #else diff --git a/Lib/r/rstdcommon.swg b/Lib/r/rstdcommon.swg index 56cbe2cdd..223203773 100644 --- a/Lib/r/rstdcommon.swg +++ b/Lib/r/rstdcommon.swg @@ -40,7 +40,7 @@ namespace swig { struct traits_asptr { static int asptr(SWIG_Object obj, Type **val) { Type *p; - int res = SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0); + int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0; if (SWIG_IsOK(res)) { if (val) *val = p; } diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg index d388d1eae..9206b5e3e 100644 --- a/Lib/r/rtype.swg +++ b/Lib/r/rtype.swg @@ -3,23 +3,17 @@ for use in class representations. */ -%typemap("rtype") int, int *, int & "integer"; +%typemap("rtype") int, int *, int & "numeric"; %apply int {size_t} %apply int {std::size_t} %apply int {ptrdiff_t} %apply int {std::ptrdiff_t} -%apply int {signed int} -%apply int {unsigned int} -%apply int {short} -%apply int {unsigned short} - -%typemap("rtype") long, long *, long & "integer"; -%apply long {long long} -%apply long {signed long long} -%apply long {unsigned long long} -%apply long {signed long} -%apply long {unsigned long} +%typemap("rtype") long, long * "numeric"; +%typemap("rtype") unsigned long, + unsigned long * "numeric"; +%typemap("rtype") unsigned int, + unsigned int * "numeric"; %typemap("rtype") double, double*, double & "numeric"; %typemap("rtype") float, float *, float & "numeric"; %typemap("rtype") char *, char ** "character"; @@ -41,14 +35,15 @@ INTSXP. */ -/* Force coercion of integer, since by default R sets all constants to - numeric, which means that you can't directly call a function with an - integer using an R numercal literal */ %typemap(scoercein) int, int *, int & - %{ $input = as.integer($input); %} -%typemap(scoercein) long, long *, long & - %{ $input = as.integer($input); %} + %{ $input = as($input, "integer"); %} +%typemap(scoercein) ptrdiff_t, ptrdiff_t *, ptrdiff_t & + %{ $input = as($input, "integer"); %} +%typemap(scoercein) unsigned long, unsigned long *, unsigned long & + %{ $input = as($input, "integer"); %} +%typemap(scoercein) unsigned int, unsigned int *, unsigned int & + %{ $input = as($input, "integer"); %} %typemap(scoercein) double, double *, double & %{ %} %typemap(scoercein) float, float *, float & @@ -92,16 +87,45 @@ %typemap(scoercein) bool, bool *, bool & "$input = as.logical($input) "; +/* %typemap(scoercein) int, int *, int &, int[ANY], - long, - long *, - long &, - long[ANY] + size_t, + std::size_t, + size_t &, + std::size_t & "$input = as.integer($input) "; + +%typemap(scoercein) unsigned int, + unsigned long, + double, + float, + long, + long long, + unsigned int[], + unsigned long[], + double[], + float[], + long[], + long long[], + unsigned int[ANY], + unsigned long[ANY], + double[ANY], + float[ANY], + long[ANY], + long long[ANY], + unsigned int *, + unsigned long *, + double*, + float*, + long*, + long long * +%{ $input = as.numeric($input) %} +*/ + %typemap(scoercein) char *, string, std::string, string &, std::string & %{ $input = as($input, "character") %} @@ -129,38 +153,31 @@ string &, std::string & %typemap(scoerceout) char, char *, char &, + unsigned int, + unsigned int &, + unsigned long, + unsigned long &, double, double &, float, float &, + long, + long &, + long long, + long long &, int, int &, - long, - long &, bool, bool &, string, std::string, string &, std::string &, - void, - signed int, - signed int &, - unsigned int, - unsigned int &, - short, - short &, - unsigned short, - unsigned short &, - long long, - signed long long, - signed long long &, - unsigned long long, - unsigned long long &, - signed long, - signed long &, - unsigned long, - unsigned long & + size_t, + std::size_t, + size_t &, + std::size_t &, + void %{ %} diff --git a/Lib/ruby/file.i b/Lib/ruby/file.i index d64937ed1..54ed0a609 100644 --- a/Lib/ruby/file.i +++ b/Lib/ruby/file.i @@ -3,14 +3,7 @@ #ifdef __cplusplus extern "C" { #endif - -// Ruby 1.9 changed the file name of this header -#ifdef HAVE_RUBY_IO_H -#include "ruby/io.h" -#else #include "rubyio.h" -#endif - #ifdef __cplusplus } #endif diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg index d17fdbaae..8e6e2e7d0 100644 --- a/Lib/ruby/rubyhead.swg +++ b/Lib/ruby/rubyhead.swg @@ -7,9 +7,6 @@ #ifdef read # undef read #endif -#ifdef bind -# undef bind -#endif /* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */ diff --git a/Lib/ruby/rubywstrings.swg b/Lib/ruby/rubywstrings.swg index 862928c95..0cf9d7ed9 100644 --- a/Lib/ruby/rubywstrings.swg +++ b/Lib/ruby/rubywstrings.swg @@ -29,7 +29,7 @@ SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc) // } // } // if (ok) { -// Py_ssize_t len = PyUnicode_GetSize(obj); +// int len = PyUnicode_GetSize(obj); // rb_notimplement(); // if (cptr) { // *cptr = %new_array(len + 1, wchar_t); diff --git a/Lib/shared_ptr.i b/Lib/shared_ptr.i index 709791502..0ccce64bf 100644 --- a/Lib/shared_ptr.i +++ b/Lib/shared_ptr.i @@ -1,8 +1,4 @@ // shared_ptr namespaces could be boost or std or std::tr1 -// For example for std::tr1, use: -// #define SWIG_SHARED_PTR_NAMESPACE std -// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1 - #if !defined(SWIG_SHARED_PTR_NAMESPACE) # define SWIG_SHARED_PTR_NAMESPACE boost #endif @@ -48,12 +44,12 @@ SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) %define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...) SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE) SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE) -%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{ +%types(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >) %{ *newmemory = SWIG_CAST_NEW_MEMORY; - return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from); -%} + return (void *) new SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > *)$from); + %} %extend TYPE { - static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { + static SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) { return swigSharedPtrUpcast; } } diff --git a/Lib/swig.swg b/Lib/swig.swg index 77308e080..6f40a8fe9 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -25,11 +25,10 @@ /* Code insertion directives such as %wrapper %{ ... %} */ -#define %begin %insert("begin") -#define %runtime %insert("runtime") -#define %header %insert("header") -#define %wrapper %insert("wrapper") #define %init %insert("init") +#define %wrapper %insert("wrapper") +#define %header %insert("header") +#define %runtime %insert("runtime") /* Class extension */ @@ -424,21 +423,13 @@ namespace std { /* Character array handling */ %typemap(memberin) char [ANY] { - if($input) { - strncpy((char*)$1, (const char *)$input, $1_dim0-1); - $1[$1_dim0-1] = 0; - } else { - $1[0] = 0; - } + if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0); + else $1[0] = 0; } %typemap(globalin) char [ANY] { - if($input) { - strncpy((char*)$1, (const char *)$input, $1_dim0-1); - $1[$1_dim0-1] = 0; - } else { - $1[0] = 0; - } + if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0); + else $1[0] = 0; } %typemap(memberin) char [] { @@ -468,26 +459,26 @@ namespace std { /* memberin/globalin typemap for double arrays. */ %typemap(memberin) SWIGTYPE [ANY][ANY] { - $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input); - $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1); + $basetype (*inp)[$dim1] = ($basetype (*)[$dim1])($input); + $basetype (*dest)[$dim1] = ($basetype (*)[$dim1])($1); size_t ii = 0; - for (; ii < $1_dim0; ++ii) { + for (; ii < $dim0; ++ii) { $basetype *ip = inp[ii]; $basetype *dp = dest[ii]; size_t jj = 0; - for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj]; + for (; jj < $dim1; ++jj) dp[jj] = ip[jj]; } } %typemap(globalin) SWIGTYPE [ANY][ANY] { - $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input); - $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1); + $basetype (*inp)[$dim1] = ($basetype (*)[$dim1])($input); + $basetype (*dest)[$dim1] = ($basetype (*)[$dim1])($1); size_t ii = 0; - for (; ii < $1_dim0; ++ii) { + for (; ii < $dim0; ++ii) { $basetype *ip = inp[ii]; $basetype *dp = dest[ii]; size_t jj = 0; - for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj]; + for (; jj < $dim1; ++jj) dp[jj] = ip[jj]; } } @@ -634,10 +625,6 @@ namespace std { * arg1 = *inarg1; // Assignment from a pointer * arg1 = Vector(1,2,3); // Assignment from a value * - * The class offers a strong guarantee of exception safety. - * With regards to the implementation, the private SwigMovePointer nested class is - * a simple smart pointer with move semantics, much like std::auto_ptr. - * * This wrapping technique was suggested by William Fulton and is henceforth * known as the "Fulton Transform" :-). */ @@ -645,21 +632,18 @@ namespace std { #ifdef __cplusplus %insert("runtime") %{ #ifdef __cplusplus -/* SwigValueWrapper is described in swig.swg */ template class SwigValueWrapper { - struct SwigMovePointer { - T *ptr; - SwigMovePointer(T *p) : ptr(p) { } - ~SwigMovePointer() { delete ptr; } - SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; } - } pointer; - SwigValueWrapper& operator=(const SwigValueWrapper& rhs); - SwigValueWrapper(const SwigValueWrapper& rhs); + T *tt; public: - SwigValueWrapper() : pointer(0) { } - SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; } - operator T&() const { return *pointer.ptr; } - T *operator&() { return pointer.ptr; } + SwigValueWrapper() : tt(0) { } + SwigValueWrapper(const SwigValueWrapper& rhs) : tt(new T(*rhs.tt)) { } + SwigValueWrapper(const T& t) : tt(new T(t)) { } + ~SwigValueWrapper() { delete tt; } + SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; } + operator T&() const { return *tt; } + T *operator&() { return tt; } +private: + SwigValueWrapper& operator=(const SwigValueWrapper& rhs); };%} /* diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index a8e9ad74c..9ee676a2b 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------------- * swigrun.swg * - * This file contains generic C API SWIG runtime support for pointer + * This file contains generic CAPI SWIG runtime support for pointer * type checking. * ----------------------------------------------------------------------------- */ @@ -20,11 +20,11 @@ /* You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the SWIG runtime code. - In 99.9% of the cases, SWIG just needs to declare them as 'static'. + creating a static or dynamic library from the swig runtime code. + In 99.9% of the cases, swig just needs to declare them as 'static'. - But only do this if strictly necessary, ie, if you have problems - with your compiler or suchlike. + But only do this if is strictly necessary, ie, if you have problems + with your compiler or so. */ #ifndef SWIGRUNTIME @@ -51,14 +51,14 @@ /* Flags/methods for returning states. - The SWIG conversion methods, as ConvertPtr, return and integer + The swig conversion methods, as ConvertPtr, return and integer that tells if the conversion was successful or not. And if not, an error code can be returned (see swigerrors.swg for the codes). Use the following macros/flags to set or process the returning states. - In old versions of SWIG, code such as the following was usually written: + In old swig versions, you usually write code as: if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { // success code @@ -66,7 +66,7 @@ //fail code } - Now you can be more explicit: + Now you can be more explicit as: int res = SWIG_ConvertPtr(obj,vptr,ty.flags); if (SWIG_IsOK(res)) { @@ -75,7 +75,7 @@ // fail code } - which is the same really, but now you can also do + that seems to be the same, but now you can also do Type *ptr; int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); @@ -93,7 +93,7 @@ I.e., now SWIG_ConvertPtr can return new objects and you can identify the case and take care of the deallocation. Of course that - also requires SWIG_ConvertPtr to return new result values, such as + requires also to SWIG_ConvertPtr to return new result values, as int SWIG_ConvertPtr(obj, ptr,...) { if () { @@ -111,7 +111,7 @@ Of course, returning the plain '0(success)/-1(fail)' still works, but you can be more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - SWIG errors code. + swig errors code. Finally, if the SWIG_CASTRANK_MODE is enabled, the result code allows to return the 'cast rank', for example, if you have this @@ -125,8 +125,9 @@ fooi(1) // cast rank '0' just use the SWIG_AddCast()/SWIG_CheckState() -*/ + + */ #define SWIG_OK (0) #define SWIG_ERROR (-1) #define SWIG_IsOK(r) (r >= 0) @@ -151,6 +152,7 @@ #define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) #define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) + /* Cast-Rank Mode */ #if defined(SWIG_CASTRANK_MODE) # ifndef SWIG_TypeRank @@ -173,6 +175,8 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) { #endif + + #include #ifdef __cplusplus @@ -269,58 +273,40 @@ SWIG_TypeCompare(const char *nb, const char *tb) { } +/* think of this as a c++ template<> or a scheme macro */ +#define SWIG_TypeCheck_Template(comparison, ty) \ + if (ty) { \ + swig_cast_info *iter = ty->cast; \ + while (iter) { \ + if (comparison) { \ + if (iter == ty->cast) return iter; \ + /* Move iter to the top of the linked list */ \ + iter->prev->next = iter->next; \ + if (iter->next) \ + iter->next->prev = iter->prev; \ + iter->next = ty->cast; \ + iter->prev = 0; \ + if (ty->cast) ty->cast->prev = iter; \ + ty->cast = iter; \ + return iter; \ + } \ + iter = iter->next; \ + } \ + } \ + return 0 + /* Check the typename */ SWIGRUNTIME swig_cast_info * SWIG_TypeCheck(const char *c, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (strcmp(iter->type->name, c) == 0) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; + SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); } -/* - Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison -*/ +/* Same as previous function, except strcmp is replaced with a pointer comparison */ SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (iter->type == from) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; +SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { + SWIG_TypeCheck_Template(iter->type == from, into); } /* diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg index 4bc6315b7..f6335be82 100644 --- a/Lib/typemaps/attribute.swg +++ b/Lib/typemaps/attribute.swg @@ -11,7 +11,7 @@ The following macros convert a pair of set/get methods into a "native" attribute. - Use %attribute when you have a pair of get/set methods to a primitive type + Use %attribute when you have a pair of get/set methods like in: %attribute(A, int, a, get_a, set_a); @@ -27,8 +27,8 @@ %attribute(A, int, c, get_c); - Use %attributeref when you have const/non-const reference access methods - for primitive types or class/structs, like in: + Use %attributeref when you have const/non-const reference + access methods, like in: %attributeref(A, int, b); @@ -99,40 +99,6 @@ where %arg() 'normalizes' the type to be understood as a single argument, otherwise the macro will get confused by the comma. - - The %attributeval is the same as %attribute, but should be used when the type - is a class/struct (ie a non-primitive type) and when the get and set methods - return/pass by value. The following is very similar to the above example, but - note that the access is by value rather than reference. - - %attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo); - %attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo); - %inline %{ - class MyClassVal { - MyFoo foo; - public: - MyFoo GetFoo() { return foo; } - void SetFoo(MyFoo other) { foo = other; } - }; - %} - - The %attributestring is the same as %attributeval, but should be used for string - class types, which are unusual as they are a class on the C++ side, but normally an - immutable/primitive type in the target language. Example usage for std::string: - - %include - %attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString); - %attributestring(MyStringyClass, std::string, ReadOnlyString, GetString); - %inline %{ - class MyStringyClass { - std::string str; - public: - MyStringyClass(const std::string &val) : str(val) {} - std::string GetString() { return str; } - void SetString(std::string other) { str = other; } - }; - %} - */ // @@ -237,50 +203,3 @@ #endif %enddef - -%define %attributeval(Class, AttributeType, AttributeName, GetMethod, SetMethod...) - %{ - #define %mangle(Class) ##_## AttributeName ## _get(self_) new AttributeType(self_->GetMethod()) - %} - #if #SetMethod != "" - %{ - #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) self_->SetMethod(*val_) - %} - #if #SetMethod != #AttributeName - %ignore Class::SetMethod; - #endif - #else - %immutable Class::AttributeName; - #endif - %ignore Class::GetMethod(); - %ignore Class::GetMethod() const; - %newobject Class::AttributeName; - %extend Class { - AttributeType AttributeName; - } -%enddef - - -%define %attributestring(Class, AttributeType, AttributeName, GetMethod, SetMethod...) - %{ - #define %mangle(Class) ##_## AttributeName ## _get(self_) *new AttributeType(self_->GetMethod()) - %} - #if #SetMethod != "" - %{ - #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) self_->SetMethod(val_) - %} - #if #SetMethod != #AttributeName - %ignore Class::SetMethod; - #endif - #else - %immutable Class::AttributeName; - #endif - %ignore Class::GetMethod(); - %ignore Class::GetMethod() const; - %newobject Class::AttributeName; - %typemap(newfree) const AttributeType &AttributeName "delete $1;// my newfree override" - %extend Class { - AttributeType AttributeName; - } -%enddef - diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg index 15f2f9b41..f5c88a717 100644 --- a/Lib/typemaps/swigtype.swg +++ b/Lib/typemaps/swigtype.swg @@ -124,7 +124,7 @@ %typemap(memberin) SWIGTYPE [ANY] { if ($input) { size_t ii = 0; - for (; ii < (size_t)$1_dim0; ++ii) $1[ii] = $input[ii]; + for (; ii < (size_t)$dim0; ++ii) $1[ii] = $input[ii]; } else { %variable_nullref("$type","$name"); } @@ -133,7 +133,7 @@ %typemap(globalin) SWIGTYPE [ANY] { if ($input) { size_t ii = 0; - for (; ii < (size_t)$1_dim0; ++ii) $1[ii] = $input[ii]; + for (; ii < (size_t)$dim0; ++ii) $1[ii] = $input[ii]; } else { %variable_nullref("$type","$name"); } @@ -146,7 +146,7 @@ %variable_fail(res, "$type", "$name"); } else if (inp) { size_t ii = 0; - for (; ii < (size_t)$1_dim0; ++ii) $1[ii] = inp[ii]; + for (; ii < (size_t)$dim0; ++ii) $1[ii] = inp[ii]; } else { %variable_nullref("$type", "$name"); } @@ -158,10 +158,10 @@ %typemap(memberin) SWIGTYPE [ANY][ANY] { if ($input) { size_t ii = 0; - for (; ii < (size_t)$1_dim0; ++ii) { + for (; ii < (size_t)$dim0; ++ii) { if ($input[ii]) { size_t jj = 0; - for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; + for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = $input[ii][jj]; } else { %variable_nullref("$type","$name"); } @@ -174,10 +174,10 @@ %typemap(globalin) SWIGTYPE [ANY][ANY] { if ($input) { size_t ii = 0; - for (; ii < (size_t)$1_dim0; ++ii) { + for (; ii < (size_t)$dim0; ++ii) { if ($input[ii]) { size_t jj = 0; - for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj]; + for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = $input[ii][jj]; } else { %variable_nullref("$type","$name"); } @@ -188,16 +188,16 @@ } %typemap(varin) SWIGTYPE [ANY][ANY] { - $basetype (*inp)[$1_dim1] = 0; + $basetype (*inp)[$dim1] = 0; int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags); if (!SWIG_IsOK(res)) { %variable_fail(res, "$type", "$name"); } else if (inp) { size_t ii = 0; - for (; ii < (size_t)$1_dim0; ++ii) { + for (; ii < (size_t)$dim0; ++ii) { if (inp[ii]) { size_t jj = 0; - for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = inp[ii][jj]; + for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = inp[ii][jj]; } else { %variable_nullref("$type", "$name"); } diff --git a/Makefile.in b/Makefile.in index b56272b11..dd3867f0d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,8 +2,6 @@ # $Id$ ####################################################################### -.PHONY: ccache source swig - prefix = @prefix@ exec_prefix = @exec_prefix@ srcdir = @srcdir@ @@ -16,39 +14,23 @@ datarootdir = @datarootdir@ SHELL = /bin/sh SWIG_LIB = @swig_lib@ BIN_DIR = @bindir@ -ENABLE_CCACHE = @ENABLE_CCACHE@ TARGET_NOEXE= swig TARGET = $(TARGET_NOEXE)@EXEEXT@ SOURCE = Source -CCACHE = CCache DOCS = Doc/Manual -swig: libfiles source ccache +swig: libfiles source source: @cd $(SOURCE) && $(MAKE) -ccache: - test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE)) - libfiles: $(srcdir)/Lib/swigwarn.swg # Files required just for the tarball maintainer: libfiles @cd $(SOURCE) && $(MAKE) CParse/parser.h -##################################################################### -# Documentation -##################################################################### - -docs: docs-main docs-ccache - -docs-main: - @echo making docs - @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) all clean-baks - -docs-ccache: - test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) docs) +.PHONY: source libfiles maintainer ##################################################################### # All the languages SWIG speaks (when it wants to) @@ -62,7 +44,7 @@ skip-guilescm = test -n "@SKIP_GUILESCM@" skip-guile = test -n "@SKIP_GUILE@" skip-mzscheme = test -n "@SKIP_MZSCHEME@" skip-ruby = test -n "@SKIP_RUBY@" -skip-php = test -n "@SKIP_PHP@" +skip-php4 = test -n "@SKIP_PHP4@" skip-ocaml = test -n "@SKIP_OCAML@" skip-octave = test -n "@SKIP_OCTAVE@" skip-pike = test -n "@SKIP_PIKE@" @@ -85,7 +67,6 @@ skip-gcj = test -n "@SKIP_GCJ@" ##################################################################### ACTION = check -NOSKIP = chk-set-swiglib = SWIG_LIB=@ROOT_DIR@/Lib chk-set-swig = SWIG=@ROOT_DIR@/$(TARGET) @@ -104,7 +85,7 @@ check-aliveness: @$(skip-ruby) || ./$(TARGET) -ruby -help @$(skip-ocaml) || ./$(TARGET) -ocaml -help @$(skip-octave) || ./$(TARGET) -octave -help - @$(skip-php) || ./$(TARGET) -php -help + @$(skip-php4) || ./$(TARGET) -php4 -help @$(skip-pike) || ./$(TARGET) -pike -help @$(skip-chicken) || ./$(TARGET) -chicken -help @$(skip-csharp) || ./$(TARGET) -csharp -help @@ -113,9 +94,6 @@ check-aliveness: @$(skip-r) || ./$(TARGET) -r -help @$(skip-c) || ./$(TARGET) -c -help -check-ccache: - test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) check) - # Checks examples for compilation (does not run them) check-examples: \ check-tcl-examples \ @@ -127,7 +105,7 @@ check-examples: \ check-ruby-examples \ check-ocaml-examples \ check-octave-examples \ - check-php-examples \ + check-php4-examples \ check-pike-examples \ check-chicken-examples \ check-csharp-examples \ @@ -137,7 +115,7 @@ check-examples: \ check-clisp-examples \ check-uffi-examples \ check-cffi-examples \ - check-r-examples \ + check-r-examples \ check-c-examples tcl_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/tcl/check.list) @@ -149,7 +127,7 @@ mzscheme_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/mzscheme/check.list ruby_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/ruby/check.list) ocaml_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/ocaml/check.list) octave_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/octave/check.list) -php_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php/check.list) +php4_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php4/check.list) pike_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/pike/check.list) chicken_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/chicken/check.list) csharp_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/csharp/check.list) @@ -202,13 +180,13 @@ check-gifplot: \ check-ruby-gifplot \ check-ocaml-gifplot \ check-octave-gifplot \ - check-php-gifplot \ + check-php4-gifplot \ check-pike-gifplot \ check-chicken-gifplot \ # check-lua-gifplot \ # check-csharp-gifplot \ -# check-modula3-gifplot \ -# check-c-gifplot +# check-modula3-gifplot \ +# check-c-gifplot check-%-gifplot: gifplot-library @if test -z "$(skip-$*)"; then \ @@ -245,7 +223,7 @@ check-test-suite: \ check-ruby-test-suite \ check-ocaml-test-suite \ check-octave-test-suite \ - check-php-test-suite \ + check-php4-test-suite \ check-pike-test-suite \ check-csharp-test-suite \ check-modula3-test-suite \ @@ -255,7 +233,7 @@ check-test-suite: \ check-uffi-test-suite \ check-cffi-test-suite \ check-chicken-test-suite \ - check-r-test-suite \ + check-r-test-suite \ check-c-test-suite check-%-test-suite: @@ -265,7 +243,7 @@ check-%-test-suite: fi @passed=true; \ dir="Examples/test-suite/$*"; \ - if $(skip-$*) -a "$(NOSKIP)" != "1"; then \ + if $(skip-$*); then \ echo skipping $* test-suite $(ACTION); \ elif [ ! -d $$dir ]; then \ echo warning: cannot $(ACTION) $* test-suite "(no dir $$dir)";\ @@ -278,12 +256,12 @@ check-%-test-suite: # Partial test-suite check - it only invokes SWIG, ie no compilation and no runtime testing partialcheck-test-suite: - @$(MAKE) -k -s check-test-suite ACTION=partialcheck NOSKIP=1 + @$(MAKE) -k -s check-test-suite ACTION=partialcheck partialcheck-%-test-suite: - @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck NOSKIP=1 + @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck -check: check-aliveness check-ccache check-examples check-gifplot check-test-suite +check: check-aliveness check-examples check-gifplot check-test-suite # Run known-to-be-broken as well as not broken testcases in the test-suite all-test-suite: \ @@ -297,7 +275,7 @@ all-test-suite: \ all-ruby-test-suite \ all-ocaml-test-suite \ all-octave-test-suite \ - all-php-test-suite \ + all-php4-test-suite \ all-pike-test-suite \ all-csharp-test-suite \ all-modula3-test-suite \ @@ -307,7 +285,7 @@ all-test-suite: \ all-uffi-test-suite \ all-cffi-test-suite \ all-chicken-test-suite \ - all-r-test-suite \ + all-r-test-suite \ all-c-test-suite all-%-test-suite: @@ -325,7 +303,7 @@ broken-test-suite: \ broken-ruby-test-suite \ broken-ocaml-test-suite \ broken-octave-test-suite \ - broken-php-test-suite \ + broken-php4-test-suite \ broken-pike-test-suite \ broken-csharp-test-suite \ broken-modula3-test-suite \ @@ -335,8 +313,8 @@ broken-test-suite: \ broken-uffi-test-suite \ broken-cffi-test-suite \ broken-chicken-test-suite \ - broken-r-test-suite \ - broken-c-test-suite + broken-r-test-suite \ + broken-c-test-suite broken-%-test-suite: @$(MAKE) -k -s check-$*-test-suite ACTION=broken @@ -347,7 +325,7 @@ broken-%-test-suite: clean: clean-objects clean-libfiles clean-examples clean-gifplot clean-test-suite clean-docs -clean-objects: clean-source clean-ccache +clean-objects: clean-source clean-source: @echo cleaning Source @@ -364,28 +342,20 @@ clean-gifplot: @$(MAKE) -k -s check-gifplot ACTION=clean clean-test-suite: - @$(MAKE) -k -s check-test-suite ACTION=clean NOSKIP=1 + @$(MAKE) -k -s check-test-suite ACTION=clean clean-%-examples: @$(MAKE) -k -s check-$*-examples ACTION=clean clean-%-test-suite: - @$(MAKE) -k -s check-$*-test-suite ACTION=clean NOSKIP=1 + @$(MAKE) -k -s check-$*-test-suite ACTION=clean clean-%-gifplot: @$(MAKE) -k -s check-$*-gifplot ACTION=clean -clean-ccache: - test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s clean) - -clean-docs: clean-docs-main clean-docs-ccache - -clean-docs-main: +clean-docs: @echo cleaning Docs - @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) clean - -clean-docs-ccache: - @test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) clean-docs) + @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) -s clean maintainer-clean: clean-libfiles @cd $(SOURCE) && $(MAKE) maintainer-clean @@ -396,7 +366,7 @@ maintainer-clean: clean-libfiles DISTCLEAN-DEAD = config.status config.log config.cache swig.spec Makefile mkmf.log libtool -distclean: distclean-objects clean-examples clean-gifplot distclean-test-suite clean-docs distclean-dead distclean-ccache +distclean: distclean-objects clean-examples clean-gifplot distclean-test-suite clean-docs distclean-dead distclean-objects: distclean-source @@ -407,10 +377,39 @@ distclean-source: distclean-test-suite: @echo distcleaning Examples/test-suite - @$(MAKE) -k -s check-test-suite ACTION=distclean NOSKIP=1 + @$(MAKE) -k -s noskip-test-suite ACTION=distclean -distclean-ccache: - test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s distclean) +noskip-test-suite: \ + noskip-tcl-test-suite \ + noskip-perl5-test-suite \ + noskip-python-test-suite \ + noskip-java-test-suite \ + noskip-guilescm-test-suite \ + noskip-guile-test-suite \ + noskip-mzscheme-test-suite \ + noskip-ruby-test-suite \ + noskip-ocaml-test-suite \ + noskip-octave-test-suite \ + noskip-php4-test-suite \ + noskip-pike-test-suite \ + noskip-csharp-test-suite \ + noskip-lua-test-suite \ + noskip-allegrocl-test-suite \ + noskip-clisp-test-suite \ + noskip-uffi-test-suite \ + noskip-cffi-test-suite \ + noskip-chicken-test-suite \ + noskip-r-test-suite \ + noskip-c-test-suite + +noskip-%-test-suite: + dir="Examples/test-suite/$*"; \ + if [ ! -d $$dir ]; then \ + echo warning: cannot $(ACTION) $* test-suite "(no dir $$dir)";\ + else \ + echo $(ACTION)ing $$dir; \ + (cd $$dir && $(MAKE) -k -s $(ACTION)) \ + fi; distclean-dead: rm -f $(DISTCLEAN-DEAD) @@ -440,7 +439,7 @@ MKINSTDIRS = @abs_srcdir@/Tools/config/install-sh -m 0755 -d # Use standard autoconf approach to transform executable name using --program-prefix and --program-suffix transform = @program_transform_name@ -install: install-main install-lib install-ccache +install: install-main install-lib @echo "Installation complete" install-main: @@ -449,7 +448,7 @@ install-main: @echo "Installing $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@" @$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@ -lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \ +lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php4 ocaml octave \ pike chicken csharp modula3 allegrocl clisp lua cffi uffi r c lib-modules = std @@ -484,15 +483,12 @@ install-lib: fi) ; \ done -install-ccache: - test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) install) - ##################################################################### # TARGETS: uninstall & friends ##################################################################### -uninstall: uninstall-main uninstall-lib uninstall-ccache +uninstall: uninstall-main uninstall-lib @echo "Uninstall complete" uninstall-main: @@ -503,9 +499,6 @@ uninstall-lib: @echo "Uninstalling the SWIG library" rm -rf $(DESTDIR)$(SWIG_LIB)/ -uninstall-ccache: - test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) uninstall) - ############################################################################ # DIST and other maintenance ############################################################################ diff --git a/README b/README index 3df9e506a..2898130b0 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 1.3.40 (in progress) +Version: 1.3.36 (24 June 2008) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, @@ -91,27 +91,6 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki: What's New? =========== -SWIG-1.3.39 summary: -- Some new small feature enhancements. -- Improved C# std::vector wrappers. -- Bug fixes: mainly Python, but also Perl, MzScheme, CFFI, Allegrocl - and Ruby - -SWIG-1.3.38 summary: -- Output directory regression fix and other minor bug fixes - -SWIG-1.3.37 summary: -- Python 3 support added -- SWIG now ships with a version of ccache that can be used with SWIG. - This enables the files generated by SWIG to be cached so that repeated - use of SWIG on unchanged input files speeds up builds quite considerably. -- PHP 4 support removed and PHP support improved in general -- Improved C# array support -- Numerous Allegro CL improvements -- Bug fixes/enhancements for Python, PHP, Java, C#, Chicken, Allegro CL, - CFFI, Ruby, Tcl, Perl, R, Lua. -- Other minor generic bug fixes and enhancements - SWIG-1.3.36 summary: - Enhancement to directors to wrap all protected members - Optimisation feature for objects returned by value diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h index 9be41c60e..06a901c0d 100644 --- a/Source/CParse/cparse.h +++ b/Source/CParse/cparse.h @@ -34,18 +34,16 @@ extern "C" { extern void scanner_ignore_typedef(void); extern void scanner_last_id(int); extern void scanner_clear_rename(void); - extern void scanner_set_location(String *file, int line); - extern void scanner_set_main_input_file(String *file); - extern String *scanner_get_main_input_file(); + extern void scanner_set_location(String_or_char *, int line); extern void Swig_cparse_follow_locators(int); extern void start_inline(char *, int); extern String *scanner_ccode; - extern int yylex(void); + extern int yylex(); /* parser.y */ extern SwigType *Swig_cparse_type(String *); extern Node *Swig_cparse(File *); - extern Hash *Swig_cparse_features(void); + extern Hash *Swig_cparse_features(); extern void SWIG_cparse_set_compact_default_args(int defargs); extern int SWIG_cparse_template_reduce(int treduce); diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c index 8734c7d0e..032c71f7e 100644 --- a/Source/CParse/cscanner.c +++ b/Source/CParse/cscanner.c @@ -22,10 +22,7 @@ char cvsroot_cscanner_c[] = "$Id$"; static Scanner *scan = 0; /* Global string containing C code. Used by the parser to grab code blocks */ -String *scanner_ccode = 0; - -/* The main file being parsed */ -static String *main_input_file = 0; +DOHString *scanner_ccode = 0; /* Error reporting/location information */ int cparse_line = 1; @@ -264,8 +261,10 @@ int yylook(void) { while (1) { if ((tok = Scanner_token(scan)) == 0) return 0; - if (tok == SWIG_TOKEN_ERROR) - return 0; + if (tok == SWIG_TOKEN_ERROR) { + Swig_error(Scanner_file(scan), Scanner_errline(scan), Scanner_errmsg(scan)); + continue; + } cparse_start_line = Scanner_start_line(scan); cparse_line = Scanner_line(scan); cparse_file = Scanner_file(scan); @@ -442,7 +441,7 @@ int yylook(void) { static int check_typedef = 0; -void scanner_set_location(String *file, int line) { +void scanner_set_location(String_or_char *file, int line) { Scanner_set_location(scan,file,line-1); } @@ -468,14 +467,6 @@ void scanner_next_token(int tok) { next_token = tok; } -void scanner_set_main_input_file(String *file) { - main_input_file = file; -} - -String *scanner_get_main_input_file() { - return main_input_file; -} - /* ---------------------------------------------------------------------------- * int yylex() * @@ -699,22 +690,10 @@ int yylex(void) { termtoken = SWIG_TOKEN_LPAREN; termvalue = "("; break; - } else if (nexttok == SWIG_TOKEN_CODEBLOCK) { - termtoken = SWIG_TOKEN_CODEBLOCK; - termvalue = Char(Scanner_text(scan)); - break; - } else if (nexttok == SWIG_TOKEN_LBRACE) { - termtoken = SWIG_TOKEN_LBRACE; - termvalue = "{"; - break; - } else if (nexttok == SWIG_TOKEN_SEMI) { + } else if (nexttok == SWIG_TOKEN_SEMI) { termtoken = SWIG_TOKEN_SEMI; termvalue = ";"; break; - } else if (nexttok == SWIG_TOKEN_STRING) { - termtoken = SWIG_TOKEN_STRING; - termvalue = Swig_copy_string(Char(Scanner_text(scan))); - break; } else if (nexttok == SWIG_TOKEN_ID) { if (needspace) { Append(s," "); @@ -880,14 +859,8 @@ int yylex(void) { return (INLINE); if (strcmp(yytext, "%typemap") == 0) return (TYPEMAP); - if (strcmp(yytext, "%feature") == 0) { - /* The rename_active indicates we don't need the information of the - * following function's return type. This applied for %rename, so do - * %feature. - */ - rename_active = 1; + if (strcmp(yytext, "%feature") == 0) return (FEATURE); - } if (strcmp(yytext, "%except") == 0) return (EXCEPT); if (strcmp(yytext, "%importfile") == 0) diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 0babfbbb8..58e0c0c41 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -66,7 +66,7 @@ static void yyerror (const char *e) { (void)e; } -static Node *new_node(const_String_or_char_ptr tag) { +static Node *new_node(const String_or_char *tag) { Node *n = NewHash(); set_nodeType(n,tag); Setfile(n,cparse_file); @@ -203,7 +203,7 @@ static String *yyrename = 0; static String *resolve_node_scope(String *cname); -Hash *Swig_cparse_features(void) { +Hash *Swig_cparse_features() { static Hash *features_hash = 0; if (!features_hash) features_hash = NewHash(); return features_hash; @@ -1002,68 +1002,6 @@ static void add_nested(Nested *n) { } } -/* Strips C-style and C++-style comments from string in-place. */ -static void strip_comments(char *string) { - int state = 0; /* - * 0 - not in comment - * 1 - in c-style comment - * 2 - in c++-style comment - * 3 - in string - * 4 - after reading / not in comments - * 5 - after reading * in c-style comments - * 6 - after reading \ in strings - */ - char * c = string; - while (*c) { - switch (state) { - case 0: - if (*c == '\"') - state = 3; - else if (*c == '/') - state = 4; - break; - case 1: - if (*c == '*') - state = 5; - *c = ' '; - break; - case 2: - if (*c == '\n') - state = 0; - else - *c = ' '; - break; - case 3: - if (*c == '\"') - state = 0; - else if (*c == '\\') - state = 6; - break; - case 4: - if (*c == '/') { - *(c-1) = ' '; - *c = ' '; - state = 2; - } else if (*c == '*') { - *(c-1) = ' '; - *c = ' '; - state = 1; - } else - state = 0; - break; - case 5: - if (*c == '/') - state = 0; - *c = ' '; - break; - case 6: - state = 3; - break; - } - ++c; - } -} - /* Dump all of the nested class declarations to the inline processor * However. We need to do a few name replacements and other munging * first. This function must be called before closing a class! */ @@ -1115,9 +1053,6 @@ static Node *dump_nested(const char *parent) { ret = retx; */ - /* Strip comments - further code may break in presence of comments. */ - strip_comments(Char(n->code)); - /* Make all SWIG created typedef structs/unions/classes unnamed else redefinition errors occur - nasty hack alert.*/ @@ -1425,7 +1360,7 @@ static void default_arguments(Node *n) { * Used by the parser to mark subtypes with extra information. * ----------------------------------------------------------------------------- */ -static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) { +static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) { while (n) { Setattr(n, attrname, value); tag_nodes(firstChild(n), attrname, value); @@ -1951,19 +1886,14 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK { ; /* ------------------------------------------------------------ - %includefile "filename" [option1="xyz", ...] [ declarations ] - %importfile "filename" [option1="xyz", ...] [ declarations ] + %includefile "filename" [ declarations ] + %importfile "filename" [ declarations ] ------------------------------------------------------------ */ include_directive: includetype options string LBRACKET { $1.filename = Copy(cparse_file); $1.line = cparse_line; scanner_set_location(NewString($3),1); - if ($2) { - String *maininput = Getattr($2, "maininput"); - if (maininput) - scanner_set_main_input_file(NewString(maininput)); - } } interface RBRACKET { String *mname = 0; $$ = $6; @@ -2360,25 +2290,21 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr String *val = $7 ? NewString($7) : NewString("1"); new_feature($3, val, 0, $5.id, $5.type, $5.parms, $6.qualifier); $$ = 0; - scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum RPAREN declarator cpp_const SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, 0, $7.id, $7.type, $7.parms, $8.qualifier); $$ = 0; - scanner_clear_rename(); } | FEATURE LPAREN idstring featattr RPAREN declarator cpp_const stringbracesemi { String *val = $8 ? NewString($8) : NewString("1"); new_feature($3, val, $4, $6.id, $6.type, $6.parms, $7.qualifier); $$ = 0; - scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum featattr RPAREN declarator cpp_const SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, $6, $8.id, $8.type, $8.parms, $9.qualifier); $$ = 0; - scanner_clear_rename(); } /* Global feature */ @@ -2386,25 +2312,21 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr String *val = $5 ? NewString($5) : NewString("1"); new_feature($3, val, 0, 0, 0, 0, 0); $$ = 0; - scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum RPAREN SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, 0, 0, 0, 0, 0); $$ = 0; - scanner_clear_rename(); } | FEATURE LPAREN idstring featattr RPAREN stringbracesemi { String *val = $6 ? NewString($6) : NewString("1"); new_feature($3, val, $4, 0, 0, 0, 0); $$ = 0; - scanner_clear_rename(); } | FEATURE LPAREN idstring COMMA stringnum featattr RPAREN SEMI { String *val = Len($5) ? NewString($5) : 0; new_feature($3, val, $6, 0, 0, 0, 0); $$ = 0; - scanner_clear_rename(); } ; @@ -3230,15 +3152,15 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE { List *bases = 0; Node *scope = 0; - $$ = new_node("class"); - Setline($$,cparse_start_line); - Setattr($$,"kind",$2); + $$ = new_node("class"); + Setline($$,cparse_start_line); + Setattr($$,"kind",$2); if ($4) { - Setattr($$,"baselist", Getattr($4,"public")); - Setattr($$,"protectedbaselist", Getattr($4,"protected")); - Setattr($$,"privatebaselist", Getattr($4,"private")); + Setattr($$,"baselist", Getattr($4,"public")); + Setattr($$,"protectedbaselist", Getattr($4,"protected")); + Setattr($$,"privatebaselist", Getattr($4,"private")); } - Setattr($$,"allows_typedef","1"); + Setattr($$,"allows_typedef","1"); /* preserve the current scope */ prev_symtab = Swig_symbol_current(); @@ -3267,10 +3189,10 @@ cpp_class_decl : nscope_inner = 0; } } - Setattr($$,"name",$3); + Setattr($$,"name",$3); Delete(class_rename); - class_rename = make_name($$,$3,0); + class_rename = make_name($$,$3,0); Classprefix = NewString($3); /* Deal with inheritance */ if ($4) { @@ -3334,12 +3256,12 @@ cpp_class_decl : } else { max_class_levels *= 2; } - class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels); + class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels); if (!class_decl) { Swig_error(cparse_file, cparse_line, "realloc() failed\n"); } } - class_decl[class_level++] = $$; + class_decl[class_level++] = $$; inclass = 1; } cpp_members RBRACE cpp_opt_declarators { Node *p; @@ -3462,14 +3384,14 @@ cpp_class_decl : | storage_class cpptype LBRACE { String *unnamed; unnamed = make_unnamed(); - $$ = new_node("class"); - Setline($$,cparse_start_line); - Setattr($$,"kind",$2); - Setattr($$,"storage",$1); - Setattr($$,"unnamed",unnamed); - Setattr($$,"allows_typedef","1"); + $$ = new_node("class"); + Setline($$,cparse_start_line); + Setattr($$,"kind",$2); + Setattr($$,"storage",$1); + Setattr($$,"unnamed",unnamed); + Setattr($$,"allows_typedef","1"); Delete(class_rename); - class_rename = make_name($$,0,0); + class_rename = make_name($$,0,0); if (strcmp($2,"class") == 0) { cplus_mode = CPLUS_PRIVATE; } else { @@ -3483,12 +3405,12 @@ cpp_class_decl : } else { max_class_levels *= 2; } - class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels); + class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels); if (!class_decl) { Swig_error(cparse_file, cparse_line, "realloc() failed\n"); } } - class_decl[class_level++] = $$; + class_decl[class_level++] = $$; inclass = 1; Classprefix = NewStringEmpty(); Delete(Namespaceprefix); @@ -5492,18 +5414,7 @@ valexpr : exprnum { $$ = $1; } | LPAREN expr RPAREN expr %prec CAST { $$ = $4; if ($4.type != T_STRING) { - switch ($2.type) { - case T_FLOAT: - case T_DOUBLE: - case T_LONGDOUBLE: - case T_FLTCPLX: - case T_DBLCPLX: - $$.val = NewStringf("(%s)%s", $2.val, $4.val); /* SwigType_str and decimal points don't mix! */ - break; - default: - $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val); - break; - } + $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val); } } | LPAREN expr pointer RPAREN expr %prec CAST { diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c index 14886605f..8142125a7 100644 --- a/Source/CParse/templ.c +++ b/Source/CParse/templ.c @@ -15,7 +15,7 @@ char cvsroot_templ_c[] = "$Id$"; static int template_debug = 0; -const char *baselists[3]; +String *baselists[3]; void SwigType_template_init() { baselists[0] = "baselist"; @@ -167,21 +167,18 @@ static int cparse_template_expand(Node *n, String *tname, String *rname, String add_parms(Getattr(n, "throws"), cpatchlist, typelist); } else if (Equal(nodeType, "destructor")) { String *name = Getattr(n, "name"); - if (name) { - if (strchr(Char(name), '<')) - Append(patchlist, Getattr(n, "name")); - else - Append(name, templateargs); + if (name && strchr(Char(name), '<')) { + Append(patchlist, Getattr(n, "name")); + } else { + Append(name, templateargs); } name = Getattr(n, "sym:name"); - if (name) { - if (strchr(Char(name), '<')) { - String *sn = Copy(tname); - Setattr(n, "sym:name", sn); - Delete(sn); - } else { - Replace(name, tname, rname, DOH_REPLACE_ANY); - } + if (name && strchr(Char(name), '<')) { + String *sn = Copy(tname); + Setattr(n, "sym:name", sn); + Delete(sn); + } else { + Replace(name, tname, rname, DOH_REPLACE_ANY); } /* Setattr(n,"sym:name",name); */ Append(cpatchlist, Getattr(n, "code")); diff --git a/Source/DOH/README b/Source/DOH/README index 9a42e8b8b..1e948105c 100644 --- a/Source/DOH/README +++ b/Source/DOH/README @@ -92,12 +92,12 @@ DohEncoding(name, fn) Register a format encoding for Printf Currently Available datatypes ------------------------------ -NewString(char *initial) Strings -NewHash() Hash -NewList() List -NewVoid(void *ptr, void (*del)(void *)) Void -NewFile(char *filename, char *mode, List *newfiles) File -NewCallable(DOH *(*func)(DOH *, DOH *)) Callable object +NewString(char *initial) Strings +NewHash() Hash +NewList() List +NewVoid(void *ptr, void (*del)(void *)) Void +NewFile(char *file, char *mode) File +NewCallable(DOH *(*func)(DOH *, DOH *)) Callable object Odds and ends: diff --git a/Source/DOH/base.c b/Source/DOH/base.c index 15827f328..dcb0140e0 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -827,7 +827,7 @@ void DohSetfile(DOH *ho, DOH *file) { /* ----------------------------------------------------------------------------- * DohGetFile() * ----------------------------------------------------------------------------- */ -DOH *DohGetfile(const DOH *ho) { +DOH *DohGetfile(DOH *ho) { DohBase *h = (DohBase *) ho; DohObjInfo *objinfo; if (!h) @@ -854,7 +854,7 @@ void DohSetline(DOH *ho, int l) { /* ----------------------------------------------------------------------------- * DohGetLine() * ----------------------------------------------------------------------------- */ -int DohGetline(const DOH *ho) { +int DohGetline(DOH *ho) { DohBase *h = (DohBase *) ho; DohObjInfo *objinfo; if (!h) diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h index 766e12a34..7ab244fab 100644 --- a/Source/DOH/doh.h +++ b/Source/DOH/doh.h @@ -144,9 +144,6 @@ typedef void DOH; #define DOHString_or_char DOH #define DOHObj_or_char DOH -typedef const DOHString_or_char * const_String_or_char_ptr; -typedef const DOHString_or_char * DOHconst_String_or_char_ptr; - #define DOH_BEGIN -1 #define DOH_END -2 #define DOH_CUR -3 @@ -237,9 +234,9 @@ extern DohIterator DohNext(DohIterator x); /* Positional */ -extern int DohGetline(const DOH *obj); +extern int DohGetline(DOH *obj); extern void DohSetline(DOH *obj, int line); -extern DOH *DohGetfile(const DOH *obj); +extern DOH *DohGetfile(DOH *obj); extern void DohSetfile(DOH *obj, DOH *file); /* String Methods */ @@ -274,7 +271,7 @@ extern int DohGetmark(DOH *obj); * Strings. * ----------------------------------------------------------------------------- */ -extern DOHString *DohNewStringEmpty(void); +extern DOHString *DohNewStringEmpty(); extern DOHString *DohNewString(const DOH *c); extern DOHString *DohNewStringWithSize(const DOH *c, int len); extern DOHString *DohNewStringf(const DOH *fmt, ...); @@ -300,7 +297,7 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch); * Files * ----------------------------------------------------------------------------- */ -extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles); +extern DOHFile *DohNewFile(DOH *file, const char *mode); extern DOHFile *DohNewFileFromFile(FILE *f); extern DOHFile *DohNewFileFromFd(int fd); extern void DohFileErrorDisplay(DOHString * filename); @@ -312,14 +309,14 @@ extern int DohCopyto(DOHFile * input, DOHFile * output); * List * ----------------------------------------------------------------------------- */ -extern DOHList *DohNewList(void); +extern DOHList *DohNewList(); extern void DohSortList(DOH *lo, int (*cmp) (const DOH *, const DOH *)); /* ----------------------------------------------------------------------------- * Hash * ----------------------------------------------------------------------------- */ -extern DOHHash *DohNewHash(void); +extern DOHHash *DohNewHash(); /* ----------------------------------------------------------------------------- * Void diff --git a/Source/DOH/file.c b/Source/DOH/file.c index 65c2336a4..8c53978ee 100644 --- a/Source/DOH/file.c +++ b/Source/DOH/file.c @@ -228,16 +228,15 @@ static DohObjInfo DohFileType = { * NewFile() * * Create a new file from a given filename and mode. - * If newfiles is non-zero, the filename is added to the list of new files. * ----------------------------------------------------------------------------- */ -DOH *DohNewFile(DOH *filename, const char *mode, DOHList *newfiles) { +DOH *DohNewFile(DOH *fn, const char *mode) { DohFile *f; FILE *file; - char *filen; + char *filename; - filen = Char(filename); - file = fopen(filen, mode); + filename = Char(fn); + file = fopen(filename, mode); if (!file) return 0; @@ -246,8 +245,6 @@ DOH *DohNewFile(DOH *filename, const char *mode, DOHList *newfiles) { fclose(file); return 0; } - if (newfiles) - Append(newfiles, filename); f->filep = file; f->fd = 0; f->closeondel = 1; diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c index 045de8b5b..62aef10f2 100644 --- a/Source/DOH/hash.c +++ b/Source/DOH/hash.c @@ -535,7 +535,7 @@ DohObjInfo DohHashType = { * Create a new hash table. * ----------------------------------------------------------------------------- */ -DOH *DohNewHash(void) { +DOH *DohNewHash() { Hash *h; int i; h = (Hash *) DohMalloc(sizeof(Hash)); diff --git a/Source/DOH/list.c b/Source/DOH/list.c index 7a1786299..a45731de1 100644 --- a/Source/DOH/list.c +++ b/Source/DOH/list.c @@ -345,7 +345,7 @@ DohObjInfo DohListType = { #define MAXLISTITEMS 8 -DOH *DohNewList(void) { +DOH *DohNewList() { List *l; int i; l = (List *) DohMalloc(sizeof(List)); diff --git a/Source/DOH/string.c b/Source/DOH/string.c index 141cd58e8..1498d717a 100644 --- a/Source/DOH/string.c +++ b/Source/DOH/string.c @@ -1056,7 +1056,7 @@ DOHString *DohNewString(const DOH *so) { * NewStringEmpty() - Create a new string * ----------------------------------------------------------------------------- */ -DOHString *DohNewStringEmpty(void) { +DOHString *DohNewStringEmpty() { int max = INIT_MAXSIZE; String *str = (String *) DohMalloc(sizeof(String)); str->hashkey = 0; diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h index ebcd2fe7c..72e394c98 100644 --- a/Source/Include/swigwarn.h +++ b/Source/Include/swigwarn.h @@ -49,7 +49,6 @@ #define WARN_DEPRECATED_NOEXTERN 122 #define WARN_DEPRECATED_NODEFAULT 123 #define WARN_DEPRECATED_TYPEMAP_LANG 124 -#define WARN_DEPRECATED_INPUT_FILE 125 /* -- Preprocessor -- */ @@ -248,21 +247,15 @@ /* please leave 850-869 free for Modula 3 */ -/* These are needed for backward compatibility, but you don't need to add - * PHP4 versions of new warnings since existing user interface files can't - * be using them. - */ -#define WARN_PHP_MULTIPLE_INHERITANCE 870 -#define WARN_PHP_UNKNOWN_PRAGMA 871 +#define WARN_PHP4_MULTIPLE_INHERITANCE 870 +#define WARN_PHP4_UNKNOWN_PRAGMA 871 -#define WARN_PHP_MULTIPLE_INHERITANCE 870 -#define WARN_PHP_UNKNOWN_PRAGMA 871 +/* please leave 870-889 free for Php */ -/* please leave 870-889 free for PHP */ +#define WARN_C_TYPEMAP_CTYPE_UNDEF 890 /* please leave 890-909 free for C */ -#define WARN_C_TYPEMAP_CTYPE_UNDEF 890 /* Feel free to claim any number in this space that's not currently being used. Just make sure you add an entry here */ diff --git a/Source/Makefile.am b/Source/Makefile.am index a5f4a0c39..c44f22931 100644 --- a/Source/Makefile.am +++ b/Source/Makefile.am @@ -38,11 +38,11 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/allegrocl.cxx \ Modules/allocate.cxx \ Modules/browser.cxx \ - Modules/c.cxx \ Modules/cffi.cxx \ Modules/chicken.cxx \ Modules/clisp.cxx \ Modules/contract.cxx \ + Modules/c.cxx \ Modules/csharp.cxx \ Modules/directors.cxx \ Modules/emit.cxx \ @@ -58,7 +58,7 @@ eswig_SOURCES = CParse/cscanner.c \ Modules/octave.cxx \ Modules/overload.cxx \ Modules/perl5.cxx \ - Modules/php.cxx \ + Modules/php4.cxx \ Modules/pike.cxx \ Modules/python.cxx \ Modules/r.cxx \ diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx index 878e30a67..a968e506c 100644 --- a/Source/Modules/allegrocl.cxx +++ b/Source/Modules/allegrocl.cxx @@ -21,8 +21,7 @@ char cvsroot_allegrocl_cxx[] = "$Id$"; static File *f_cl = 0; String *f_clhead = NewString(""); String *f_clwrap = NewString("(swig-in-package ())\n\n"); -static File *f_begin; -static File *f_runtime; +static File *f_cxx; static File *f_cxx_header = 0; static File *f_cxx_wrapper = 0; @@ -35,8 +34,6 @@ static bool CWrap = true; // generate wrapper file for C code by default. most c static bool Generate_Wrapper = false; static bool unique_swig_package = false; -static SwigType *fwdref_ffi_type = NewString("__SWIGACL_FwdReference"); - static String *current_namespace = NewString(""); static String *current_package = NewString(""); static Hash *defined_namespace_packages = NewHash(); @@ -171,7 +168,6 @@ static String *namespace_of(String *str) { void add_linked_type(Node *n) { #ifdef ALLEGROCL_CLASS_DEBUG Printf(stderr, "Adding linked node of type: %s(%s) %s(%x)\n\n", nodeType(n), Getattr(n, "storage"), Getattr(n, "name"), n); - // Swig_print_node(n); #endif if (!first_linked_type) { first_linked_type = n; @@ -301,8 +297,7 @@ void add_forward_referenced_type(Node *n, int overwrite = 0) { } } -void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, - String *name = 0, String *ns = current_namespace) { +void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String *name = 0, String *ns = current_namespace) { String *val; String *ns_list = listify_namespace(ns); @@ -326,34 +321,22 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, /* For typedefs of the form: - typedef struct __xxx { ... } xxx; + typedef __xxx { ... } xxx; - behavior differs between C mode and C++ mode. - - C Mode: add_defined_foreign_type will be called once via classHandler - to define the type for 'struct __xxx' and add the mapping from - 'struct __xxx' -> 'xxx' + to define the type for 'struct __xxx', and once via typedefHandler + to associate xxx with 'struct __xxx'. - It will also be called once via typedefHandler to add the - mapping 'xxx' -> 'xxx' + We create the following type to identifier mappings: - C++ Mode: - add_defined_foreign_type will be called once via classHandler - to define the type for 'xxx'. it also adds the mapping from - 'xxx' -> 'xxx' and also for 'struct xxx' -> 'xxx' + struct __xxx -> (swig-insert-id "xxx") via classHand + xxx -> (swig-insert-id "xxx") via typedefHand - In typedefHandler, we again try to add the mapping from - 'xxx' -> 'xxx', which already exists. This second mapping - is ignored. + and all references to this typedef'd struct will appear in + generated code as 'xxx'. For non-typedef'd structs, the + classHand mapping will be - Both modes: - - All references to this typedef'd struct will appear in - generated lisp code as an objectd of type 'xxx'. For - non-typedef'd structs, the classHand mapping will be - - struct __xxx -> (swig-insert-id "__xxx") + struct __xxx -> (swig-insert-id "__xxx") */ // Swig_print_node(n); String *unnamed = Getattr(n, "unnamed"); @@ -602,11 +585,7 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, Delete(mangled_name_gen); Delete(mangled_lname_gen); } else { - if (!CPlusPlus || Strcmp(Getattr(n,"kind"),"typedef")) { - Swig_warning(WARN_TYPE_REDEFINED, Getfile(n), Getline(n), - "Attempting to store a foreign type that exists: %s (%s)\n", - k, val); - } + Swig_warning(WARN_TYPE_REDEFINED, Getfile(n), Getline(n), "Attempting to store a foreign type that exists: %s (%s)\n", k, val); } Delete(ns_list); @@ -626,7 +605,7 @@ void note_implicit_template_instantiation(SwigType *t) { add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace); } -String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) { +String *get_ffi_type(SwigType *ty, const String_or_char *name) { /* lookup defined foreign type. if it exists, it will return a form suitable for placing into lisp code to generate the def-foreign-type name */ @@ -641,8 +620,7 @@ String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "found_type '%s'\n", found_type); #endif - return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : - get_ffi_type(fwdref_ffi_type, "")); + return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : NewString(":void")); } else { Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0); @@ -729,39 +707,25 @@ String *internal_compose_foreign_type(SwigType *ty) { if (res) Printf(ffiType, "%s", res); } - +// while(resolved_type) { +// // the resolved_type may expand into something like p.NS1::NS2::SomeType +// // for which get_ffi_type will not find any match (due to the p.). +// // Printf(stderr, "\n in resolved type loop on '%s'\n", resolved_type); +// res = get_ffi_type(resolved_type, ""); +// if (res) { +// Printf(ffiType, "%s", res); +// break; +// } else { +// resolved_type = SwigType_typedef_resolve(resolved_type); +// } +// } if (!res) { - String *is_struct = 0; - String *tok_remove_text = 0; - String *tok_name = Copy(tok); - String *tok_key = SwigType_str(tok,0); - if ((is_struct = Strstr(tok_key, "struct ")) || Strstr(tok_key, "union ")) { - tok_remove_text = NewString(is_struct ? "struct " : "union "); + if (Strstr(tok, "struct ")) { + Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(tok), Getline(tok), "Unable to find definition of '%s', assuming forward reference.\n", tok); + } else { + Printf(stderr, "Unable to compose foreign type of: '%s'\n", tok); } - - /* be more permissive of opaque types. This is the swig way. - compiles will notice if these types are ultimately not - present. */ - - if(tok_remove_text) { - Replaceall(tok_name,tok_remove_text,""); - } - tok_name = strip_namespaces(tok_name); - Delete(tok_remove_text); - // Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(tok), Getline(tok), "Unable to find definition of '%s', assuming forward reference.\n", tok); - -#ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "i-c-f-t: adding forward reference for unknown type '%s'. mapping: %s -> %s\n", tok, tok_key, tok_name); -#endif - Node *nn = NewHash(); - Setattr(nn,"nodeType","classforward"); - Setattr(nn,"kind","class"); - Setattr(nn,"sym:name",tok_name); - Setattr(nn,"name",tok_key); - Setattr(nn,"allegrocl:package",current_namespace); - - add_forward_referenced_type(nn, 0); - Printf(ffiType, "%s", get_ffi_type(tok, ""), tok_name); + Printf(ffiType, "(* :void)"); } } } @@ -769,36 +733,24 @@ String *internal_compose_foreign_type(SwigType *ty) { return ffiType; } -String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) { - -/* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */ +String *compose_foreign_type(SwigType *ty, String *id = 0) { + Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty); - // Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0)); - /* String *id_ref = SwigType_str(ty, id); + String *id_ref = SwigType_str(ty, id); Printf(stderr, "looking up typemap for %s, found '%s'(%x)\n", id_ref, lookup_res ? Getattr(lookup_res, "code") : 0, lookup_res); - if (lookup_res) Swig_print_node(lookup_res); - */ #endif - /* should we allow named lookups in the typemap here? YES! */ /* unnamed lookups should be found in get_ffi_type, called by internal_compose_foreign_type(), below. */ - - /* I'm reverting to 'no' for the question above. I can no longer - remember why I needed it. If a user needed it, I'll find out - as soon as they upgrade. Sigh. -mutandiz 9/16/2008. */ - -/* if(id && lookup_res) { #ifdef ALLEGROCL_TYPE_DEBUG Printf(stderr, "compose_foreign_type: EXIT-1 (%s)\n ", Getattr(lookup_res, "code")); #endif return NewString(Getattr(lookup_res, "code")); } -*/ SwigType *temp = SwigType_strip_qualifiers(ty); String *res = internal_compose_foreign_type(temp); @@ -876,10 +828,6 @@ String *strip_parens(String *string) { } int ALLEGROCL::validIdentifier(String *s) { -#ifdef ALLEGROCL_DEBUG - Printf(stderr, "validIdentifier %s\n", s); -#endif - char *c = Char(s); bool got_dot = false; @@ -1006,7 +954,6 @@ String *convert_literal(String *literal, String *type, bool try_to_split) { Delete(num); num = 0; } - Delete(lisp_exp); } else { String *id = NewStringf("#.(swig-insert-id \"%s\" %s :type :constant)", num, ns); @@ -1137,8 +1084,7 @@ void emit_synonym(Node *synonym) { of_ltype = lookup_defined_foreign_ltype(of_name); // Printf(f_clhead,";; from emit-synonym\n"); - if( of_ltype ) - Printf(f_clhead, "(swig-def-synonym-type %s\n %s\n %s)\n", syn_ltype, of_ltype, syn_type); + Printf(f_clhead, "(swig-def-synonym-type %s\n %s\n %s)\n", syn_ltype, of_ltype, syn_type); Delete(synonym_ns); Delete(of_ns_list); @@ -1338,6 +1284,7 @@ void emit_typedef(Node *n) { // leave these in for now. might want to change these to def-foreign-class at some point. // Printf(f_clhead, ";; %s\n", SwigType_typedef_resolve_all(lisp_type)); + // Swig_print_node(n); Printf(f_clhead, "(swig-def-foreign-type \"%s\"\n %s)\n", name, lisp_type); Delete(name); @@ -1521,7 +1468,6 @@ extern "C" Language *swig_allegrocl(void) { void ALLEGROCL::main(int argc, char *argv[]) { int i; - Preprocessor_define("SWIGALLEGROCL 1", 0); SWIG_library_directory("allegrocl"); SWIG_config_file("allegrocl.swg"); @@ -1569,10 +1515,7 @@ void ALLEGROCL::main(int argc, char *argv[]) { "\tcalled to convert identifiers to symbols.\n" "\n" " -[no]cwrap\n" - "\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n" - " -isolate\n" - "Define all SWIG helper functions in a package unique to this module. Avoids redefinition warnings when loading multiple SWIGged modules\n" - "into the same running Allegro CL image.\n"); + "\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n"); } @@ -1588,9 +1531,9 @@ int ALLEGROCL::top(Node *n) { swig_package = unique_swig_package ? NewStringf("swig.%s", module_name) : NewString("swig"); - Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), module_name); + Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), Swig_file_basename(Getattr(n,"infile"))); - f_cl = NewFile(cl_filename, "w", SWIG_output_files()); + f_cl = NewFile(cl_filename, "w"); if (!f_cl) { Printf(stderr, "Unable to open %s for writing\n", cl_filename); SWIG_exit(EXIT_FAILURE); @@ -1599,42 +1542,33 @@ int ALLEGROCL::top(Node *n) { Generate_Wrapper = CPlusPlus || CWrap; if (Generate_Wrapper) { - f_begin = NewFile(cxx_filename, "w", SWIG_output_files()); - if (!f_begin) { + f_cxx = NewFile(cxx_filename, "w"); + if (!f_cxx) { Close(f_cl); Delete(f_cl); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); SWIG_exit(EXIT_FAILURE); } } else - f_begin = NewString(""); + f_cxx = NewString(""); - f_runtime = NewString(""); - f_cxx_header = f_runtime; + f_cxx_header = f_cxx; f_cxx_wrapper = NewString(""); Swig_register_filebyname("header", f_cxx_header); Swig_register_filebyname("wrapper", f_cxx_wrapper); - Swig_register_filebyname("begin", f_begin); - Swig_register_filebyname("runtime", f_runtime); + Swig_register_filebyname("runtime", f_cxx); Swig_register_filebyname("lisp", f_clwrap); Swig_register_filebyname("lisphead", f_cl); - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGALLEGROCL\n"); - Printf(f_runtime, "\n"); - - Swig_banner_target_lang(f_cl, ";;"); - - Printf(f_cl, "\n" + Printf(f_cl, ";; This is an automatically generated file. Make changes in\n" + ";; the definition file, not here.\n\n" "(defpackage :%s\n" " (:use :common-lisp :ff :excl)\n" " (:export #:*swig-identifier-converter* #:*swig-module-name*\n" " #:*void* #:*swig-export-list*))\n" "(in-package :%s)\n\n" - "(eval-when (:compile-toplevel :load-toplevel :execute)\n" + "(eval-when (compile load eval)\n" " (defparameter *swig-identifier-converter* '%s)\n" " (defparameter *swig-module-name* :%s))\n\n", swig_package, swig_package, identifier_converter, module_name); Printf(f_cl, "(defpackage :%s\n" " (:use :common-lisp :%s :ff :excl))\n\n", module_name, swig_package); @@ -1645,7 +1579,7 @@ int ALLEGROCL::top(Node *n) { Language::top(n); - // SwigType_emit_type_table(f_runtime,f_cxx_wrapper); + // SwigType_emit_type_table(f_cxx,f_cxx_wrapper); // Swig_print_tree(n); #ifdef ALLEGROCL_TYPE_DEBUG @@ -1668,12 +1602,8 @@ int ALLEGROCL::top(Node *n) { Delete(f_clhead); Delete(f_clwrap); - Dump(f_runtime, f_begin); - Printf(f_begin, "%s\n", f_cxx_wrapper); - - Close(f_begin); - Delete(f_runtime); - Delete(f_begin); + Close(f_cxx); + Delete(f_cxx); Delete(f_cxx_wrapper); // Swig_print_tree(n); @@ -1968,7 +1898,7 @@ int any_varargs(ParmList *pl) { return 0; } -String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) { +String *get_lisp_type(SwigType *ty, const String_or_char *name) { Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0); if (typemap) { String *typespec = Getattr(typemap, "code"); @@ -2154,9 +2084,7 @@ struct IDargs { String *arity; IDargs():name(0), type(0), klass(0), arity(0) { - } - - String *full_quoted_str() { + } String *full_quoted_str() { String *result = no_others_quoted_str(); if (arity) Printf(result, " :arity %s", arity); @@ -2407,24 +2335,41 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { for (p = pl; p; p = nextSibling(p), argnum++, largnum++) { // SwigType *argtype=Getattr(p, "type"); SwigType *argtype = Swig_cparse_type(Getattr(p, "tmap:ctype")); - SwigType *parmtype = Getattr(p,"type"); if (!first) { Printf(fcl, "\n "); } - /* by default, skip varargs */ - if (!SwigType_isvarargs(parmtype)) { + if (SwigType_isvarargs(argtype)) { + Printf(stderr, "Function %s (line %d) contains varargs, which is not directly supported. Use %%varargs instead.\n", Getattr(n, "name"), Getline(n)); + } else { String *argname = NewStringf("PARM%d_%s", largnum, Getattr(p, "name")); + // Swig_print_node(p); // Printf(stderr,"%s\n", Getattr(p,"tmap:lin")); String *ffitype = compose_foreign_type(argtype, Getattr(p,"name")); - String *deref_ffitype = dereference_ffitype(ffitype); - String *lisptype = get_lisp_type(parmtype, Getattr(p, "name")); + String *deref_ffitype; + + deref_ffitype = dereference_ffitype(ffitype); + +/* + String *temp = Copy(argtype); + + if (SwigType_ispointer(temp)) { + SwigType_pop(temp); + deref_ffitype = compose_foreign_type(temp); + } else { + deref_ffitype = Copy(ffitype); + } + + Delete(temp); +*/ + // String *lisptype=get_lisp_type(argtype, argname); + String *lisptype = get_lisp_type(Getattr(p, "type"), Getattr(p, "name")); #ifdef ALLEGROCL_DEBUG - Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", parmtype, - Getattr(p, "name"), lisptype); + Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", + Getattr(p, "type"), Getattr(p, "name"), lisptype); #endif // while we're walking the parameters, generating LIN @@ -2455,9 +2400,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { first = 0; } - Delete(argname); Delete(ffitype); - Delete(deref_ffitype); Delete(lisptype); } } @@ -2495,6 +2438,11 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { lclass = lookup_defined_foreign_ltype(cl_t); isPtrReturn = 1; } + // if (SwigType_ispointer(cl_t)) { + // isPtrReturn = 1; + // SwigType_pop(cl_t); + // lclass = lookup_defined_foreign_ltype(cl_t); + // } int ff_foreign_ptr = 0; if (!lclass) { @@ -2567,16 +2515,9 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) { } int ALLEGROCL::functionWrapper(Node *n) { -#ifdef ALLEGROCL_DEBUG - Printf(stderr, "functionWrapper %s\n", Getattr(n,"name")); - Swig_print_node(n); -#endif - ParmList *parms = CopyParmList(Getattr(n, "parms")); Wrapper *f = NewWrapper(); - SwigType *t = Getattr(n, "type"); - String *name = Getattr(n, "name"); String *raw_return_type = Swig_typemap_lookup("ctype", n, "", 0); SwigType *return_type = Swig_cparse_type(raw_return_type); @@ -2586,13 +2527,11 @@ int ALLEGROCL::functionWrapper(Node *n) { Delete(resolved); if (!is_void_return) { - String *lresult_init = - NewStringf("= (%s)0", - SwigType_str(SwigType_strip_qualifiers(return_type),0)); - Wrapper_add_localv(f, "lresult", - SwigType_lstr(SwigType_ltype(return_type), "lresult"), - lresult_init, NIL); - Delete(lresult_init); + String *lresult_init = NewStringf("= (%s)0", raw_return_type); + Wrapper_add_localv(f, "lresult", + SwigType_lstr(SwigType_ltype(return_type), "lresult"), + lresult_init, NIL); + Delete(lresult_init); } // Emit all of the local variables for holding arguments. emit_parameter_variables(parms, f); @@ -2617,7 +2556,7 @@ int ALLEGROCL::functionWrapper(Node *n) { if (Getattr(n, "overload:ignore")) { // if we're the last overload, make sure to force the emit // of the rest of the overloads before we leave. - Printf(stderr, "ignored overload %s(%x)\n", name, Getattr(n, "sym:nextSibling")); + Printf(stderr, "ignored overload %s(%x)\n", Getattr(n, "name"), Getattr(n, "sym:nextSibling")); if (!Getattr(n, "sym:nextSibling")) { update_package_if_needed(n); emit_buffered_defuns(n); @@ -2632,7 +2571,7 @@ int ALLEGROCL::functionWrapper(Node *n) { int gencomma = 0; #ifdef ALLEGROCL_DEBUG - Printf(stderr, "Walking parameters for %s '%s'\n", Getattr(n, "allegrocl:kind"), name); + Printf(stderr, "Walking parameters for %s '%s'\n", Getattr(n, "allegrocl:kind"), Getattr(n, "name")); #endif // Now walk the function parameter list and generate code to get arguments String *name_and_parms = NewStringf("%s (", mangled); @@ -2686,34 +2625,24 @@ int ALLEGROCL::functionWrapper(Node *n) { String *actioncode = emit_action(n); - String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode); - if (!is_void_return && tm) { - if (tm) { - Replaceall(tm, "$result", "lresult"); - Printf(f->code, "%s\n", tm); - Printf(f->code, " return lresult;\n"); - Delete(tm); - } else { - Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, - "Unable to use return type %s in function %s.\n", - SwigType_str(t, 0), name); - } - } - - emit_return_variable(n, t, f); + String *result_convert = Swig_typemap_lookup_out("out", n, "result", f, actioncode); + Replaceall(result_convert, "$result", "lresult"); + Printf(f->code, "%s\n", result_convert); + Printf(f->code, " return lresult;\n"); + Delete(result_convert); + emit_return_variable(n, Getattr(n, "type"), f); if (CPlusPlus) { Printf(f->code, " } catch (...) {\n"); if (!is_void_return) - Printf(f->code, " return (%s)0;\n", - SwigType_str(SwigType_strip_qualifiers(return_type),0)); + Printf(f->code, " return (%s)0;\n", raw_return_type); Printf(f->code, " }\n"); } Printf(f->code, "}\n"); /* print this when in C mode? make this a command-line arg? */ if (Generate_Wrapper) - Wrapper_print(f, f_cxx_wrapper); + Wrapper_print(f, f_cxx); String *f_buffer = NewString(""); @@ -2735,15 +2664,13 @@ int ALLEGROCL::functionWrapper(Node *n) { } int ALLEGROCL::namespaceDeclaration(Node *n) { + // Empty namespaces are not worth DEFPACKAGEing. + // Swig_print_node(n); #ifdef ALLEGROCL_DEBUG Printf(stderr, "namespaceDecl: '%s'(0x%x) (fc=0x%x)\n", Getattr(n, "sym:name"), n, firstChild(n)); #endif - /* don't wrap a namespace with no contents. package bloat. - also, test-suite/namespace_class.i claims an unnamed namespace - is 'private' and should not be wrapped. Complying... - */ - if (Getattr(n,"unnamed") || !firstChild(n)) + if (!firstChild(n)) return SWIG_OK; String *name = Getattr(n, "sym:name"); @@ -2770,7 +2697,7 @@ int ALLEGROCL::namespaceDeclaration(Node *n) { int ALLEGROCL::constructorHandler(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "constructorHandler %s\n", Getattr(n, "name")); + Printf(stderr, "constructor %s\n", Getattr(n, "name")); #endif // Swig_print_node(n); Setattr(n, "allegrocl:kind", "constructor"); @@ -2782,7 +2709,7 @@ int ALLEGROCL::constructorHandler(Node *n) { int ALLEGROCL::destructorHandler(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "destructorHandler %s\n", Getattr(n, "name")); + Printf(stderr, "destructor %s\n", Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "destructor"); @@ -2793,8 +2720,9 @@ int ALLEGROCL::destructorHandler(Node *n) { } int ALLEGROCL::constantWrapper(Node *n) { + #ifdef ALLEGROCL_DEBUG - Printf(stderr, "constantWrapper %s\n", Getattr(n, "name")); + Printf(stderr, "constant %s\n", Getattr(n, "name")); #endif if (Generate_Wrapper) { @@ -2813,10 +2741,10 @@ int ALLEGROCL::constantWrapper(Node *n) { } SwigType_add_qualifier(const_type, "const"); + SwigType_add_qualifier(const_type, "static"); - String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "sym:name")); - // Printf(f_runtime, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); - Printf(f_runtime, "static %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); + String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "name")); + Printf(f_cxx, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val); Setattr(n, "name", ppcname); SetFlag(n, "feature:immutable"); @@ -2850,10 +2778,6 @@ int ALLEGROCL::constantWrapper(Node *n) { } int ALLEGROCL::globalvariableHandler(Node *n) { -#ifdef ALLEGROCL_DEBUG - Printf(stderr, "globalvariableHandler %s\n", Getattr(n, "name")); -#endif - if (Generate_Wrapper) return Language::globalvariableHandler(n); @@ -2873,7 +2797,7 @@ int ALLEGROCL::globalvariableHandler(Node *n) { ctype = SwigType_str(type, 0); // EXPORT ; // = ; - // Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, + // Printf(f_cxx, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, // ctype, mangled_name, (pointer_added ? "&" : ""), name); Printf(f_clwrap, "(swig-defvar \"%s\" \"%s\" :type %s)\n", @@ -2884,7 +2808,7 @@ int ALLEGROCL::globalvariableHandler(Node *n) { int ALLEGROCL::variableWrapper(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "variableWrapper %s\n", Getattr(n, "name")); + Printf(stderr, "variable %s\n", Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "variable"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); @@ -2909,30 +2833,24 @@ int ALLEGROCL::variableWrapper(Node *n) { } ctype = SwigType_str(type, 0); - // EXPORT ; // = ; - Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name); + Printf(f_cxx, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name); Printf(f_cl, "(swig-defvar \"%s\" :type %s)\n", mangled_name, ((SwigType_isconst(type)) ? ":constant" : ":variable")); /* - Printf(f_runtime, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type"))); - Printf(f_runtime, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype)))); + Printf(f_cxx, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type"))); + Printf(f_cxx, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype)))); */ - Printf(stderr,"***\n"); Delete(mangled_name); -#ifdef ALLEGROCL_DEBUG - Printf(stderr, "DONE variable %s\n", Getattr(n, "name")); -#endif - return SWIG_OK; } int ALLEGROCL::memberfunctionHandler(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "memberfunctionHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); + Printf(stderr, "member function %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "member function"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); @@ -2943,7 +2861,7 @@ int ALLEGROCL::memberfunctionHandler(Node *n) { int ALLEGROCL::membervariableHandler(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "membervariableHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); + Printf(stderr, "member variable %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name")); #endif Setattr(n, "allegrocl:kind", "member variable"); Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name")); @@ -2953,8 +2871,10 @@ int ALLEGROCL::membervariableHandler(Node *n) { } int ALLEGROCL::typedefHandler(Node *n) { + #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "In typedefHandler\n"); + Printf(stderr, "In typedefHAND\n"); + // Swig_print_node(n); #endif SwigType *typedef_type = Getattr(n,"type"); @@ -2972,7 +2892,9 @@ int ALLEGROCL::typedefHandler(Node *n) { Printf(stderr, " typedef in class '%s'(%x)\n", Getattr(in_class, "sym:name"), in_class); #endif Setattr(n, "allegrocl:typedef:in-class", in_class); + } + if (in_class) { String *class_name = Getattr(in_class, "name"); name = NewStringf("%s__%s", class_name, sym_name); type_ref = NewStringf("%s::%s", class_name, sym_name); @@ -2986,19 +2908,14 @@ int ALLEGROCL::typedefHandler(Node *n) { String *lookup = lookup_defined_foreign_type(typedef_type); -#ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "** lookup='%s'(%x), typedef_type='%s', strcmp = '%d' strstr = '%d'\n", lookup, lookup, typedef_type, Strcmp(typedef_type,"void"), Strstr(ff_type,"__SWIGACL_FwdReference")); -#endif + // Printf(stderr, "** lookup='%s'(%x), ff_type='%s', strstr = '%d'\n", lookup, lookup, ff_type, !Strstr(ff_type,"void")); - if(lookup || (!lookup && Strcmp(typedef_type,"void")) || - (!lookup && Strstr(ff_type,"__SWIGACL_FwdReference"))) { + if(lookup || (!lookup && !Strstr(ff_type,"void"))) add_defined_foreign_type(n, 0, type_ref, name); - } else { - add_forward_referenced_type(n); - } + else add_forward_referenced_type(n); #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "Out typedefHandler\n"); + Printf(stderr, "Out typedefHAND\n"); #endif Delete(ff_type); @@ -3008,33 +2925,22 @@ int ALLEGROCL::typedefHandler(Node *n) { // forward referenced classes are added specially to defined_foreign_types int ALLEGROCL::classforwardDeclaration(Node *n) { -#ifdef ALLEGROCL_DEBUG - Printf(stderr, "classforwardDeclaration %s\n", Getattr(n, "name")); -#endif - add_forward_referenced_type(n); return SWIG_OK; } int ALLEGROCL::classHandler(Node *n) { #ifdef ALLEGROCL_DEBUG - Printf(stderr, "classHandler %s::%s\n", current_namespace, Getattr(n, "sym:name")); + Printf(stderr, "class %s::%s\n", current_namespace, Getattr(n, "sym:name")); #endif - int result; - if (Generate_Wrapper) - result = cppClassHandler(n); + return cppClassHandler(n); else - result = cClassHandler(n); - - return result; + return cClassHandler(n); } int ALLEGROCL::cClassHandler(Node *n) { -#ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "In cClassHandler\n"); -#endif // String *cDeclName = Getattr(n,"classDeclaration:name"); // String *name= Getattr(n, "sym:name"); // String *kind = Getattr(n,"kind"); @@ -3044,21 +2950,22 @@ int ALLEGROCL::cClassHandler(Node *n) { // Printf(stderr, "Adding %s foreign type\n", name); String *ns = listify_namespace(current_namespace); +#ifdef ALLEGROCL_TYPE_DEBUG + Printf(stderr, "In cClassHAND\n"); +#endif + add_defined_foreign_type(n); Delete(ns); #ifdef ALLEGROCL_TYPE_DEBUG - Printf(stderr, "Out cClassHandler\n"); + Printf(stderr, "Out cClassHAND\n"); #endif return SWIG_OK; } int ALLEGROCL::cppClassHandler(Node *n) { -#ifdef ALLEGROCL_DEBUG - Printf(stderr, "cppClassHandler %s\n", Getattr(n, "name")); -#endif // String *name=Getattr(n, "sym:name"); // String *kind = Getattr(n,"kind"); @@ -3117,9 +3024,6 @@ int ALLEGROCL::cppClassHandler(Node *n) { // so their types can be added to the linked_type_list. SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type")); -#ifdef ALLEGROCL_CLASS_DEBUG - Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType); -#endif if (!SwigType_isfunction(childType)) Delete(compose_foreign_type(childType)); @@ -3160,9 +3064,6 @@ int ALLEGROCL::emit_one(Node *n) { } int ALLEGROCL::enumDeclaration(Node *n) { -#ifdef ALLEGROCL_DEBUG - Printf(stderr, "enumDeclaration %s\n", Getattr(n, "name")); -#endif if (Getattr(n, "sym:name")) { add_defined_foreign_type(n); @@ -3179,34 +3080,21 @@ int ALLEGROCL::enumDeclaration(Node *n) { int ALLEGROCL::enumvalueDeclaration(Node *n) { -#ifdef ALLEGROCL_DEBUG - Printf(stderr, "enumvalueDeclaration %s\n", Getattr(n, "name")); -#endif - /* print this when in C mode? make this a command-line arg? */ - if (Generate_Wrapper) { - SwigType *enum_type = Copy(Getattr(n,"type")); - String *mangled_name = - mangle_name(n, "ACL_ENUM", - in_class ? Getattr(in_class,"name") : - current_namespace); - - SwigType_add_qualifier(enum_type,"const"); - String *enum_decl = SwigType_str(enum_type, mangled_name); - Printf(f_cxx_wrapper, "EXPORT %s;\n", enum_decl); - Printf(f_cxx_wrapper, "%s = %s;\n", enum_decl, Getattr(n, "value")); + /* print this when in C mode? make this a command-line arg? */ + + if (Generate_Wrapper) { + String *mangled_name = mangle_name(n, "ACL_ENUM"); + + Printf(f_cxx, "EXPORT const %s %s = %s;\n", Getattr(n, "type"), mangled_name, Getattr(n, "value")); Delete(mangled_name); - Delete(enum_type); - Delete(enum_decl); } + return SWIG_OK; } int ALLEGROCL::templateDeclaration(Node *n) { -#ifdef ALLEGROCL_DEBUG - Printf(stderr, "templateDeclaration %s\n", Getattr(n, "name")); -#endif String *type = Getattr(n, "templatetype"); diff --git a/Source/Modules/c.cxx b/Source/Modules/c.cxx index 74a960214..9d22a0de4 100644 --- a/Source/Modules/c.cxx +++ b/Source/Modules/c.cxx @@ -12,22 +12,6 @@ char cvsroot_c_cxx[] = "$Id: c.cxx 11186 2009-04-11 10:46:13Z maciekd $"; #include #include "swigmod.h" -int SwigType_isbuiltin(SwigType *t) { - const char* builtins[] = { "void", "short", "int", "long", "char", "float", "double", "bool", - "unsigned short", "unsigned int", "unsigned long", "unsigned char", "signed char", - "long long", "unsigned long long", 0 }; - int i = 0; - char *c = Char(t); - if (!t) - return 0; - while (builtins[i]) { - if (strcmp(c, builtins[i]) == 0) - return 1; - i++; - } - return 0; -} - class C:public Language { static const char *usage; @@ -166,8 +150,8 @@ public: String *outfile = Getattr(n, "outfile"); // initialize I/O - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } @@ -186,13 +170,13 @@ public: // create proxy files with appropriate name String *proxy_code_filename = NewStringf("%s%s_proxy.c", SWIG_output_directory(), Char(module)); - if ((f_proxy_c = NewFile(proxy_code_filename, "w", SWIG_output_files())) == 0) { + if ((f_proxy_c = NewFile(proxy_code_filename, "w")) == 0) { FileErrorDisplay(proxy_code_filename); SWIG_exit(EXIT_FAILURE); } String *proxy_header_filename = NewStringf("%s%s_proxy.h", SWIG_output_directory(), Char(module)); - if ((f_proxy_h = NewFile(proxy_header_filename, "w", SWIG_output_files())) == 0) { + if ((f_proxy_h = NewFile(proxy_header_filename, "w")) == 0) { FileErrorDisplay(proxy_header_filename); SWIG_exit(EXIT_FAILURE); } diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx index 0aa933c56..736564d1a 100644 --- a/Source/Modules/cffi.cxx +++ b/Source/Modules/cffi.cxx @@ -22,8 +22,7 @@ public: String *f_clhead; String *f_clwrap; bool CWrap; // generate wrapper file for C code? - File *f_begin; - File *f_runtime; + File *f_cxx; File *f_cxx_header; File *f_cxx_wrapper; File *f_clos; @@ -68,7 +67,6 @@ private: void CFFI::main(int argc, char *argv[]) { int i; - Preprocessor_define("SWIGCFFI 1", 0); SWIG_library_directory("cffi"); SWIG_config_file("cffi.swg"); generate_typedef_flag = 0; @@ -121,15 +119,16 @@ int CFFI::top(Node *n) { Printf(lisp_filename, "%s%s.lisp", SWIG_output_directory(), module); - File *f_lisp = NewFile(lisp_filename, "w", SWIG_output_files()); + File *f_lisp = NewFile(lisp_filename, "w"); + NewFile(lisp_filename, "w"); if (!f_lisp) { FileErrorDisplay(lisp_filename); SWIG_exit(EXIT_FAILURE); } if (CPlusPlus || CWrap) { - f_begin = NewFile(cxx_filename, "w", SWIG_output_files()); - if (!f_begin) { + f_cxx = NewFile(cxx_filename, "w"); + if (!f_cxx) { Close(f_lisp); Delete(f_lisp); Printf(stderr, "Unable to open %s for writing\n", cxx_filename); @@ -138,7 +137,7 @@ int CFFI::top(Node *n) { String *clos_filename = NewString(""); Printf(clos_filename, "%s%s-clos.lisp", SWIG_output_directory(), module); - f_clos = NewFile(clos_filename, "w", SWIG_output_files()); + f_clos = NewFile(clos_filename, "w"); if (!f_clos) { Close(f_lisp); Delete(f_lisp); @@ -146,32 +145,22 @@ int CFFI::top(Node *n) { SWIG_exit(EXIT_FAILURE); } } else { - f_begin = NewString(""); + f_cxx = NewString(""); f_clos = NewString(""); } - f_runtime = NewString(""); - f_cxx_header = f_runtime; + f_cxx_header = f_cxx; f_cxx_wrapper = NewString(""); Swig_register_filebyname("header", f_cxx_header); Swig_register_filebyname("wrapper", f_cxx_wrapper); - Swig_register_filebyname("begin", f_begin); - Swig_register_filebyname("runtime", f_runtime); + Swig_register_filebyname("runtime", f_cxx); Swig_register_filebyname("lisphead", f_clhead); if (!no_swig_lisp) Swig_register_filebyname("swiglisp", f_cl); else Swig_register_filebyname("swiglisp", f_null); - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGCFFI\n"); - Printf(f_runtime, "\n"); - - Swig_banner_target_lang(f_lisp, ";;;"); - Language::top(n); Printf(f_lisp, "%s\n", f_clhead); Printf(f_lisp, "%s\n", f_cl); @@ -182,10 +171,8 @@ int CFFI::top(Node *n) { Delete(f_cl); Delete(f_clhead); Delete(f_clwrap); - Dump(f_runtime, f_begin); - Close(f_begin); - Delete(f_runtime); - Delete(f_begin); + Close(f_cxx); + Delete(f_cxx); Delete(f_cxx_wrapper); Delete(f_null); @@ -245,7 +232,7 @@ void CFFI::emit_defmethod(Node *n) { ParmList *pl = Getattr(n, "parms"); int argnum = 0; - Node *parent = getCurrentClass(); + Node *parent = parentNode(n); bool first = 0; for (Parm *p = pl; p; p = nextSibling(p), argnum++) { @@ -300,7 +287,7 @@ void CFFI::emit_initialize_instance(Node *n) { ParmList *pl = Getattr(n, "parms"); int argnum = 0; - Node *parent = getCurrentClass(); + Node *parent = parentNode(n); for (Parm *p = pl; p; p = nextSibling(p), argnum++) { String *argname = Getattr(p, "name"); @@ -337,18 +324,18 @@ void CFFI::emit_initialize_instance(Node *n) { } void CFFI::emit_setter(Node *n) { - Node *parent = getCurrentClass(); + Node *p = parentNode(n); Printf(f_clos, "(cl:defmethod (cl:setf %s) (arg0 (obj %s))\n (%s (ff-pointer obj) arg0))\n\n", lispify_name(n, Getattr(n, "name"), "'method"), - lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function")); + lispify_name(p, lispy_name(Char(Getattr(p, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function")); } void CFFI::emit_getter(Node *n) { - Node *parent = getCurrentClass(); + Node *p = parentNode(n); Printf(f_clos, "(cl:defmethod %s ((obj %s))\n (%s (ff-pointer obj)))\n\n", lispify_name(n, Getattr(n, "name"), "'method"), - lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function")); + lispify_name(p, lispy_name(Char(Getattr(p, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function")); } int CFFI::memberfunctionHandler(Node *n) { @@ -468,7 +455,7 @@ int CFFI::functionWrapper(Node *n) { Printf(f->code, "}\n"); if (CPlusPlus) - Wrapper_print(f, f_runtime); + Wrapper_print(f, f_cxx); if (CPlusPlus) { emit_defun(n, wname); @@ -643,7 +630,7 @@ int CFFI::enumDeclaration(Node *n) { else { String *type = Getattr(c, "type"); String *converted_value = convert_literal(value, type); - Printf(f_cl, "\n\t(%s #.%s)", slot_name, converted_value); + Printf(f_cl, "\n\t(%s %s)", slot_name, converted_value); Delete(converted_value); } Delete(value); diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx index 12ef4b454..2298d2939 100644 --- a/Source/Modules/chicken.cxx +++ b/Source/Modules/chicken.cxx @@ -30,7 +30,6 @@ static char *module = 0; static char *chicken_path = (char *) "chicken"; static int num_methods = 0; -static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; @@ -102,12 +101,12 @@ protected: int isPointer(SwigType *t); void dispatchFunction(Node *n); - String *chickenNameMapping(String *, const_String_or_char_ptr ); + String *chickenNameMapping(String *, String_or_char *); String *chickenPrimitiveName(String *); String *runtimeCode(); String *defaultExternalRuntimeFilename(); - String *buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname); + String *buildClosFunctionCall(List *types, String_or_char *closname, String_or_char *funcname); }; /* ----------------------------------------------------------------------- @@ -189,12 +188,11 @@ int CHICKEN::top(Node *n) { /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -207,7 +205,6 @@ int CHICKEN::top(Node *n) { /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); @@ -218,16 +215,14 @@ int CHICKEN::top(Node *n) { clos_methods = NewString(""); scm_const_defs = NewString(""); - Swig_banner(f_begin); + Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n"); + Swig_banner(f_runtime); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGCHICKEN\n"); + Printf(f_runtime, "/* Implementation : CHICKEN */\n\n"); if (no_collection) Printf(f_runtime, "#define SWIG_CHICKEN_NO_COLLECTION 1\n"); - Printf(f_runtime, "\n"); - /* Set module name */ module = Swig_copy_string(Char(Getattr(n, "name"))); scmmodule = NewString(module); @@ -256,14 +251,14 @@ int CHICKEN::top(Node *n) { Printf(f_init, "#endif\n"); Printf(chicken_filename, "%s%s.scm", SWIG_output_directory(), module); - if ((f_scm = NewFile(chicken_filename, "w", SWIG_output_files())) == 0) { + if ((f_scm = NewFile(chicken_filename, "w")) == 0) { FileErrorDisplay(chicken_filename); SWIG_exit(EXIT_FAILURE); } - Swig_banner_target_lang(f_scm, ";;"); - Printf(f_scm, "\n"); - + Printv(f_scm, + ";; -*- buffer-read-only: t -*- vi: set ro:\n", + ";; This file was created automatically by SWIG.\n", ";; Don't modify this file, modify the SWIG interface instead.\n", NIL); if (declare_unit) Printv(f_scm, "(declare (unit ", scmmodule, "))\n\n", NIL); Printv(f_scm, "(declare \n", @@ -312,17 +307,15 @@ int CHICKEN::top(Node *n) { /* Close all of the files */ Delete(primitive_names); Delete(scmmodule); - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); - Dump(f_wrappers, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_header, f_runtime); + Dump(f_wrappers, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_sym_size); Delete(f_init); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); return SWIG_OK; } @@ -1240,7 +1233,7 @@ int CHICKEN::importDirective(Node *n) { return Language::importDirective(n); } -String *CHICKEN::buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname) { +String *CHICKEN::buildClosFunctionCall(List *types, String_or_char *closname, String_or_char *funcname) { String *method_signature = NewString(""); String *func_args = NewString(""); String *func_call = NewString(""); @@ -1514,7 +1507,7 @@ int CHICKEN::validIdentifier(String *s) { * If class_name = "" that means the mapping is for a function or * variable not attached to any class. * ------------------------------------------------------------ */ -String *CHICKEN::chickenNameMapping(String *name, const_String_or_char_ptr class_name) { +String *CHICKEN::chickenNameMapping(String *name, String_or_char *class_name) { String *n = NewString(""); if (Strcmp(class_name, "") == 0) { diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx index fa73b3a0b..823f22e2c 100644 --- a/Source/Modules/clisp.cxx +++ b/Source/Modules/clisp.cxx @@ -36,7 +36,6 @@ private: void CLISP::main(int argc, char *argv[]) { int i; - Preprocessor_define("SWIGCLISP 1", 0); SWIG_library_directory("clisp"); SWIG_config_file("clisp.swg"); generate_typedef_flag = 0; @@ -80,22 +79,20 @@ int CLISP::top(Node *n) { Printf(output_filename, "%s%s.lisp", SWIG_output_directory(), module); } - f_cl = NewFile(output_filename, "w+", SWIG_output_files()); + f_cl = NewFile(output_filename, "w+"); if (!f_cl) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); } Swig_register_filebyname("header", f_null); - Swig_register_filebyname("begin", f_null); Swig_register_filebyname("runtime", f_null); Swig_register_filebyname("wrapper", f_null); - String *header = NewString(""); - - Swig_banner_target_lang(header, ";;"); - - Printf(header, "\n(defpackage :%s\n (:use :common-lisp :ffi)", module); + String *header = + NewStringf + (";; This is an automatically generated file. \n;;Make changes as you feel are necessary (but remember if you try to regenerate this file, your changes will be lost). \n\n(defpackage :%s\n (:use :common-lisp :ffi)", + module); Language::top(n); diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx index 518dc2997..9bf8decf6 100644 --- a/Source/Modules/contract.cxx +++ b/Source/Modules/contract.cxx @@ -46,7 +46,6 @@ public: int extendDirective(Node *n); int importDirective(Node *n); int includeDirective(Node *n); - int namespaceDeclaration(Node *n); int classDeclaration(Node *n); virtual int top(Node *n); }; @@ -321,23 +320,16 @@ int Contracts::constructorDeclaration(Node *n) { int Contracts::externDeclaration(Node *n) { return emit_children(n); } - int Contracts::extendDirective(Node *n) { return emit_children(n); } - int Contracts::importDirective(Node *n) { return emit_children(n); } - int Contracts::includeDirective(Node *n) { return emit_children(n); } -int Contracts::namespaceDeclaration(Node *n) { - return emit_children(n); -} - int Contracts::classDeclaration(Node *n) { int ret = SWIG_OK; InClass = 1; diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 2730b55d4..7ea10170a 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -24,7 +24,6 @@ class CSHARP:public Language { const String *protected_string; Hash *swig_types_hash; - File *f_begin; File *f_runtime; File *f_runtime_h; File *f_header; @@ -86,7 +85,7 @@ class CSHARP:public Language { enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum }; - static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) { + static Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) { Parm *p = NewParm(type, name); Setfile(p, Getfile(n)); Setline(p, Getline(n)); @@ -103,7 +102,6 @@ public: public_string(NewString("public")), protected_string(NewString("protected")), swig_types_hash(NULL), - f_begin(NULL), f_runtime(NULL), f_runtime_h(NULL), f_header(NULL), @@ -288,8 +286,8 @@ public: SWIG_exit(EXIT_FAILURE); } - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } @@ -299,14 +297,13 @@ public: Printf(stderr, "Unable to determine outfile_h\n"); SWIG_exit(EXIT_FAILURE); } - f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); + f_runtime_h = NewFile(outfile_h, "w"); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); } } - f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -316,7 +313,6 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); @@ -362,17 +358,13 @@ public: if (!dllimport) dllimport = Copy(module_class_name); - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGCSHARP\n"); + Swig_banner(f_runtime); // Print the SWIG banner message if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); /* Emit initial director header and director code: */ Swig_banner(f_directors_h); - Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name); @@ -384,8 +376,6 @@ public: Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h)); } - Printf(f_runtime, "\n"); - Swig_name_register((char *) "wrapper", (char *) "CSharp_%f"); if (old_variable_names) { Swig_name_register((char *) "set", (char *) "set_%v"); @@ -406,7 +396,7 @@ public: // Generate the intermediary class { String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), imclass_name); - File *f_im = NewFile(filen, "w", SWIG_output_files()); + File *f_im = NewFile(filen, "w"); if (!f_im) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -450,7 +440,7 @@ public: // Generate the C# module class { String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), module_class_name); - File *f_module = NewFile(filen, "w", SWIG_output_files()); + File *f_module = NewFile(filen, "w"); if (!f_module) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -577,11 +567,10 @@ public: n_dmethods = 0; /* Close all of the files */ - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); + Dump(f_header, f_runtime); if (directorsEnabled()) { - Dump(f_directors, f_begin); + Dump(f_directors, f_runtime); Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); @@ -596,14 +585,13 @@ public: f_directors_h = NULL; } - Dump(f_wrappers, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_wrappers, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); return SWIG_OK; } @@ -613,7 +601,11 @@ public: void emitBanner(File *f) { Printf(f, "/* ----------------------------------------------------------------------------\n"); - Swig_banner_target_lang(f, " *"); + Printf(f, " * This file was automatically generated by SWIG (http://www.swig.org).\n"); + Printf(f, " * Version %s\n", Swig_package_version()); + Printf(f, " *\n"); + Printf(f, " * Do not make changes to this file unless you know what you are doing--modify\n"); + Printf(f, " * the SWIG interface file instead.\n"); Printf(f, " * ----------------------------------------------------------------------------- */\n\n"); } @@ -1163,7 +1155,7 @@ public: } else { // Global enums are defined in their own file String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), symname); - File *f_enum = NewFile(filen, "w", SWIG_output_files()); + File *f_enum = NewFile(filen, "w"); if (!f_enum) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -1742,7 +1734,7 @@ public: } String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), proxy_class_name); - f_proxy = NewFile(filen, "w", SWIG_output_files()); + f_proxy = NewFile(filen, "w"); if (!f_proxy) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -1895,7 +1887,6 @@ public: bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); - String *terminator_code = NewString(""); if (!proxy_flag) return; @@ -2007,8 +1998,7 @@ public: if (!(variable_wrapper_flag && i == 0)) { SwigType *pt = Getattr(p, "type"); String *param_type = NewString(""); - if (setter_flag) - last_parm = p; + last_parm = p; /* Get the C# parameter type */ if ((tm = Getattr(p, "tmap:cstype"))) { @@ -2044,14 +2034,6 @@ public: Printf(post_code, "\n"); Printv(post_code, post, NIL); } - String *terminator = Getattr(p, "tmap:csin:terminator"); - if (terminator) { - substituteClassname(pt, terminator); - Replaceall(terminator, "$csinput", arg); - if (Len(terminator_code) > 0) - Insert(terminator_code, 0, "\n"); - Insert(terminator_code, 0, terminator); - } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0)); @@ -2077,8 +2059,7 @@ public: excodeSubstitute(n, tm, "csout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; - bool is_terminator_code = Len(terminator_code) > 0; - if (is_pre_code || is_post_code || is_terminator_code) { + if (is_pre_code || is_post_code) { Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap if (is_post_code) { Insert(tm, 0, "\n try "); @@ -2090,9 +2071,6 @@ public: Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } - if (is_terminator_code) { - Printv(tm, "\n", terminator_code, NIL); - } Insert(tm, 0, "{"); Printf(tm, "\n }"); } @@ -2192,7 +2170,6 @@ public: Delete(pre_code); Delete(post_code); - Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); @@ -2213,7 +2190,6 @@ public: String *helper_args = NewString(""); String *pre_code = NewString(""); String *post_code = NewString(""); - String *terminator_code = NewString(""); String *im_return_type = NewString(""); bool feature_director = (parentNode(n) && Swig_directorclass(n)); @@ -2309,14 +2285,6 @@ public: Printf(post_code, "\n"); Printv(post_code, post, NIL); } - String *terminator = Getattr(p, "tmap:csin:terminator"); - if (terminator) { - substituteClassname(pt, terminator); - Replaceall(terminator, "$csinput", arg); - if (Len(terminator_code) > 0) - Insert(terminator_code, 0, "\n"); - Insert(terminator_code, 0, terminator); - } cshin = Getattr(p, "tmap:csin:cshin"); if (cshin) Replaceall(cshin, "$csinput", arg); @@ -2373,8 +2341,7 @@ public: bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; - bool is_terminator_code = Len(terminator_code) > 0; - if (is_pre_code || is_post_code || is_terminator_code) { + if (is_pre_code || is_post_code) { Printf(helper_code, " {\n"); if (is_pre_code) { Printv(helper_code, pre_code, "\n", NIL); @@ -2386,9 +2353,6 @@ public: } else { Printv(helper_code, " return ", imcall, ";", NIL); } - if (is_terminator_code) { - Printv(helper_code, "\n", terminator_code, NIL); - } Printf(helper_code, "\n }\n"); String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args); String *im_outattributes = Getattr(n, "tmap:imtype:outattributes"); @@ -2407,7 +2371,6 @@ public: Delete(im_return_type); Delete(pre_code); Delete(post_code); - Delete(terminator_code); Delete(construct_tm); Delete(attributes); Delete(overloaded_name); @@ -2525,7 +2488,6 @@ public: bool setter_flag = false; String *pre_code = NewString(""); String *post_code = NewString(""); - String *terminator_code = NewString(""); if (l) { if (SwigType_type(Getattr(l, "type")) == T_VOID) { @@ -2630,14 +2592,6 @@ public: Printf(post_code, "\n"); Printv(post_code, post, NIL); } - String *terminator = Getattr(p, "tmap:csin:terminator"); - if (terminator) { - substituteClassname(pt, terminator); - Replaceall(terminator, "$csinput", arg); - if (Len(terminator_code) > 0) - Insert(terminator_code, 0, "\n"); - Insert(terminator_code, 0, terminator); - } Printv(imcall, tm, NIL); } else { Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0)); @@ -2662,8 +2616,7 @@ public: excodeSubstitute(n, tm, "csout", n); bool is_pre_code = Len(pre_code) > 0; bool is_post_code = Len(post_code) > 0; - bool is_terminator_code = Len(terminator_code) > 0; - if (is_pre_code || is_post_code || is_terminator_code) { + if (is_pre_code || is_post_code) { Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap if (is_post_code) { Insert(tm, 0, "\n try "); @@ -2675,9 +2628,6 @@ public: Insert(tm, 0, pre_code); Insert(tm, 0, "\n"); } - if (is_terminator_code) { - Printv(tm, "\n", terminator_code, NIL); - } Insert(tm, 0, "{"); Printf(tm, "\n }"); } @@ -2753,7 +2703,6 @@ public: Delete(pre_code); Delete(post_code); - Delete(terminator_code); Delete(function_code); Delete(return_type); Delete(imcall); @@ -2968,7 +2917,7 @@ public: void emitTypeWrapperClass(String *classname, SwigType *type) { String *swigtype = NewString(""); String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname); - File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); + File *f_swigtype = NewFile(filen, "w"); if (!f_swigtype) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx index 158b53502..4363cd813 100644 --- a/Source/Modules/directors.cxx +++ b/Source/Modules/directors.cxx @@ -84,7 +84,7 @@ String *Swig_director_declaration(Node *n) { } -String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) { +String *Swig_method_call(String_or_char *name, ParmList *parms) { String *func; int i = 0; int comma = 0; @@ -128,7 +128,7 @@ String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) { * */ -String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) { +String *Swig_method_decl(SwigType *returntype, SwigType *decl, const String_or_char *id, List *args, int strip, int values) { String *result; List *elements; String *element = 0, *nextelement; diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx index 0c72de8d0..f5f080034 100644 --- a/Source/Modules/guile.cxx +++ b/Source/Modules/guile.cxx @@ -47,7 +47,6 @@ Guile Options (available with -guile)\n\ -exportprimitive - Add the (export ...) code from scmstub into the\n\ GOOPS file.\n"; -static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; @@ -175,7 +174,7 @@ public: } } else if (strcmp(argv[i], "-procdoc") == 0) { if (argv[i + 1]) { - procdoc = NewFile(argv[i + 1], "w", SWIG_output_files()); + procdoc = NewFile(argv[i + 1], (char *) "w"); if (!procdoc) { FileErrorDisplay(argv[i + 1]); SWIG_exit(EXIT_FAILURE); @@ -300,12 +299,11 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -313,7 +311,6 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); @@ -325,10 +322,10 @@ public: goopscode = NewString(""); goopsexport = NewString(""); - Swig_banner(f_begin); + Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n"); + Swig_banner(f_runtime); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGGUILE\n"); + Printf(f_runtime, "/* Implementation : GUILE */\n\n"); if (!use_scm_interface) { if (SwigRuntime == 1) @@ -361,8 +358,6 @@ public: Printf(f_runtime, "\n}\n"); } - Printf(f_runtime, "\n"); - Language::top(n); /* Close module */ @@ -397,16 +392,14 @@ public: Delete(goopstext); /* Close all of the files */ - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); - Dump(f_wrappers, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_header, f_runtime); + Dump(f_wrappers, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); return SWIG_OK; } @@ -506,15 +499,15 @@ public: SWIG_output_directory(), primitive_name); Delete(primitive_name); - File *scmstubfile = NewFile(fname, "w", SWIG_output_files()); + File *scmstubfile = NewFile(fname, (char *) "w"); if (!scmstubfile) { FileErrorDisplay(fname); SWIG_exit(EXIT_FAILURE); } Delete(fname); - Swig_banner_target_lang(scmstubfile, ";;;"); - Printf(scmstubfile, "\n"); + Printf(scmstubfile, ";;; -*- buffer-read-only: t -*- vi: set ro: */\n"); + Printf(scmstubfile, ";;; Automatically generated by SWIG; do not edit.\n\n"); if (linkage == GUILE_LSTYLE_SIMPLE || linkage == GUILE_LSTYLE_PASSIVE) Printf(scmstubfile, "(define-module (%s))\n\n", mod); Delete(mod); @@ -537,14 +530,14 @@ public: String *fname = NewStringf("%s%s.scm", SWIG_output_directory(), module_name); - File *goopsfile = NewFile(fname, "w", SWIG_output_files()); + File *goopsfile = NewFile(fname, (char *) "w"); if (!goopsfile) { FileErrorDisplay(fname); SWIG_exit(EXIT_FAILURE); } Delete(fname); - Swig_banner_target_lang(goopsfile, ";;;"); - Printf(goopsfile, "\n"); + Printf(goopsfile, ";;; -*- buffer-read-only: t -*- vi: set ro: */\n"); + Printf(goopsfile, ";;; Automatically generated by SWIG; do not edit.\n\n"); Printf(goopsfile, "(define-module (%s))\n", mod); Printf(goopsfile, "%s\n", goopstext); Printf(goopsfile, "(use-modules (oop goops) (Swig common))\n"); @@ -1660,7 +1653,7 @@ public: * If class_name = "" that means the mapping is for a function or * variable not attached to any class. * ------------------------------------------------------------ */ - String *goopsNameMapping(String *name, const_String_or_char_ptr class_name) { + String *goopsNameMapping(String *name, String_or_char *class_name) { String *n = NewString(""); if (Strcmp(class_name, "") == 0) { diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 8dfa19624..b92fccdfb 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -24,7 +24,6 @@ class JAVA:public Language { const String *protected_string; Hash *swig_types_hash; - File *f_begin; File *f_runtime; File *f_runtime_h; File *f_header; @@ -71,7 +70,6 @@ class JAVA:public Language { String *imclass_cppcasts_code; //C++ casts up inheritance hierarchies intermediary class code String *imclass_directors; // Intermediate class director code String *destructor_call; //C++ destructor call if any - String *destructor_throws_clause; //C++ destructor throws clause if any // Director method stuff: List *dmethods_seq; @@ -83,7 +81,7 @@ class JAVA:public Language { enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum }; - static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) { + static Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) { Parm *p = NewParm(type, name); Setfile(p, Getfile(n)); Setline(p, Getline(n)); @@ -100,7 +98,6 @@ public: public_string(NewString("public")), protected_string(NewString("protected")), swig_types_hash(NULL), - f_begin(NULL), f_runtime(NULL), f_runtime_h(NULL), f_header(NULL), @@ -144,7 +141,6 @@ public: imclass_cppcasts_code(NULL), imclass_directors(NULL), destructor_call(NULL), - destructor_throws_clause(NULL), dmethods_seq(NULL), dmethods_table(NULL), n_dmethods(0), @@ -297,8 +293,8 @@ public: SWIG_exit(EXIT_FAILURE); } - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } @@ -308,14 +304,13 @@ public: Printf(stderr, "Unable to determine outfile_h\n"); SWIG_exit(EXIT_FAILURE); } - f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); + f_runtime_h = NewFile(outfile_h, "w"); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); } } - f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -323,7 +318,6 @@ public: f_directors = NewString(""); /* Register file targets with the SWIG file handler */ - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); Swig_register_filebyname("runtime", f_runtime); @@ -371,16 +365,13 @@ public: jnipackage = NewString(""); package_path = NewString(""); - Swig_banner(f_begin); - - Printf(f_runtime, "\n#define SWIGJAVA\n"); + Swig_banner(f_runtime); // Print the SWIG banner message if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); /* Emit initial director header and director code: */ Swig_banner(f_directors_h); - Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name); @@ -392,8 +383,6 @@ public: Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h)); } - Printf(f_runtime, "\n"); - String *wrapper_name = NewString(""); if (Len(package)) { @@ -431,7 +420,7 @@ public: // Generate the intermediary class { String *filen = NewStringf("%s%s.java", SWIG_output_directory(), imclass_name); - File *f_im = NewFile(filen, "w", SWIG_output_files()); + File *f_im = NewFile(filen, "w"); if (!f_im) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -482,7 +471,7 @@ public: // Generate the Java module class { String *filen = NewStringf("%s%s.java", SWIG_output_directory(), module_class_name); - File *f_module = NewFile(filen, "w", SWIG_output_files()); + File *f_module = NewFile(filen, "w"); if (!f_module) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -534,7 +523,7 @@ public: // Generate the Java constants interface if (Len(module_class_constants_code) != 0) { String *filen = NewStringf("%s%sConstants.java", SWIG_output_directory(), module_class_name); - File *f_module = NewFile(filen, "w", SWIG_output_files()); + File *f_module = NewFile(filen, "w"); if (!f_module) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -671,10 +660,8 @@ public: Delete(f_header); Delete(f_wrappers); Delete(f_init); - Dump(f_runtime, f_begin); + Close(f_runtime); Delete(f_runtime); - Close(f_begin); - Delete(f_begin); return SWIG_OK; } @@ -684,7 +671,11 @@ public: void emitBanner(File *f) { Printf(f, "/* ----------------------------------------------------------------------------\n"); - Swig_banner_target_lang(f, " *"); + Printf(f, " * This file was automatically generated by SWIG (http://www.swig.org).\n"); + Printf(f, " * Version %s\n", Swig_package_version()); + Printf(f, " *\n"); + Printf(f, " * Do not make changes to this file unless you know what you are doing--modify\n"); + Printf(f, " * the SWIG interface file instead.\n"); Printf(f, " * ----------------------------------------------------------------------------- */\n\n"); } @@ -1219,7 +1210,7 @@ public: } else { // Global enums are defined in their own file String *filen = NewStringf("%s%s.java", SWIG_output_directory(), symname); - File *f_enum = NewFile(filen, "w", SWIG_output_files()); + File *f_enum = NewFile(filen, "w"); if (!f_enum) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -1663,7 +1654,7 @@ public: else Replaceall(destruct, "$jnicall", "throw new UnsupportedOperationException(\"C++ destructor does not have public access\")"); if (*Char(destruct)) - Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL); + Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "() ", destruct, "\n", NIL); } /* Insert directordisconnect typemap, if this class has directors enabled */ @@ -1751,7 +1742,7 @@ public: } String *filen = NewStringf("%s%s.java", SWIG_output_directory(), proxy_class_name); - f_proxy = NewFile(filen, "w", SWIG_output_files()); + f_proxy = NewFile(filen, "w"); if (!f_proxy) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -1770,7 +1761,6 @@ public: Clear(proxy_class_code); destructor_call = NewString(""); - destructor_throws_clause = NewString(""); proxy_class_constants_code = NewString(""); } @@ -1829,8 +1819,6 @@ public: proxy_class_name = NULL; Delete(destructor_call); destructor_call = NULL; - Delete(destructor_throws_clause); - destructor_throws_clause = NULL; Delete(proxy_class_constants_code); proxy_class_constants_code = NULL; } @@ -2348,7 +2336,6 @@ public: if (proxy_flag) { Printv(destructor_call, imclass_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL); - generateThrowsClause(n, destructor_throws_clause); } return SWIG_OK; } @@ -2811,7 +2798,7 @@ public: void emitTypeWrapperClass(String *classname, SwigType *type) { String *swigtype = NewString(""); String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname); - File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); + File *f_swigtype = NewFile(filen, "w"); if (!f_swigtype) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -2883,7 +2870,7 @@ public: String *throws_attribute = NewStringf("%s:throws", attribute); String *throws = Getattr(parameter, throws_attribute); - if (throws && Len(throws) > 0) { + if (throws) { String *throws_list = Getattr(n, "java:throwslist"); if (!throws_list) { throws_list = NewList(); diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 38658ce9c..6718903d0 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -61,7 +61,7 @@ static String *AttributeFunctionGet = 0; static String *AttributeFunctionSet = 0; static Node *CurrentClass = 0; int line_number = 0; -String *input_file = 0; +char *input_file = 0; int SmartPointer = 0; static Hash *classhash; @@ -352,7 +352,7 @@ int Language::emit_one(Node *n) { Extend = 1; line_number = Getline(n); - input_file = Getfile(n); + input_file = Char(Getfile(n)); /* symtab = Getattr(n,"symtab"); @@ -830,8 +830,9 @@ int Language::cDeclaration(Node *n) { if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || is_non_virtual_protected_access(n)))) { return SWIG_NOWRAP; } - // Prevent wrapping protected overloaded director methods more than once - - // This bit of code is only needed due to the cDeclaration call in classHandler() +#if 0 +// I don't see why this is needed - WSF + /* prevent wrapping the method twice due to overload */ String *wrapname = NewStringf("nonpublic_%s%s", symname, Getattr(n, "sym:overname")); if (Getattr(CurrentClass, wrapname)) { Delete(wrapname); @@ -839,6 +840,7 @@ int Language::cDeclaration(Node *n) { } SetFlag(CurrentClass, wrapname); Delete(wrapname); +#endif } } @@ -1422,39 +1424,36 @@ int Language::membervariableHandler(Node *n) { target = NewStringf("%s->%s", pname, name); Delete(pname); } - } else { - target = NewStringf("$extendgetcall"); // member variable access expanded later + tm = Swig_typemap_lookup("memberin", n, target, 0); } - tm = Swig_typemap_lookup("memberin", n, target, 0); int flags = Extend | SmartPointer | use_naturalvar_mode(n); if (is_non_virtual_protected_access(n)) flags = flags | CWRAP_ALL_PROTECTED_ACCESS; - String *call = 0; - Swig_MembersetToFunction(n, ClassType, flags, &call); + Swig_MembersetToFunction(n, ClassType, flags); Setattr(n, "memberset", "1"); + if (!Extend) { + /* Check for a member in typemap here */ - if (!tm) { - if (SwigType_isarray(type)) { - Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0)); - make_set_wrapper = 0; + if (!tm) { + if (SwigType_isarray(type)) { + Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0)); + make_set_wrapper = 0; + } + } else { + String *pname0 = Swig_cparm_name(0, 0); + String *pname1 = Swig_cparm_name(0, 1); + Replace(tm, "$source", pname1, DOH_REPLACE_ANY); + Replace(tm, "$target", target, DOH_REPLACE_ANY); + Replace(tm, "$input", pname1, DOH_REPLACE_ANY); + Replace(tm, "$self", pname0, DOH_REPLACE_ANY); + Setattr(n, "wrap:action", tm); + Delete(tm); + Delete(pname0); + Delete(pname1); } - } else { - String *pname0 = Swig_cparm_name(0, 0); - String *pname1 = Swig_cparm_name(0, 1); - Replace(tm, "$source", pname1, DOH_REPLACE_ANY); - Replace(tm, "$target", target, DOH_REPLACE_ANY); - Replace(tm, "$input", pname1, DOH_REPLACE_ANY); - Replace(tm, "$self", pname0, DOH_REPLACE_ANY); - Replace(tm, "$extendgetcall", call, DOH_REPLACE_ANY); - Setattr(n, "wrap:action", tm); - Delete(tm); - Delete(pname0); - Delete(pname1); + Delete(target); } - Delete(call); - Delete(target); - if (make_set_wrapper) { Setattr(n, "sym:name", mrename_set); functionWrapper(n); @@ -2477,13 +2476,6 @@ int Language::classHandler(Node *n) { Node *m = Copy(method); Setattr(m, "director", "1"); Setattr(m, "parentNode", n); - /* - * There is a bug that needs fixing still... - * This area of code is creating methods which have not been overidden in a derived class (director methods that are protected in the base) - * If the method is overloaded, then Swig_overload_dispatch() incorrectly generates a call to the base wrapper, _wrap_xxx method - * See director_protected_overloaded.i - Possibly sym:overname needs correcting here. - Printf(stdout, "new method: %s::%s(%s)\n", Getattr(parentNode(m), "name"), Getattr(m, "name"), ParmList_str_defaultargs(Getattr(m, "parms"))); - */ cDeclaration(m); Delete(m); } @@ -2963,9 +2955,14 @@ Node *Language::classLookup(SwigType *s) { n = Getattr(classtypes, s); if (!n) { Symtab *stab = 0; +// SwigType *lt = SwigType_ltype(s); +// SwigType *ty1 = SwigType_typedef_resolve_all(lt); SwigType *ty1 = SwigType_typedef_resolve_all(s); SwigType *ty2 = SwigType_strip_qualifiers(ty1); +// Printf(stdout, " stages... ty1: %s ty2: %s\n", ty1, ty2); +// Delete(lt); Delete(ty1); +// lt = 0; ty1 = 0; String *base = SwigType_base(ty2); @@ -2974,12 +2971,6 @@ Node *Language::classLookup(SwigType *s) { Replaceall(base, "struct ", ""); Replaceall(base, "union ", ""); - if (strncmp(Char(base), "::", 2) == 0) { - String *oldbase = base; - base = NewString(Char(base) + 2); - Delete(oldbase); - } - String *prefix = SwigType_prefix(ty2); /* Do a symbol table search on the base type */ @@ -3053,12 +3044,6 @@ Node *Language::enumLookup(SwigType *s) { Replaceall(base, "enum ", ""); String *prefix = SwigType_prefix(ty2); - if (strncmp(Char(base), "::", 2) == 0) { - String *oldbase = base; - base = NewString(Char(base) + 2); - Delete(oldbase); - } - /* Look for type in symbol table */ while (!n) { Hash *nstab; diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx index 78cd7ce96..6113da960 100644 --- a/Source/Modules/lua.cxx +++ b/Source/Modules/lua.cxx @@ -92,7 +92,6 @@ NEW LANGUAGE NOTE:END ************************************************/ class LUA:public Language { private: - File *f_begin; File *f_runtime; File *f_header; File *f_wrappers; @@ -133,7 +132,6 @@ public: * --------------------------------------------------------------------- */ LUA() { - f_begin = 0; f_runtime = 0; f_header = 0; f_wrappers = 0; @@ -215,12 +213,11 @@ public: String *outfile = Getattr(n, "outfile"); /* Open the output file */ - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -229,7 +226,6 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("initbeforefunc", f_initbeforefunc); @@ -253,17 +249,11 @@ public: current=NO_CPP; /* Standard stuff for the SWIG runtime section */ - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGLUA\n"); - + Swig_banner(f_runtime); // if (NoInclude) { // Printf(f_runtime, "#define SWIG_NOINCLUDE\n"); // } - Printf(f_runtime, "\n"); - //String *init_name = NewStringf("%(title)s_Init", module); //Printf(f_header, "#define SWIG_init %s\n", init_name); //Printf(f_header, "#define SWIG_name \"%s\"\n", module); @@ -298,14 +288,13 @@ public: this basically combines several of the strings together and then writes it all to a file NEW LANGUAGE NOTE:END ************************************************/ - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); - Dump(f_wrappers, f_begin); - Dump(f_initbeforefunc, f_begin); + Dump(f_header, f_runtime); + Dump(f_wrappers, f_runtime); + Dump(f_initbeforefunc, f_runtime); /* for the Lua code it needs to be properly excaped to be added into the C/C++ code */ EscapeCode(s_luacode); - Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode); - Wrapper_pretty_print(f_init, f_begin); + Printf(f_runtime, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode); + Wrapper_pretty_print(f_init, f_runtime); /* Close all of the files */ Delete(s_luacode); Delete(s_cmd_tab); @@ -315,9 +304,8 @@ public: Delete(f_wrappers); Delete(f_init); Delete(f_initbeforefunc); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); /* Done */ return SWIG_OK; diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx index c824db6f9..901ee812e 100644 --- a/Source/Modules/main.cxx +++ b/Source/Modules/main.cxx @@ -117,8 +117,7 @@ static const char *usage3 = (const char *) "\ -fastdispatch -fvirtual \n\ -o - Set name of the output file to \n\ -oh - Set name of the output header file to \n\ - -outcurrentdir - Set default output dir to current dir instead of input file's path\n\ - -outdir - Set language specific files output directory to \n\ + -outdir - Set language specific files output directory \n\ -small - Compile in virtual elimination & compact mode\n\ -swiglib - Report location of SWIG library and exit\n\ -templatereduce - Reduce all the typedefs in templates\n\ @@ -154,7 +153,6 @@ static char *cpp_extension = (char *) "cxx"; static char *depends_extension = (char *) "d"; static String *outdir = 0; static String *xmlout = 0; -static int outcurrentdir = 0; static int help = 0; static int checkout = 0; static int cpp_only = 0; @@ -182,16 +180,14 @@ static String *dependencies_target = 0; static int external_runtime = 0; static String *external_runtime_name = 0; enum { STAGE1=1, STAGE2=2, STAGE3=4, STAGE4=8, STAGEOVERFLOW=16 }; -static List *all_output_files = 0; // ----------------------------------------------------------------------------- -// check_suffix() +// check_suffix(char *name) // // Checks the suffix of a file to see if we should emit extern declarations. // ----------------------------------------------------------------------------- -static int check_suffix(String *filename) { - const char *name = Char(filename); +static int check_suffix(const char *name) { const char *c; if (!name) return 0; @@ -285,7 +281,7 @@ static void set_outdir(const String *c_wrapper_file_dir) { } /* This function sets the name of the configuration file */ -void SWIG_config_file(const_String_or_char_ptr filename) { +void SWIG_config_file(const String_or_char *filename) { lang_config = NewString(filename); } @@ -304,11 +300,6 @@ void SWIG_config_cppext(const char *ext) { cpp_extension = (char *) ext; } -List *SWIG_output_files() { - assert(all_output_files); - return all_output_files; -} - void SWIG_setfeature(const char *cfeature, const char *cvalue) { Hash *features_hash = Swig_cparse_features(); String *name = NewString(""); @@ -372,14 +363,13 @@ static void SWIG_dump_runtime() { } } - runtime = NewFile(outfile, "w", SWIG_output_files()); + runtime = NewFile(outfile, "w"); if (!runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } Swig_banner(runtime); - Printf(runtime, "\n"); s = Swig_include_sys("swiglabels.swg"); if (!s) { @@ -698,9 +688,6 @@ void SWIG_getoptions(int argc, char *argv[]) { } else { Swig_arg_error(); } - } else if (strcmp(argv[i], "-outcurrentdir") == 0) { - Swig_mark_arg(i); - outcurrentdir = 1; } else if (strcmp(argv[i], "-Wall") == 0) { Swig_mark_arg(i); Swig_warnall(); @@ -880,7 +867,6 @@ int SWIG_main(int argc, char *argv[], Language *l) { } libfiles = NewList(); - all_output_files = NewList(); /* Check for SWIG_FEATURES environment variable */ @@ -938,13 +924,12 @@ int SWIG_main(int argc, char *argv[], Language *l) { // If we made it this far, looks good. go for it.... - input_file = NewString(argv[argc - 1]); - Swig_filename_correct(input_file); + input_file = argv[argc - 1]; // If the user has requested to check out a file, handle that if (checkout) { DOH *s; - char *outfile = Char(input_file); + char *outfile = input_file; if (outfile_name) outfile = outfile_name; @@ -953,26 +938,30 @@ int SWIG_main(int argc, char *argv[], Language *l) { s = Swig_include(input_file); if (!s) { - Printf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file); + fprintf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file); } else { - FILE *f = Swig_open(outfile); + FILE *f = fopen(outfile, "r"); if (f) { fclose(f); - Printf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile); + fprintf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile); } else { - File *f_outfile = NewFile(outfile, "w", SWIG_output_files()); - if (!f_outfile) { - FileErrorDisplay(outfile); - SWIG_exit(EXIT_FAILURE); - } else { - if (Verbose) - Printf(stdout, "'%s' checked out from the SWIG library.\n", outfile); - Printv(f_outfile, s, NIL); - Close(f_outfile); - } + f = fopen(outfile, "w"); + if (!f) { + fprintf(stderr, "Unable to create file '%s'\n", outfile); + } else { + if (Verbose) + fprintf(stdout, "'%s' checked out from the SWIG library.\n", input_file); + fputs(Char(s), f); + fclose(f); + } } } } else { + // Check the suffix for a .c file. If so, we're going to + // declare everything we see as "extern" + + ForceExtern = check_suffix(input_file); + // Run the preprocessor if (Verbose) printf("Preprocessing...\n"); @@ -982,22 +971,17 @@ int SWIG_main(int argc, char *argv[], Language *l) { String *fs = NewString(""); FILE *df = Swig_open(input_file); if (!df) { - df = Swig_include_open(input_file); - if (!df) { - char *cfile = Char(input_file); - if (cfile && cfile[0] == '-') { - Printf(stderr, "Unable to find option or file '%s', ", input_file); - Printf(stderr, "use 'swig -help' for more information.\n"); - } else { - Printf(stderr, "Unable to find file '%s'.\n", input_file); - } - SWIG_exit(EXIT_FAILURE); + char *cfile = Char(input_file); + if (cfile && cfile[0] == '-') { + Printf(stderr, "Unable to find option or file '%s', ", input_file); + Printf(stderr, "use 'swig -help' for more information.\n"); } else { - Swig_warning(WARN_DEPRECATED_INPUT_FILE, "SWIG", 1, "Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file.\n"); // so that behaviour is like c/c++ compilers + Printf(stderr, "Unable to find file '%s'.\n", input_file); } + SWIG_exit(EXIT_FAILURE); } + fclose(df); if (!no_cpp) { - fclose(df); Printf(fs, "%%include \n"); if (allkw) { Printf(fs, "%%include \n"); @@ -1005,7 +989,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (lang_config) { Printf(fs, "\n%%include <%s>\n", lang_config); } - Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_last_file()); + Printf(fs, "%%include \"%s\"\n", Swig_last_file()); for (i = 0; i < Len(libfiles); i++) { Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i)); } @@ -1013,8 +997,8 @@ int SWIG_main(int argc, char *argv[], Language *l) { cpps = Preprocessor_parse(fs); Delete(fs); } else { - cpps = Swig_read_file(df); - fclose(df); + df = Swig_open(input_file); + cpps = NewFileFromFile(df); } if (Swig_error_count()) { SWIG_exit(EXIT_FAILURE); @@ -1024,55 +1008,47 @@ int SWIG_main(int argc, char *argv[], Language *l) { SWIG_exit(EXIT_SUCCESS); } if (depend) { - if (!no_cpp) { - String *outfile; - - char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file)); - if (!outfile_name) { - if (CPlusPlus || lang->cplus_runtime_mode()) { - outfile = NewStringf("%s_wrap.%s", basename, cpp_extension); - } else { - outfile = NewStringf("%s_wrap.c", basename); - } + String *outfile; + if (!outfile_name) { + if (CPlusPlus || lang->cplus_runtime_mode()) { + outfile = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension); } else { - outfile = NewString(outfile_name); + outfile = NewStringf("%s_wrap.c", Swig_file_basename(input_file)); } - if (dependencies_file && Len(dependencies_file) != 0) { - f_dependencies_file = NewFile(dependencies_file, "w", SWIG_output_files()); - if (!f_dependencies_file) { - FileErrorDisplay(dependencies_file); - SWIG_exit(EXIT_FAILURE); - } - } else if (!depend_only) { - String *filename = NewStringf("%s_wrap.%s", basename, depends_extension); - f_dependencies_file = NewFile(filename, "w", SWIG_output_files()); - if (!f_dependencies_file) { - FileErrorDisplay(filename); - SWIG_exit(EXIT_FAILURE); - } - } else - f_dependencies_file = stdout; - if (dependencies_target) { - Printf(f_dependencies_file, "%s: ", dependencies_target); - } else { - Printf(f_dependencies_file, "%s: ", outfile); - } - List *files = Preprocessor_depend(); - for (int i = 0; i < Len(files); i++) { - if ((depend != 2) || ((depend == 2) && (Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) != 0))) { - Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i)); - } - } - Printf(f_dependencies_file, "\n"); - if (f_dependencies_file != stdout) - Close(f_dependencies_file); - if (depend_only) - SWIG_exit(EXIT_SUCCESS); } else { - Printf(stderr, "Cannot generate dependencies with -nopreprocess\n"); - // Actually we could but it would be inefficient when just generating dependencies, as it would be done after Swig_cparse - SWIG_exit(EXIT_FAILURE); + outfile = NewString(outfile_name); } + if (dependencies_file && Len(dependencies_file) != 0) { + f_dependencies_file = NewFile(dependencies_file, "w"); + if (!f_dependencies_file) { + FileErrorDisplay(dependencies_file); + SWIG_exit(EXIT_FAILURE); + } + } else if (!depend_only) { + String *filename = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), depends_extension); + f_dependencies_file = NewFile(filename, "w"); + if (!f_dependencies_file) { + FileErrorDisplay(filename); + SWIG_exit(EXIT_FAILURE); + } + } else + f_dependencies_file = stdout; + if (dependencies_target) { + Printf(f_dependencies_file, "%s: ", dependencies_target); + } else { + Printf(f_dependencies_file, "%s: ", outfile); + } + List *files = Preprocessor_depend(); + for (int i = 0; i < Len(files); i++) { + if ((depend != 2) || ((depend == 2) && (Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) != 0))) { + Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i)); + } + } + Printf(f_dependencies_file, "\n"); + if (f_dependencies_file != stdout) + Close(f_dependencies_file); + if (depend_only) + SWIG_exit(EXIT_SUCCESS); } Seek(cpps, 0, SEEK_SET); } @@ -1150,30 +1126,22 @@ int SWIG_main(int argc, char *argv[], Language *l) { } if (top) { if (!Getattr(top, "name")) { - Printf(stderr, "No module name specified using %%module or -module.\n"); + Printf(stderr, "*** No module name specified using %%module or -module.\n"); SWIG_exit(EXIT_FAILURE); } else { /* Set some filename information on the object */ - String *infile = scanner_get_main_input_file(); - if (!infile) { - Printf(stderr, "Missing input file in preprocessed output.\n"); - SWIG_exit(EXIT_FAILURE); - } - Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file - Setattr(top, "inputfile", input_file); - - char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(infile): Char(infile)); + Setattr(top, "infile", input_file); if (!outfile_name) { if (CPlusPlus || lang->cplus_runtime_mode()) { - Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension)); + Setattr(top, "outfile", NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension)); } else { - Setattr(top, "outfile", NewStringf("%s_wrap.c", basename)); + Setattr(top, "outfile", NewStringf("%s_wrap.c", Swig_file_basename(input_file))); } } else { Setattr(top, "outfile", outfile_name); } if (!outfile_name_h) { - Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", basename, hpp_extension)); + Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", Swig_file_basename(input_file), hpp_extension)); } else { Setattr(top, "outfile_h", outfile_name_h); } @@ -1181,12 +1149,7 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (Swig_contract_mode_get()) { Swig_contracts(top); } - - // Check the suffix for a c/c++ file. If so, we're going to declare everything we see as "extern" - ForceExtern = check_suffix(input_file); - lang->top(top); - if (browse) { Swig_browser(top, 0); } @@ -1210,21 +1173,6 @@ int SWIG_main(int argc, char *argv[], Language *l) { if (memory_debug) DohMemoryDebug(); - char *outfiles = getenv("CCACHE_OUTFILES"); - if (outfiles) { - File *f_outfiles = NewFile(outfiles, "w", 0); - if (!f_outfiles) { - Printf(stderr, "Failed to write list of output files to the filename '%s' specified in CCACHE_OUTFILES environment variable - ", outfiles); - FileErrorDisplay(outfiles); - SWIG_exit(EXIT_FAILURE); - } else { - int i; - for (i = 0; i < Len(all_output_files); i++) - Printf(f_outfiles, "%s\n", Getitem(all_output_files, i)); - Close(f_outfiles); - } - } - // Deletes Delete(libfiles); Preprocessor_delete(); diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx index b3568c0bf..6cb24d39a 100644 --- a/Source/Modules/modula3.cxx +++ b/Source/Modules/modula3.cxx @@ -127,7 +127,7 @@ char cvsroot_modula3_cxx[] = "$Id$"; #include // for INT_MAX #include -#define USAGE_ARG_DIR "m3wrapargdir typemap expect values: in, out, inout\n" +const char usageArgDir[] = "m3wrapargdir typemap expect values: in, out, inout\n"; class MODULA3:public Language { public: @@ -172,7 +172,6 @@ private: const String *empty_string; Hash *swig_types_hash; - File *f_begin; File *f_runtime; File *f_header; File *f_wrappers; @@ -238,7 +237,6 @@ public: MODULA3(): empty_string(NewString("")), swig_types_hash(NULL), - f_begin(NULL), f_runtime(NULL), f_header(NULL), f_wrappers(NULL), @@ -376,7 +374,7 @@ MODULA3(): } else if (Strcmp(dir, "out") == 0) { return false; } else { - printf("%s", USAGE_ARG_DIR); + printf(usageArgDir); return false; } } @@ -388,7 +386,7 @@ MODULA3(): } else if ((Strcmp(dir, "out") == 0) || (Strcmp(dir, "inout") == 0)) { return true; } else { - printf("%s", USAGE_ARG_DIR); + printf(usageArgDir); return false; } } @@ -544,7 +542,7 @@ MODULA3(): * ----------------------------------------------------------------------------- */ File *openWriteFile(String *name) { - File *file = NewFile(name, "w", SWIG_output_files()); + File *file = NewFile(name, "w"); if (!file) { FileErrorDisplay(name); SWIG_exit(EXIT_FAILURE); @@ -904,12 +902,11 @@ MODULA3(): /* Initialize all of the output files */ outfile = Getattr(n, "outfile"); - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -919,7 +916,6 @@ MODULA3(): /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); @@ -960,11 +956,7 @@ MODULA3(): module_imports = NewString(""); upcasts_code = NewString(""); - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGMODULA3\n"); - Printf(f_runtime, "\n"); + Swig_banner(f_runtime); // Print the SWIG banner message Swig_name_register((char *) "wrapper", (char *) "Modula3_%f"); if (old_variable_names) { @@ -1151,16 +1143,14 @@ MODULA3(): typemapfilename = NULL; /* Close all of the files */ - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); - Dump(f_wrappers, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_header, f_runtime); + Dump(f_wrappers, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); return SWIG_OK; } @@ -1169,9 +1159,14 @@ MODULA3(): * ----------------------------------------------------------------------------- */ void emitBanner(File *f) { - Printf(f, "(*******************************************************************************\n"); - Swig_banner_target_lang(f, " *"); - Printf(f, "*******************************************************************************)\n\n"); + Printf(f, "\ +(*******************************************************************************\n\ + * This file was automatically generated by SWIG (http://www.swig.org/).\n\ + * Version %s\n\ + *\n\ + * Do not make changes to this file unless you know what you are doing --\n\ + * modify the SWIG interface file instead.\n\ + *******************************************************************************)\n\n", Swig_package_version()); } /* ---------------------------------------------------------------------- @@ -2387,7 +2382,7 @@ MODULA3(): } String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), proxy_class_name); - f_proxy = NewFile(filen, "w", SWIG_output_files()); + f_proxy = NewFile(filen, "w"); if (!f_proxy) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -3179,7 +3174,8 @@ MODULA3(): Clear(result_m3wraptype); Printv(result_m3wraptype, tm, NIL); } else { - Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN, input_file, line_number, + Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN, + input_file, line_number, "Typemap m3wrapargdir set to 'out' for %s implies a RETURN value, but the routine %s has already one.\nUse %%multiretval feature.\n", SwigType_str(Getattr(p, "type"), 0), raw_name); } @@ -3766,7 +3762,7 @@ MODULA3(): void emitTypeWrapperClass(String *classname, SwigType *type) { String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname); - File *f_swigtype = NewFile(filen, "w", SWIG_output_files()); + File *f_swigtype = NewFile(filen, "w"); if (!f_swigtype) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx index 28dd8ecd2..78d4a4b65 100644 --- a/Source/Modules/mzscheme.cxx +++ b/Source/Modules/mzscheme.cxx @@ -39,7 +39,6 @@ static String *module = 0; static char *mzscheme_path = (char *) "mzscheme"; static String *init_func_def = 0; -static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; @@ -130,12 +129,11 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -143,17 +141,13 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); init_func_def = NewString(""); Swig_register_filebyname("init", init_func_def); - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGMZSCHEME\n"); - Printf(f_runtime, "\n"); + Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n"); + Swig_banner(f_runtime); module = Getattr(n, "name"); @@ -192,16 +186,14 @@ public: } /* Close all of the files */ - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); - Dump(f_wrappers, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_header, f_runtime); + Dump(f_wrappers, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx old mode 100644 new mode 100755 index b925328a3..9f5677ba5 --- a/Source/Modules/ocaml.cxx +++ b/Source/Modules/ocaml.cxx @@ -38,7 +38,6 @@ static Hash *seen_enumvalues = 0; static Hash *seen_constructors = 0; static File *f_header = 0; -static File *f_begin = 0; static File *f_runtime = 0; static File *f_wrappers = 0; static File *f_directors = 0; @@ -215,12 +214,11 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -249,7 +247,6 @@ public: Swig_register_filebyname("init", init_func_def); Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("mli", f_mlibody); Swig_register_filebyname("ml", f_mlbody); @@ -265,10 +262,7 @@ public: Swig_name_register("get", "%v__get__"); } - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGOCAML\n"); + Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n"); Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module); /* Module name */ Printf(f_mlbody, "let module_name = \"%s\"\n", module); @@ -282,12 +276,12 @@ public: Printf(f_int_to_enum, "let int_to_enum x y =\n" " match (x : c_enum_type) with\n" " `unknown -> C_enum (`Int y)\n"); + Swig_banner(f_runtime); + if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } - Printf(f_runtime, "\n"); - /* Produce the enum_to_int and int_to_enum functions */ Printf(f_enumtypes_type, "open Swig\n" "type c_enum_type = [ \n `unknown\n"); @@ -299,12 +293,12 @@ public: Printv(mlifile, module, ".mli", NIL); String *mlfilen = NewStringf("%s%s", SWIG_output_directory(), mlfile); - if ((f_mlout = NewFile(mlfilen, "w", SWIG_output_files())) == 0) { + if ((f_mlout = NewFile(mlfilen, "w")) == 0) { FileErrorDisplay(mlfilen); SWIG_exit(EXIT_FAILURE); } String *mlifilen = NewStringf("%s%s", SWIG_output_directory(), mlifile); - if ((f_mliout = NewFile(mlifilen, "w", SWIG_output_files())) == 0) { + if ((f_mliout = NewFile(mlifilen, "w")) == 0) { FileErrorDisplay(mlifilen); SWIG_exit(EXIT_FAILURE); } @@ -328,18 +322,16 @@ public: SwigType_emit_type_table(f_runtime, f_wrappers); /* Close all of the files */ - Dump(f_runtime, f_begin); Dump(f_directors_h, f_header); - Dump(f_header, f_begin); + Dump(f_header, f_runtime); Dump(f_directors, f_wrappers); - Dump(f_wrappers, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_wrappers, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); Dump(f_enumtypes_type, f_mlout); Dump(f_enumtypes_value, f_mlout); @@ -1300,50 +1292,56 @@ public: * which means looking up and registering by typedef and enum name. */ int enumDeclaration(Node *n) { String *name = Getattr(n, "name"); - if (name) { - String *oname = NewString(name); - /* name is now fully qualified */ - String *fully_qualified_name = NewString(name); - bool seen_enum = false; - if (name_qualifier) - Delete(name_qualifier); - char *strip_position; - name_qualifier = fully_qualify_enum_name(n, NewString("")); + String *oname = name ? NewString(name) : NULL; + /* name is now fully qualified */ + String *fully_qualified_name = NewString(name); + bool seen_enum = false; + if (name_qualifier) + Delete(name_qualifier); + char *strip_position; + name_qualifier = fully_qualify_enum_name(n, NewString("")); + /* Recent changes have distrubed enum and template naming again. + * Will try to keep it consistent by can't guarantee much given + * that these things move around a lot. + * + * I need to figure out a way to isolate this module better. + */ + if (oname) { strip_position = strstr(Char(oname), "::"); while (strip_position) { - strip_position += 2; - oname = NewString(strip_position); - strip_position = strstr(Char(oname), "::"); + strip_position += 2; + oname = NewString(strip_position); + strip_position = strstr(Char(oname), "::"); + } + } + + seen_enum = oname ? (Getattr(seen_enums, fully_qualified_name) ? true : false) : false; + + if (oname && !seen_enum) { + const_enum = true; + Printf(f_enum_to_int, "| `%s -> (match y with\n", oname); + Printf(f_int_to_enum, "| `%s -> C_enum (\n", oname); + /* * * * A note about enum name resolution * * * * + * This code should now work, but I think we can do a bit better. + * The problem I'm having is that swig isn't very precise about + * typedef name resolution. My opinion is that SwigType_typedef + * resolve_all should *always* return the enum tag if one exists, + * rather than the admittedly friendlier enclosing typedef. + * + * This would make one of the cases below unnecessary. + * * * */ + Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n", fully_qualified_name, oname); + if (!strncmp(Char(fully_qualified_name), "enum ", 5)) { + String *fq_noenum = NewString(Char(fully_qualified_name) + 5); + Printf(f_mlbody, + "let _ = Callback.register \"%s_marker\" (`%s)\n" "let _ = Callback.register \"%s_marker\" (`%s)\n", fq_noenum, oname, fq_noenum, name); } - seen_enum = (Getattr(seen_enums, fully_qualified_name) ? true : false); - - if (!seen_enum) { - const_enum = true; - Printf(f_enum_to_int, "| `%s -> (match y with\n", oname); - Printf(f_int_to_enum, "| `%s -> C_enum (\n", oname); - /* * * * A note about enum name resolution * * * * - * This code should now work, but I think we can do a bit better. - * The problem I'm having is that swig isn't very precise about - * typedef name resolution. My opinion is that SwigType_typedef - * resolve_all should *always* return the enum tag if one exists, - * rather than the admittedly friendlier enclosing typedef. - * - * This would make one of the cases below unnecessary. - * * * */ - Printf(f_mlbody, "let _ = Callback.register \"%s_marker\" (`%s)\n", fully_qualified_name, oname); - if (!strncmp(Char(fully_qualified_name), "enum ", 5)) { - String *fq_noenum = NewString(Char(fully_qualified_name) + 5); - Printf(f_mlbody, - "let _ = Callback.register \"%s_marker\" (`%s)\n" "let _ = Callback.register \"%s_marker\" (`%s)\n", fq_noenum, oname, fq_noenum, name); - } - - Printf(f_enumtypes_type, "| `%s\n", oname); - Insert(fully_qualified_name, 0, "enum "); - Setattr(seen_enums, fully_qualified_name, n); - } + Printf(f_enumtypes_type, "| `%s\n", oname); + Insert(fully_qualified_name, 0, "enum "); + Setattr(seen_enums, fully_qualified_name, n); } int ret = Language::enumDeclaration(n); diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx index c5ff2eb44..d582e8a6c 100644 --- a/Source/Modules/octave.cxx +++ b/Source/Modules/octave.cxx @@ -7,7 +7,7 @@ * Octave language module for SWIG. * ----------------------------------------------------------------------------- */ -char cvsroot_octave_cxx[] = "$Id: octave.cxx 10538 2008-06-21 14:51:02Z maciekd $"; +char cvsroot_octave_cxx[] = "$Id$"; #include "swigmod.h" @@ -18,7 +18,6 @@ Octave Options (available with -octave)\n\ class OCTAVE:public Language { private: - File *f_begin; File *f_runtime; File *f_header; File *f_doc; @@ -38,16 +37,9 @@ private: Hash *docs; public: - OCTAVE():f_begin(0), f_runtime(0), f_header(0), f_doc(0), f_wrappers(0), + OCTAVE():f_runtime(0), f_header(0), f_doc(0), f_wrappers(0), f_init(0), f_initbeforefunc(0), f_directors(0), f_directors_h(0), s_global_tab(0), s_members_tab(0), class_name(0) { - /* Add code to manage protected constructors and directors */ - director_prot_ctor_code = NewString(""); - Printv(director_prot_ctor_code, - "if ( $comparison ) { /* subclassed */\n", - " $director_new \n", - "} else {\n", " error(\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL); - enable_cplus_runtime_mode(); allow_overloading(); director_multiple_inheritance = 1; @@ -95,12 +87,11 @@ public: String *module = Getattr(n, "name"); String *outfile = Getattr(n, "outfile"); - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); f_header = NewString(""); f_doc = NewString(""); f_wrappers = NewString(""); @@ -109,7 +100,6 @@ public: f_directors_h = NewString(""); f_directors = NewString(""); s_global_tab = NewString(""); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("header", f_header); Swig_register_filebyname("doc", f_doc); @@ -118,16 +108,11 @@ public: Swig_register_filebyname("initbeforefunc", f_initbeforefunc); Swig_register_filebyname("director", f_directors); Swig_register_filebyname("director_h", f_directors_h); - - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGOCTAVE\n"); + Swig_banner(f_runtime); Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module); Printf(f_runtime, "#define SWIG_name %s\n", module); if (directorsEnabled()) { - Printf(f_runtime, "#define SWIG_DIRECTORS\n"); Swig_banner(f_directors_h); if (dirprot_mode()) { // Printf(f_directors_h, "#include \n"); @@ -135,7 +120,6 @@ public: } } - Printf(f_runtime, "\n"); Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n"); Printf(f_init, "static void SWIG_init_user(octave_swig_type* module_ns)\n{\n"); @@ -159,16 +143,15 @@ public: Printv(f_wrappers, s_global_tab, NIL); SwigType_emit_type_table(f_runtime, f_wrappers); - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); - Dump(f_doc, f_begin); + Dump(f_header, f_runtime); + Dump(f_doc, f_runtime); if (directorsEnabled()) { - Dump(f_directors_h, f_begin); - Dump(f_directors, f_begin); + Dump(f_directors_h, f_runtime); + Dump(f_directors, f_runtime); } - Dump(f_wrappers, f_begin); - Dump(f_initbeforefunc, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_wrappers, f_runtime); + Dump(f_initbeforefunc, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(s_global_tab); Delete(f_initbeforefunc); @@ -178,9 +161,8 @@ public: Delete(f_header); Delete(f_directors); Delete(f_directors_h); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); return SWIG_OK; } diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx index 511e55004..d16913885 100644 --- a/Source/Modules/overload.cxx +++ b/Source/Modules/overload.cxx @@ -316,7 +316,7 @@ static bool print_typecheck(String *f, int j, Parm *pj) { * ReplaceFormat() * ----------------------------------------------------------------------------- */ -static String *ReplaceFormat(const_String_or_char_ptr fmt, int j) { +static String *ReplaceFormat(const String_or_char *fmt, int j) { String *lfmt = NewString(fmt); char buf[50]; sprintf(buf, "%d", j); @@ -352,7 +352,7 @@ static String *ReplaceFormat(const_String_or_char_ptr fmt, int j) { /* Cast dispatch mechanism. */ -String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *maxargs) { +String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *maxargs) { int i, j; *maxargs = 1; @@ -536,7 +536,7 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int * /* Fast dispatch mechanism, provided by Salvador Fandi~no Garc'ia (#930586). */ -String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *maxargs) { +String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *maxargs) { int i, j; *maxargs = 1; @@ -695,7 +695,7 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int * return f; } -String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxargs) { +String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) { if (fast_dispatch_mode || GetFlag(n, "feature:fastdispatch")) { return Swig_overload_dispatch_fast(n, fmt, maxargs); diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx index eace179a7..6e706fc8d 100644 --- a/Source/Modules/perl5.cxx +++ b/Source/Modules/perl5.cxx @@ -78,7 +78,6 @@ static String *command_tab = 0; static String *constant_tab = 0; static String *variable_tab = 0; -static File *f_begin = 0; static File *f_runtime = 0; static File *f_header = 0; static File *f_wrappers = 0; @@ -208,7 +207,6 @@ public: } Preprocessor_define("SWIGPERL 1", 0); - // SWIGPERL5 is deprecated, and no longer documented. Preprocessor_define("SWIGPERL5 1", 0); SWIG_typemap_lang("perl5"); SWIG_config_file("perl5.swg"); @@ -224,12 +222,11 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -237,7 +234,6 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); @@ -256,12 +252,11 @@ public: constant_tab = NewString("static swig_constant_info swig_constants[] = {\n"); variable_tab = NewString("static swig_variable_info swig_variables[] = {\n"); - Swig_banner(f_begin); + Swig_banner(f_runtime); - Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGPERL\n"); Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n"); - Printf(f_runtime, "\n"); + // Is the imported module in another package? (IOW, does it use the // %module(package="name") option and it's different than the package @@ -320,7 +315,7 @@ public: pmfile = NewStringf("%s.pm", m); } String *filen = NewStringf("%s%s", SWIG_output_directory(), pmfile); - if ((f_pm = NewFile(filen, "w", SWIG_output_files())) == 0) { + if ((f_pm = NewFile(filen, "w")) == 0) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } @@ -337,7 +332,10 @@ public: Delete(boot_name); } - Swig_banner_target_lang(f_pm, "#"); + Printf(f_pm, "# This file was automatically generated by SWIG (http://www.swig.org).\n"); + Printf(f_pm, "# Version %s\n", Swig_package_version()); + Printf(f_pm, "#\n"); + Printf(f_pm, "# Don't modify this file, modify the SWIG interface instead.\n"); Printf(f_pm, "\n"); Printf(f_pm, "package %s;\n", module); @@ -526,16 +524,14 @@ public: Delete(underscore_module); /* Close all of the files */ - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); - Dump(f_wrappers, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_header, f_runtime); + Dump(f_wrappers, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); return SWIG_OK; } @@ -1145,9 +1141,8 @@ public: /* Do some work on the class name */ if (verbose > 0) { - String *modulename = Getattr(clsmodule, "name"); fprintf(stdout, "setclassname: Found sym:name: %s\n", Char(symname)); - fprintf(stdout, "setclassname: Found module: %s\n", Char(modulename)); + fprintf(stdout, "setclassname: Found module: %s\n", Char(clsmodule)); fprintf(stdout, "setclassname: No package found\n"); } @@ -1629,7 +1624,7 @@ public: } else if (Strcmp(code, "include") == 0) { /* Include a file into the .pm file */ if (value) { - FILE *f = Swig_include_open(value); + FILE *f = Swig_open(value); if (!f) { Printf(stderr, "%s : Line %d. Unable to locate file %s\n", input_file, line_number, value); } else { diff --git a/Source/Modules/php.cxx b/Source/Modules/php4.cxx similarity index 64% rename from Source/Modules/php.cxx rename to Source/Modules/php4.cxx index ee69c1864..42d71e79a 100644 --- a/Source/Modules/php.cxx +++ b/Source/Modules/php4.cxx @@ -2,9 +2,9 @@ * See the LICENSE file for information on copyright, usage and redistribution * of SWIG, and the README file for authors - http://www.swig.org/release.html. * - * php.cxx + * php4.cxx * - * PHP language module for SWIG. + * Php language module for SWIG. * ----------------------------------------------------------------------------- */ @@ -13,9 +13,11 @@ * Short term: * * Sort out auto-renaming of method and class names which are reserved - * words (e.g. empty, clone, exception, etc.) + * words (e.g. empty, clone, exception, etc.) vs -php4/-php5 in some + * sane way. * - * Sort out wrapping of static member variables in OO PHP5. + * Sort out wrapping of static member variables in OO PHP5 (which first may + * mean we need to sort them out for PHP4!) * * Medium term: * @@ -37,10 +39,10 @@ /* * TODO: Replace remaining stderr messages with Swig_error or Swig_warning - * (may need to add more WARN_PHP_xxx codes...) + * (may need to add more WARN_PHP4_xxx codes...) */ -char cvsroot_php_cxx[] = "$Id$"; +char cvsroot_php4_cxx[] = "$Id$"; #include "swigmod.h" @@ -48,13 +50,19 @@ char cvsroot_php_cxx[] = "$Id$"; #include static const char *usage = (char *) "\ -PHP Options (available with -php)\n\ +PHP Options (available with -php4 or -php5)\n\ -cppext - cpp file extension (default to .cpp)\n\ -noproxy - Don't generate proxy classes.\n\ - -prefix - Prepend to all class names in PHP wrappers\n\ + -prefix - Prepend to all class names in PHP5 wrappers\n\ + -make - Create simple makefile\n\ + -phpfull - Create full make files\n\ + -withincs - With -phpfull writes needed incs in config.m4\n\ + -withlibs - With -phpfull writes needed libs in config.m4\n\ + -withc - With -phpfull makes extra C files in Makefile.in\n\ + -withcxx - With -phpfull makes extra C++ files in Makefile.in\n\ \n"; -/* The original class wrappers for PHP stored the pointer to the C++ class in +/* The original class wrappers for PHP4 store the pointer to the C++ class in * the object property _cPtr. If we use the same name for the member variable * which we put the pointer to the C++ class in, then the flat function * wrappers will automatically pull it out without any changes being required. @@ -68,10 +76,16 @@ static Node *classnode = 0; static String *module = 0; static String *cap_module = 0; static String *prefix = 0; +static String *withlibs = 0; +static String *withincs = 0; +static String *withc = 0; +static String *withcxx = 0; static String *shadow_classname = 0; -static File *f_begin = 0; +static int gen_extra = 0; +static int gen_make = 0; + static File *f_runtime = 0; static File *f_h = 0; static File *f_phpcode = 0; @@ -102,6 +116,9 @@ static Node *current_class = 0; static Hash *shadow_get_vars; static Hash *shadow_set_vars; +#define NATIVE_CONSTRUCTOR 1 +#define ALTERNATIVE_CONSTRUCTOR 2 +static int native_constructor = 0; static Hash *zend_types = 0; static int shadow = 1; @@ -142,7 +159,7 @@ void SwigPHP_emit_resource_registrations() { Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key); // write out body - if (class_node != NOTCLASS) { + if ((class_node != NOTCLASS)) { String *destructor = Getattr(class_node, "destructor"); human_name = Getattr(class_node, "sym:name"); if (!human_name) @@ -173,9 +190,12 @@ void SwigPHP_emit_resource_registrations() { } } -class PHP : public Language { +class PHP:public Language { + int php_version; + public: - PHP() { } + PHP(int php_version_):php_version(php_version_) { + } /* Test to see if a type corresponds to something wrapped with a shadow class. */ @@ -196,57 +216,327 @@ public: * ------------------------------------------------------------ */ virtual void main(int argc, char *argv[]) { - SWIG_library_directory("php"); + int i; + SWIG_library_directory("php4"); SWIG_config_cppext("cpp"); - for (int i = 1; i < argc; i++) { - if (strcmp(argv[i], "-prefix") == 0) { - if (argv[i + 1]) { - prefix = NewString(argv[i + 1]); + for (i = 1; i < argc; i++) { + if (argv[i]) { + if (strcmp(argv[i], "-phpfull") == 0) { + gen_extra = 1; Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); - } - } else if (strcmp(argv[i], "-cppext") == 0) { - if (argv[i + 1]) { - SWIG_config_cppext(argv[i + 1]); + } else if (strcmp(argv[i], "-dlname") == 0) { + Printf(stderr, "*** -dlname is no longer supported\n*** if you want to change the module name, use -module instead.\n"); + SWIG_exit(EXIT_FAILURE); + } else if (strcmp(argv[i], "-prefix") == 0) { + if (argv[i + 1]) { + prefix = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-withlibs") == 0) { + if (argv[i + 1]) { + withlibs = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-withincs") == 0) { + if (argv[i + 1]) { + withincs = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-withc") == 0) { + if (argv[i + 1]) { + withc = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-withcxx") == 0) { + if (argv[i + 1]) { + withcxx = NewString(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if (strcmp(argv[i], "-cppext") == 0) { + if (argv[i + 1]) { + SWIG_config_cppext(argv[i + 1]); + Swig_mark_arg(i); + Swig_mark_arg(i + 1); + i++; + } else { + Swig_arg_error(); + } + } else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) { + shadow = 0; Swig_mark_arg(i); - Swig_mark_arg(i + 1); - i++; - } else { - Swig_arg_error(); + } else if (strcmp(argv[i], "-make") == 0) { + gen_make = 1; + Swig_mark_arg(i); + } else if (strcmp(argv[i], "-help") == 0) { + fputs(usage, stdout); } - } else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) { - shadow = 0; - Swig_mark_arg(i); - } else if (strcmp(argv[i], "-help") == 0) { - fputs(usage, stdout); - } else if (strcmp(argv[i], "-make") == 0 || - strcmp(argv[i], "-withc") == 0 || - strcmp(argv[i], "-withcxx") == 0) { - Printf(stderr, "*** %s is no longer supported.\n", argv[i]); - SWIG_exit(EXIT_FAILURE); - } else if (strcmp(argv[i], "-phpfull") == 0 || - strcmp(argv[i], "-withlibs") == 0 || - strcmp(argv[i], "-withincs") == 0) { - Printf(stderr, "*** %s is no longer supported.\n*** We recommend building as a dynamically loadable module.\n", argv[i]); - SWIG_exit(EXIT_FAILURE); - } else if (strcmp(argv[i], "-dlname") == 0) { - Printf(stderr, "*** -dlname is no longer supported.\n*** If you want to change the module name, use -module instead.\n"); - SWIG_exit(EXIT_FAILURE); } } - Preprocessor_define("SWIGPHP 1", 0); - // SWIGPHP5 is deprecated, and no longer documented. - Preprocessor_define("SWIGPHP5 1", 0); - SWIG_typemap_lang("php"); - SWIG_config_file("php.swg"); + Preprocessor_define((void *) "SWIGPHP 1", 0); + if (php_version == 4) { + Preprocessor_define((void *) "SWIGPHP4 1", 0); + } else if (php_version == 5) { + Preprocessor_define((void *) "SWIGPHP5 1", 0); + } + SWIG_typemap_lang("php4"); + /* DB: Suggest using a language configuration file */ + SWIG_config_file("php4.swg"); allow_overloading(); } + void create_simple_make(void) { + File *f_make; + + f_make = NewFile((void *) "makefile", "w"); + Printf(f_make, "CC=gcc\n"); + Printf(f_make, "CXX=g++\n"); + Printf(f_make, "CXX_SOURCES=%s\n", withcxx); + Printf(f_make, "C_SOURCES=%s\n", withc); + Printf(f_make, "OBJS=%s_wrap.o $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cxx=.o)\n", module); + Printf(f_make, "MODULE=%s.so\n", module); + Printf(f_make, "CFLAGS=-fpic\n"); + Printf(f_make, "LDFLAGS=-shared\n"); + Printf(f_make, "PHP_INC=`php-config --includes`\n"); + Printf(f_make, "EXTRA_INC=\n"); + Printf(f_make, "EXTRA_LIB=\n\n"); + Printf(f_make, "$(MODULE): $(OBJS)\n"); + if (CPlusPlus || (withcxx != NULL)) { + Printf(f_make, "\t$(CXX) $(LDFLAGS) $(OBJS) -o $@ $(EXTRA_LIB)\n\n"); + } else { + Printf(f_make, "\t$(CC) $(LDFLAGS) $(OBJS) -o $@ $(EXTRA_LIB)\n\n"); + } + Printf(f_make, "%%.o: %%.cpp\n"); + Printf(f_make, "\t$(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); + Printf(f_make, "%%.o: %%.cxx\n"); + Printf(f_make, "\t$(CXX) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); + Printf(f_make, "%%.o: %%.c\n"); + Printf(f_make, "\t$(CC) $(EXTRA_INC) $(PHP_INC) $(CFLAGS) -c $<\n"); + + Close(f_make); + } + + void create_extra_files(String *outfile) { + File *f_extra; + + static String *configm4 = 0; + static String *makefilein = 0; + static String *credits = 0; + + configm4 = NewStringEmpty(); + Printv(configm4, SWIG_output_directory(), "config.m4", NIL); + + makefilein = NewStringEmpty(); + Printv(makefilein, SWIG_output_directory(), "Makefile.in", NIL); + + credits = NewStringEmpty(); + Printv(credits, SWIG_output_directory(), "CREDITS", NIL); + + // are we a --with- or --enable- + int with = (withincs || withlibs) ? 1 : 0; + + // Note Makefile.in only copes with one source file + // also withincs and withlibs only take one name each now + // the code they generate should be adapted to take multiple lines + + /* Write out Makefile.in */ + f_extra = NewFile(makefilein, "w"); + if (!f_extra) { + FileErrorDisplay(makefilein); + SWIG_exit(EXIT_FAILURE); + } + + Printf(f_extra, "# $Id$\n\n" "LTLIBRARY_NAME = %s.la\n", module); + + // C++ has more and different entries to C in Makefile.in + if (!CPlusPlus) { + Printf(f_extra, "LTLIBRARY_SOURCES = %s %s\n", Swig_file_filename(outfile), withc); + Printf(f_extra, "LTLIBRARY_SOURCES_CPP = %s\n", withcxx); + } else { + Printf(f_extra, "LTLIBRARY_SOURCES = %s\n", withc); + Printf(f_extra, "LTLIBRARY_SOURCES_CPP = %s %s\n", Swig_file_filename(outfile), withcxx); + Printf(f_extra, "LTLIBRARY_OBJECTS_X = $(LTLIBRARY_SOURCES_CPP:.cpp=.lo) $(LTLIBRARY_SOURCES_CPP:.cxx=.lo)\n"); + } + Printf(f_extra, "LTLIBRARY_SHARED_NAME = %s.la\n", module); + Printf(f_extra, "LTLIBRARY_SHARED_LIBADD = $(%s_SHARED_LIBADD)\n\n", cap_module); + Printf(f_extra, "include $(top_srcdir)/build/dynlib.mk\n"); + + Printf(f_extra, "\n# patch in .cxx support to php build system to work like .cpp\n"); + Printf(f_extra, ".SUFFIXES: .cxx\n\n"); + + Printf(f_extra, ".cxx.o:\n"); + Printf(f_extra, "\t$(CXX_COMPILE) -c $<\n\n"); + + Printf(f_extra, ".cxx.lo:\n"); + Printf(f_extra, "\t$(CXX_PHP_COMPILE)\n\n"); + Printf(f_extra, ".cxx.slo:\n"); + + Printf(f_extra, "\t$(CXX_SHARED_COMPILE)\n\n"); + + Printf(f_extra, "\n# make it easy to test module\n"); + Printf(f_extra, "testmodule:\n"); + Printf(f_extra, "\tphp -q -d extension_dir=modules %s\n\n", Swig_file_filename(phpfilename)); + + Close(f_extra); + + /* Now config.m4 */ + // Note: # comments are OK in config.m4 if you don't mind them + // appearing in the final ./configure file + // (which can help with ./configure debugging) + + // NOTE2: phpize really ought to be able to write out a sample + // config.m4 based on some simple data, I'll take this up with + // the php folk! + f_extra = NewFile(configm4, "w"); + if (!f_extra) { + FileErrorDisplay(configm4); + SWIG_exit(EXIT_FAILURE); + } + + Printf(f_extra, "dnl $Id$\n"); + Printf(f_extra, "dnl ***********************************************************************\n"); + Printf(f_extra, "dnl ** THIS config.m4 is provided for PHPIZE and PHP's consumption NOT\n"); + Printf(f_extra, "dnl ** for any part of the rest of the %s build system\n", module); + Printf(f_extra, "dnl ***********************************************************************\n\n"); + + + if (!with) { // must be enable then + Printf(f_extra, "PHP_ARG_ENABLE(%s, whether to enable %s support,\n", module, module); + Printf(f_extra, "[ --enable-%s Enable %s support])\n\n", module, module); + } else { + Printf(f_extra, "PHP_ARG_WITH(%s, for %s support,\n", module, module); + Printf(f_extra, "[ --with-%s[=DIR] Include %s support.])\n\n", module, module); + // These tests try and file the library we need + Printf(f_extra, "dnl THESE TESTS try and find the library and header files\n"); + Printf(f_extra, "dnl your new php module needs. YOU MAY NEED TO EDIT THEM\n"); + Printf(f_extra, "dnl as written they assume your header files are all in the same place\n\n"); + + Printf(f_extra, "dnl ** are we looking for %s_lib.h or something else?\n", module); + if (withincs) + Printf(f_extra, "HNAMES=\"%s\"\n\n", withincs); + else + Printf(f_extra, "HNAMES=\"\"; # %s_lib.h ?\n\n", module); + + Printf(f_extra, "dnl ** Are we looking for lib%s.a or lib%s.so or something else?\n", module, module); + + if (withlibs) + Printf(f_extra, "LIBNAMES=\"%s\"\n\n", withlibs); + else + Printf(f_extra, "LIBNAMES=\"\"; # lib%s.so ?\n\n", module); + + Printf(f_extra, "dnl IF YOU KNOW one of the symbols in the library and you\n"); + Printf(f_extra, "dnl specify it below then we can have a link test to see if it works\n"); + Printf(f_extra, "LIBSYMBOL=\"\"\n\n"); + } + + // Now write out tests to find thing.. they may need to extend tests + Printf(f_extra, "if test \"$PHP_%s\" != \"no\"; then\n\n", cap_module); + + // Ready for when we add libraries as we find them + Printf(f_extra, " PHP_SUBST(%s_SHARED_LIBADD)\n\n", cap_module); + + if (withlibs) { // find more than one library + Printf(f_extra, " for LIBNAME in $LIBNAMES ; do\n"); + Printf(f_extra, " LIBDIR=\"\"\n"); + // For each path element to try... + Printf(f_extra, " for i in $PHP_%s $PHP_%s/lib /usr/lib /usr/local/lib ; do\n", cap_module, cap_module); + Printf(f_extra, " if test -r $i/lib$LIBNAME.a -o -r $i/lib$LIBNAME.so ; then\n"); + Printf(f_extra, " LIBDIR=\"$i\"\n"); + Printf(f_extra, " break\n"); + Printf(f_extra, " fi\n"); + Printf(f_extra, " done\n\n"); + Printf(f_extra, " dnl ** and $LIBDIR should be the library path\n"); + Printf(f_extra, " if test \"$LIBNAME\" != \"\" -a -z \"$LIBDIR\" ; then\n"); + Printf(f_extra, " AC_MSG_RESULT(Library files $LIBNAME not found)\n"); + Printf(f_extra, " AC_MSG_ERROR(Is the %s distribution installed properly?)\n", module); + Printf(f_extra, " else\n"); + Printf(f_extra, " AC_MSG_RESULT(Library files $LIBNAME found in $LIBDIR)\n"); + Printf(f_extra, " PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIBDIR, %s_SHARED_LIBADD)\n", cap_module); + Printf(f_extra, " fi\n"); + Printf(f_extra, " done\n\n"); + } + + if (withincs) { // Find more than once include + Printf(f_extra, " for HNAME in $HNAMES ; do\n"); + Printf(f_extra, " INCDIR=\"\"\n"); + // For each path element to try... + Printf(f_extra, " for i in $PHP_%s $PHP_%s/include $PHP_%s/includes $PHP_%s/inc $PHP_%s/incs /usr/local/include /usr/include; do\n", cap_module, + cap_module, cap_module, cap_module, cap_module); + // Try and find header files + Printf(f_extra, " if test \"$HNAME\" != \"\" -a -r $i/$HNAME ; then\n"); + Printf(f_extra, " INCDIR=\"$i\"\n"); + Printf(f_extra, " break\n"); + Printf(f_extra, " fi\n"); + Printf(f_extra, " done\n\n"); + + Printf(f_extra, " dnl ** Now $INCDIR should be the include file path\n"); + Printf(f_extra, " if test \"$HNAME\" != \"\" -a -z \"$INCDIR\" ; then\n"); + Printf(f_extra, " AC_MSG_RESULT(Include files $HNAME not found)\n"); + Printf(f_extra, " AC_MSG_ERROR(Is the %s distribution installed properly?)\n", module); + Printf(f_extra, " else\n"); + Printf(f_extra, " AC_MSG_RESULT(Include files $HNAME found in $INCDIR)\n"); + Printf(f_extra, " PHP_ADD_INCLUDE($INCDIR)\n"); + Printf(f_extra, " fi\n\n"); + Printf(f_extra, " done\n\n"); + } + + if (CPlusPlus) { + Printf(f_extra, " # As this is a C++ module..\n"); + } + + Printf(f_extra, " PHP_REQUIRE_CXX\n"); + Printf(f_extra, " AC_CHECK_LIB(stdc++, cin)\n"); + + if (with) { + Printf(f_extra, " if test \"$LIBSYMBOL\" != \"\" ; then\n"); + Printf(f_extra, " old_LIBS=\"$LIBS\"\n"); + Printf(f_extra, " LIBS=\"$LIBS -L$TEST_DIR/lib -lm -ldl\"\n"); + Printf(f_extra, " AC_CHECK_LIB($LIBNAME, $LIBSYMBOL, [AC_DEFINE(HAVE_TESTLIB,1, [ ])],\n"); + Printf(f_extra, " [AC_MSG_ERROR(wrong test lib version or lib not found)])\n"); + Printf(f_extra, " LIBS=\"$old_LIBS\"\n"); + Printf(f_extra, " fi\n\n"); + } + + Printf(f_extra, " AC_DEFINE(HAVE_%s, 1, [ ])\n", cap_module); + Printf(f_extra, "dnl AC_DEFINE_UNQUOTED(PHP_%s_DIR, \"$%s_DIR\", [ ])\n", cap_module, cap_module); + Printf(f_extra, " PHP_EXTENSION(%s, $ext_shared)\n", module); + + // and thats all! + Printf(f_extra, "fi\n"); + + Close(f_extra); + + /* CREDITS */ + f_extra = NewFile(credits, "w"); + if (!f_extra) { + FileErrorDisplay(credits); + SWIG_exit(EXIT_FAILURE); + } + Printf(f_extra, "%s\n", module); + Close(f_extra); + } + /* ------------------------------------------------------------ * top() * ------------------------------------------------------------ */ @@ -260,12 +550,13 @@ public: String *outfile = Getattr(n, "outfile"); /* main output file */ - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); + + Swig_banner(f_runtime); /* sections of the output file */ s_init = NewString("/* init section */\n"); @@ -284,7 +575,6 @@ public: s_phpclasses = NewString("/* PHP Proxy Classes */\n"); /* Register file targets with the SWIG file handler */ - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", s_init); Swig_register_filebyname("rinit", r_init); @@ -293,12 +583,6 @@ public: Swig_register_filebyname("header", s_header); Swig_register_filebyname("wrapper", s_wrappers); - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGPHP\n"); - Printf(f_runtime, "\n"); - /* Set the module name */ module = Copy(Getattr(n, "name")); cap_module = NewStringf("%(upper)s", module); @@ -310,7 +594,7 @@ public: Printv(filen, SWIG_output_directory(), module, ".php", NIL); phpfilename = NewString(filen); - f_phpcode = NewFile(filen, "w", SWIG_output_files()); + f_phpcode = NewFile(filen, "w"); if (!f_phpcode) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -320,14 +604,14 @@ public: Swig_banner(f_phpcode); - Printf(f_phpcode, "\n"); Printf(f_phpcode, "// Try to load our extension if it's not already loaded.\n"); Printf(f_phpcode, "if (!extension_loaded(\"%s\")) {\n", module); Printf(f_phpcode, " if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {\n"); Printf(f_phpcode, " if (!dl('php_%s.dll')) return;\n", module); Printf(f_phpcode, " } else {\n"); - Printf(f_phpcode, " // PHP_SHLIB_SUFFIX gives 'dylib' on MacOS X but modules are 'so'.\n"); - Printf(f_phpcode, " if (PHP_SHLIB_SUFFIX === 'dylib') {\n"); + Printf(f_phpcode, " // PHP_SHLIB_SUFFIX is available as of PHP 4.3.0, for older PHP assume 'so'.\n"); + Printf(f_phpcode, " // It gives 'dylib' on MacOS X which is for libraries, modules are 'so'.\n"); + Printf(f_phpcode, " if (PHP_SHLIB_SUFFIX === 'PHP_SHLIB_SUFFIX' || PHP_SHLIB_SUFFIX === 'dylib') {\n"); Printf(f_phpcode, " if (!dl('%s.so')) return;\n", module); Printf(f_phpcode, " } else {\n"); Printf(f_phpcode, " if (!dl('%s.'.PHP_SHLIB_SUFFIX)) return;\n", module); @@ -390,7 +674,7 @@ public: /* Create the .h file too */ filen = NewStringEmpty(); Printv(filen, SWIG_output_directory(), "php_", module, ".h", NIL); - f_h = NewFile(filen, "w", SWIG_output_files()); + f_h = NewFile(filen, "w"); if (!f_h) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); @@ -398,7 +682,7 @@ public: Swig_banner(f_h); - Printf(f_h, "\n"); + Printf(f_h, "\n\n"); Printf(f_h, "#ifndef PHP_%s_H\n", cap_module); Printf(f_h, "#define PHP_%s_H\n\n", cap_module); Printf(f_h, "extern zend_module_entry %s_module_entry;\n", module); @@ -443,6 +727,9 @@ public: Printf(s_init, "};\n"); Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module); + if (gen_extra) { + Printf(s_init, "#ifdef COMPILE_DL_%s\n", cap_module); + } Printf(s_init, "#ifdef __cplusplus\n"); Printf(s_init, "extern \"C\" {\n"); Printf(s_init, "#endif\n"); @@ -453,6 +740,10 @@ public: Printf(s_init, "}\n"); Printf(s_init, "#endif\n\n"); + if (gen_extra) { + Printf(s_init, "#endif\n\n"); + } + /* We have to register the constants before they are (possibly) used * by the pointer typemaps. This all needs re-arranging really as * things are being called in the wrong order @@ -527,19 +818,16 @@ public: Printf(s_wrappers, "/* end wrapper section */\n"); Printf(s_vdecl, "/* end vdecl subsection */\n"); - Dump(f_runtime, f_begin); - Printv(f_begin, s_header, s_vdecl, s_wrappers, NIL); - Printv(f_begin, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL); - Printv(f_begin, s_init, NIL); + Printv(f_runtime, s_header, s_vdecl, s_wrappers, NIL); + Printv(f_runtime, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL); + Printv(f_runtime, s_init, NIL); Delete(s_header); Delete(s_wrappers); Delete(s_init); Delete(s_vdecl); Delete(all_cs_entry); Delete(s_entry); - Close(f_begin); - Delete(f_runtime); - Delete(f_begin); + Close(f_runtime); Printf(f_phpcode, "%s\n%s\n", pragma_incl, pragma_code); if (s_fakeoowrappers) { @@ -552,12 +840,22 @@ public: Printf(f_phpcode, "%s\n?>\n", s_phpclasses); Close(f_phpcode); + if (gen_extra) { + create_extra_files(outfile); + } else if (gen_make) { + create_simple_make(); + } + return SWIG_OK; } /* Just need to append function names to function table to register with PHP. */ void create_command(String *cname, String *iname) { // This is for the single main zend_function_entry record + if (shadow && php_version == 4) { + if (wrapperType != standard) + return; + } Printf(f_h, "ZEND_NAMED_FUNCTION(%s);\n", iname); String * s = cs_entry; if (!s) s = s_entry; @@ -574,6 +872,8 @@ public: String *tmp = NewStringEmpty(); String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs); + int has_this_ptr = (wrapperType == memberfn && shadow && php_version == 4); + /* Generate a dispatch wrapper for all overloaded functions */ Wrapper *f = NewWrapper(); @@ -590,7 +890,13 @@ public: Printf(f->code, "argc = ZEND_NUM_ARGS();\n"); - Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); + if (has_this_ptr) { + Printf(f->code, "argv[0] = &this_ptr;\n"); + Printf(f->code, "zend_get_parameters_array_ex(argc,argv+1);\n"); + Printf(f->code, "argc++;\n"); + } else { + Printf(f->code, "zend_get_parameters_array_ex(argc,argv);\n"); + } Replaceall(dispatch, "$args", "self,args"); @@ -598,7 +904,7 @@ public: Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n"); Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname); - Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n", NIL); + Printv(f->code, "zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());\n", NIL); Printv(f->code, "}\n", NIL); Wrapper_print(f, s_wrappers); @@ -639,6 +945,8 @@ public: int numopt; String *tm; Wrapper *f; + bool mvr = (shadow && php_version == 4 && wrapperType == membervar); + bool mvrset = (mvr && (Strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, name))) == 0)); String *wname; int overloaded = 0; @@ -663,6 +971,19 @@ public: if (overname) { Printf(wname, "%s", overname); } + // if PHP4, shadow and variable wrapper we want to snag the main contents + // of this function to stick in to the property handler... + if (mvr) { + String *php_function_name = NewString(iname); + if (Strcmp(iname, Swig_name_set(Swig_name_member(shadow_classname, name))) == 0) { + Setattr(shadow_set_vars, php_function_name, name); + } + if (Strcmp(iname, Swig_name_get(Swig_name_member(shadow_classname, name))) == 0) { + Setattr(shadow_get_vars, php_function_name, name); + } + + Delete(php_function_name); + } f = NewWrapper(); numopt = 0; @@ -670,11 +991,20 @@ public: String *outarg = NewStringEmpty(); String *cleanup = NewStringEmpty(); - // Not issued for overloaded functions or static member variables. - if (!overloaded && wrapperType != staticmembervar) { - create_command(iname, wname); + if (mvr) { // do prop[gs]et header + if (mvrset) { + Printf(f->def, "static int _wrap_%s(zend_property_reference *property_reference, pval *value) {\n", iname); + } else { + Printf(f->def, "static pval _wrap_%s(zend_property_reference *property_reference) {\n", iname); + } + } else { + // regular header + // Not issued for overloaded functions or static member variables. + if (!overloaded && wrapperType != staticmembervar) { + create_command(iname, wname); + } + Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); } - Printv(f->def, "ZEND_NAMED_FUNCTION(", wname, ") {\n", NIL); emit_parameter_variables(l, f); /* Attach standard typemaps */ @@ -688,8 +1018,10 @@ public: int num_required = emit_num_required(l); numopt = num_arguments - num_required; - if (num_arguments > 0) { - String *args = NewStringf("zval **args[%d]", num_arguments); + int has_this_ptr = (wrapperType == memberfn && shadow && php_version == 4); + + if (num_arguments - has_this_ptr > 0) { + String *args = NewStringf("zval **args[%d]", num_arguments - has_this_ptr); Wrapper_add_local(f, "args", args); Delete(args); args = NULL; @@ -704,22 +1036,39 @@ public: Printf(f->code, "SWIG_ResetError();\n"); + if (has_this_ptr) + Printf(f->code, "/* This function uses a this_ptr*/\n"); + + if (native_constructor) { + if (native_constructor == NATIVE_CONSTRUCTOR) { + Printf(f->code, "/* NATIVE Constructor */\n"); + } else { + Printf(f->code, "/* ALTERNATIVE Constructor */\n"); + } + } + + if (mvr && !mvrset) { + Wrapper_add_local(f, "_return_value", "zval _return_value"); + Wrapper_add_local(f, "return_value", "zval *return_value=&_return_value"); + } + if (numopt > 0) { // membervariable wrappers do not have optional args Wrapper_add_local(f, "arg_count", "int arg_count"); Printf(f->code, "arg_count = ZEND_NUM_ARGS();\n"); Printf(f->code, "if(arg_count<%d || arg_count>%d ||\n", num_required, num_arguments); Printf(f->code, " zend_get_parameters_array_ex(arg_count,args)!=SUCCESS)\n"); Printf(f->code, "\tWRONG_PARAM_COUNT;\n\n"); - } else { - if (num_arguments == 0) { + } else if (!mvr) { + int num = num_arguments - has_this_ptr; + if (num == 0) { Printf(f->code, "if(ZEND_NUM_ARGS() != 0) {\n"); } else { - Printf(f->code, "if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\n", num_arguments, num_arguments); + Printf(f->code, "if(ZEND_NUM_ARGS() != %d || zend_get_parameters_array_ex(%d, args) != SUCCESS) {\n", num, num); } Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n"); } - /* Now convert from PHP to C variables */ + /* Now convert from php to C variables */ // At this point, argcount if used is the number of deliberately passed args // not including this_ptr even if it is used. // It means error messages may be out by argbase with error @@ -740,7 +1089,19 @@ public: SwigType *pt = Getattr(p, "type"); - source = NewStringf("args[%d]", i); + if (mvr) { // do we assert that numargs=2, that i<2 + if (i == 0) { + source = NewString("&(property_reference->object)"); + } else { + source = NewString("&value"); + } + } else { + if (i == 0 && has_this_ptr) { + source = NewString("&this_ptr"); + } else { + source = NewStringf("args[%d]", i - has_this_ptr); + } + } String *ln = Getattr(p, "lname"); @@ -822,6 +1183,24 @@ public: Replaceall(tm, "$result", "return_value"); Replaceall(tm, "$owner", newobject ? "1" : "0"); Printf(f->code, "%s\n", tm); + // Are we returning a wrapable object? + if (shadow && php_version == 4 && is_shadow(d) && (SwigType_type(d) != T_ARRAY)) { + // Make object. + Printf(f->code, "{\n/* Wrap this return value */\n"); + Printf(f->code, "zval *_cPtr;\n"); + Printf(f->code, "ALLOC_ZVAL(_cPtr);\n"); + Printf(f->code, "*_cPtr = *return_value;\n"); + Printf(f->code, "INIT_ZVAL(*return_value);\n"); + if (native_constructor == NATIVE_CONSTRUCTOR) { + Printf(f->code, "add_property_zval(this_ptr,\"" SWIG_PTR "\",_cPtr);\n"); + } else { + String *shadowrettype = GetShadowReturnType(n); + Printf(f->code, "object_init_ex(return_value,ptr_ce_swig_%s);\n", shadowrettype); + Delete(shadowrettype); + Printf(f->code, "add_property_zval(return_value,\"" SWIG_PTR "\",_cPtr);\n"); + } + Printf(f->code, "}\n"); + } } else { Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(d, 0), name); } @@ -849,12 +1228,21 @@ public: Delete(tm); } - Printf(f->code, "return;\n"); + + if (mvr) { + if (!mvrset) { + Printf(f->code, "return _return_value;\n"); + } else { + Printf(f->code, "return SUCCESS;\n"); + } + } else { + Printf(f->code, "return;\n"); + } /* Error handling code */ Printf(f->code, "fail:\n"); Printv(f->code, cleanup, NIL); - Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL); + Printv(f->code, "zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());", NIL); Printf(f->code, "}\n"); @@ -870,7 +1258,7 @@ public: Delete(wname); wname = NULL; - if (!shadow) { + if (!(shadow && php_version == 5)) { DelWrapper(f); return SWIG_OK; } @@ -1113,8 +1501,7 @@ public: case T_LONG: { char *p; errno = 0; - unsigned int n = strtol(Char(value), &p, 0); - (void) n; + (void) strtol(Char(value), &p, 0); if (errno || *p) { Clear(value); Append(value, "?"); @@ -1127,8 +1514,7 @@ public: case T_ULONG: { char *p; errno = 0; - unsigned int n = strtoul(Char(value), &p, 0); - (void) n; + (void) strtoul(Char(value), &p, 0); if (errno || *p) { Clear(value); Append(value, "?"); @@ -1252,8 +1638,8 @@ public: Setattr(seen, "this", seen); /* We use $r to store the return value, so disallow that as a parameter * name in case the user uses the "call-time pass-by-reference" feature - * (it's deprecated and off by default in PHP5, but we want to be - * maximally portable). + * (it's deprecated and off by default in PHP5 and even later PHP4 + * versions apparently, but we want to be maximally portable). */ Setattr(seen, "r", seen); @@ -1369,26 +1755,16 @@ public: Printf(output, "\n"); // If it's a member function or a class constructor... if (wrapperType == memberfn || (newobject && current_class)) { + Printf(output, "\tfunction %s(%s) {\n", methodname, args); // We don't need this code if the wrapped class has a copy ctor // since the flat function new_CLASSNAME will handle it for us. if (newobject && !Getattr(current_class, "allocate:copy_constructor")) { - const char * arg0; - if (max_num_of_arguments > 0) { - arg0 = Char(arg_names[0]); - } else { - arg0 = "res"; - Delete(args); - args = NewString("$res=null"); - } SwigType *t = Getattr(current_class, "classtype"); String *mangled_type = SwigType_manglestr(SwigType_ltype(t)); - Printf(output, "\tfunction %s(%s) {\n", methodname, args); - Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg0, arg0, mangled_type); - Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0); - Printf(output, "\t\t\treturn;\n"); - Printf(output, "\t\t}\n"); - } else { - Printf(output, "\tfunction %s(%s) {\n", methodname, args); + Printf(s_oowrappers, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg_names[0], arg_names[0], mangled_type); + Printf(s_oowrappers, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg_names[0]); + Printf(s_oowrappers, "\t\t\treturn;\n"); + Printf(s_oowrappers, "\t\t}\n"); } } else { Printf(output, "\tstatic function %s(%s) {\n", methodname, args); @@ -1501,7 +1877,8 @@ public: Replaceall(tm, "$symname", iname); Printf(f_c->code, "%s\n", tm); } else { - Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0)); + Printf(stderr,"%s: Line %d, Unable to link with type %s\n", + input_file, line_number, SwigType_str(t, 0)); } */ /* Now generate C -> PHP sync blocks */ @@ -1513,7 +1890,8 @@ public: Replaceall(tm, "$symname", iname); Printf(f_php->code, "%s\n", tm); } else { - Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0)); + Printf(stderr,"%s: Line %d, Unable to link with type %s\n", + input_file, line_number, SwigType_str(t, 0)); } } */ @@ -1544,7 +1922,7 @@ public: Printf(s_cinit, "%s\n", tm); } - if (shadow) { + if (shadow && php_version == 5) { String *enumvalue = GetChar(n, "enumvalue"); String *set_to = iname; @@ -1586,8 +1964,8 @@ public: * * Pragma directive. * - * %pragma(php) code="String" # Includes a string in the .php file - * %pragma(php) include="file.pl" # Includes a file in the .php file + * %pragma(php4) code="String" # Includes a string in the .php file + * %pragma(php4) include="file.pl" # Includes a file in the .php file */ virtual int pragmaDirective(Node *n) { @@ -1596,7 +1974,7 @@ public: String *type = Getattr(n, "name"); String *value = Getattr(n, "value"); - if (Strcmp(lang, "php") == 0 || Strcmp(lang, "php4") == 0) { + if (Strcmp(lang, "php4") == 0) { if (Strcmp(type, "code") == 0) { if (value) { Printf(pragma_code, "%s\n", value); @@ -1610,7 +1988,7 @@ public: Printf(pragma_phpinfo, "%s\n", value); } } else { - Swig_warning(WARN_PHP_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type); + Swig_warning(WARN_PHP4_UNKNOWN_PRAGMA, input_file, line_number, "Unrecognized pragma <%s>.\n", type); } } } @@ -1640,7 +2018,52 @@ public: current_class = n; // String *use_class_name=SwigType_manglestr(SwigType_ltype(t)); - if (shadow) { + if (shadow && php_version == 4) { + char *rename = GetChar(n, "sym:name"); + + if (!addSymbol(rename, n)) + return SWIG_ERROR; + shadow_classname = NewString(rename); + cs_entry = NewStringEmpty(); + Printf(cs_entry, "/* Function entries for %s */\n", shadow_classname); + Printf(cs_entry, "static zend_function_entry %s_functions[] = {\n", shadow_classname); + + if (Strcmp(shadow_classname, module) == 0) { + Printf(stderr, "class name cannot be equal to module name: %s\n", module); + SWIG_exit(1); + } + + shadow_get_vars = NewHash(); + shadow_set_vars = NewHash(); + + /* Deal with inheritance */ + List *baselist = Getattr(n, "bases"); + if (baselist) { + Iterator base = First(baselist); + while (base.item && GetFlag(base.item, "feature:ignore")) { + base = Next(base); + } + base = Next(base); + if (base.item) { + /* Warn about multiple inheritance for additional base class(es) */ + while (base.item) { + if (GetFlag(base.item, "feature:ignore")) { + base = Next(base); + continue; + } + String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); + String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); + Swig_warning(WARN_PHP4_MULTIPLE_INHERITANCE, input_file, line_number, + "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Php4.\n", proxyclassname, baseclassname); + base = Next(base); + } + } + } + + /* Write out class init code */ + Printf(s_vdecl, "static zend_class_entry ce_swig_%s;\n", shadow_classname); + Printf(s_vdecl, "static zend_class_entry* ptr_ce_swig_%s=NULL;\n", shadow_classname); + } else if (shadow && php_version == 5) { char *rename = GetChar(n, "sym:name"); if (!addSymbol(rename, n)) @@ -1667,7 +2090,7 @@ public: } String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0); String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0); - Swig_warning(WARN_PHP_MULTIPLE_INHERITANCE, input_file, line_number, + Swig_warning(WARN_PHP4_MULTIPLE_INHERITANCE, input_file, line_number, "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in PHP.\n", proxyclassname, baseclassname); base = Next(base); } @@ -1679,7 +2102,217 @@ public: Language::classHandler(n); classnode = 0; - if (shadow) { + if (shadow && php_version == 4) { + DOH *key; + String *s_propget = NewStringEmpty(); + String *s_propset = NewStringEmpty(); + List *baselist = Getattr(n, "bases"); + Iterator ki, base; + + // If no constructor was generated (abstract class) we had better + // generate a constructor that raises an error about instantiating + // abstract classes + if (Getattr(n, "abstract") && constructors == 0) { + // have to write out fake constructor which raises an error when called + abstractConstructorHandler(n); + } + + Printf(s_oinit, "/* Define class %s */\n", shadow_classname); + Printf(s_oinit, "INIT_OVERLOADED_CLASS_ENTRY(ce_swig_%s,\"%(lower)s\",%s_functions,", shadow_classname, shadow_classname, shadow_classname); + Printf(s_oinit, "NULL,_wrap_propget_%s,_wrap_propset_%s);\n", shadow_classname, shadow_classname); + + // ******** Write property SET handlers + Printf(s_header, "static int _wrap_propset_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); + Printf(s_header, "static int _propset_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); + + Printf(s_propset, "static int _wrap_propset_%s(zend_property_reference *property_reference, pval *value) { \n", shadow_classname); + Printf(s_propset, " zval * _value;\n"); + Printf(s_propset, " zend_llist_element *element = property_reference->elements_list->head;\n"); + Printf(s_propset, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); + Printf(s_propset, " if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", shadow_classname); + Printf(s_propset, " /* set it ourselves as it is %s */\n", shadow_classname); + Printf(s_propset, " MAKE_STD_ZVAL(_value);\n"); + Printf(s_propset, " *_value=*value;\n"); + Printf(s_propset, " INIT_PZVAL(_value);\n"); + Printf(s_propset, " zval_copy_ctor(_value);\n"); + Printf(s_propset, + " return add_property_zval_ex(property_reference->object,Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),_value);\n"); + Printf(s_propset, "}\n"); + Printf(s_propset, "static int _propset_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname); + + + if (baselist) { + base = First(baselist); + } else { + base.item = NULL; + } + + while (base.item && GetFlag(base.item, "feature:ignore")) { + base = Next(base); + } + + ki = First(shadow_set_vars); + key = ki.key; + + // Print function header; we only need to find property name if there + // are properties for this class to look up... + if (key || !base.item) { // or if we are base class and set it ourselves + Printf(s_propset, " /* get the property name */\n"); + Printf(s_propset, " zend_llist_element *element = property_reference->elements_list->head;\n"); + Printf(s_propset, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); + Printf(s_propset, " char *propname=Z_STRVAL_P(&(property->element));\n"); + } else { + if (base.item) { + Printf(s_propset, " /* No extra properties for subclass %s */\n", shadow_classname); + } else { + Printf(s_propset, " /* No properties for base class %s */\n", shadow_classname); + } + } + + while (ki.key) { + key = ki.key; + Printf(s_propset, " if (strcmp(propname,\"%s\")==0) return _wrap_%s(property_reference, value);\n", ki.item, key); + + ki = Next(ki); + } + + // If the property wasn't in this class, try the handlers of each base + // class (if any) in turn until we succeed in setting the property or + // have tried all base classes. + if (base.item) { + Printf(s_propset, " /* Try base class(es) */\n"); + while (base.item) { + Printf(s_propset, " if (_propset_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", GetChar(base.item, "sym:name")); + + base = Next(base); + while (base.item && GetFlag(base.item, "feature:ignore")) { + base = Next(base); + } + } + } + Printf(s_propset, " return FAILURE;\n}\n\n"); + + // ******** Write property GET handlers + Printf(s_header, "static pval _wrap_propget_%s(zend_property_reference *property_reference);\n", shadow_classname); + Printf(s_header, "static int _propget_%s(zend_property_reference *property_reference, pval *value);\n", shadow_classname); + + Printf(s_propget, "static pval _wrap_propget_%s(zend_property_reference *property_reference) {\n", shadow_classname); + Printf(s_propget, " pval result;\n"); + Printf(s_propget, " pval **_result;\n"); + Printf(s_propget, " zend_llist_element *element = property_reference->elements_list->head;\n"); + Printf(s_propget, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); + Printf(s_propget, " result.type = IS_NULL;\n"); + Printf(s_propget, " if (_propget_%s(property_reference, &result)==SUCCESS) return result;\n", shadow_classname); + Printf(s_propget, " /* return it ourselves */\n"); + Printf(s_propget, + " if (zend_hash_find(Z_OBJPROP_P(property_reference->object),Z_STRVAL_P(&(property->element)),1+Z_STRLEN_P(&(property->element)),(void**)&_result)==SUCCESS) {\n"); + Printf(s_propget, " zval *_value;\n"); + Printf(s_propget, " MAKE_STD_ZVAL(_value);"); + Printf(s_propget, " *_value=**_result;\n"); + Printf(s_propget, " INIT_PZVAL(_value);\n"); + Printf(s_propget, " zval_copy_ctor(_value);\n"); + Printf(s_propget, " return *_value;\n"); + Printf(s_propget, " }\n"); + Printf(s_propget, " result.type = IS_NULL;\n"); + Printf(s_propget, " return result;\n"); + Printf(s_propget, "}\n"); + Printf(s_propget, "static int _propget_%s(zend_property_reference *property_reference, pval *value) {\n", shadow_classname); + + if (baselist) { + base = First(baselist); + } else { + base.item = NULL; + } + while (base.item && GetFlag(base.item, "feature:ignore")) { + base = Next(base); + } + ki = First(shadow_get_vars); + + key = ki.key; + + // Print function header; we only need to find property name if there + // are properties for this class to look up... + if (key || !base.item) { // or if we are base class... + Printf(s_propget, " /* get the property name */\n"); + Printf(s_propget, " zend_llist_element *element = property_reference->elements_list->head;\n"); + Printf(s_propget, " zend_overloaded_element *property=(zend_overloaded_element *)element->data;\n"); + Printf(s_propget, " char *propname=Z_STRVAL_P(&(property->element));\n"); + } else { + if (base.item) { + Printf(s_propget, " /* No extra properties for subclass %s */\n", shadow_classname); + } else { + Printf(s_propget, " /* No properties for base class %s */\n", shadow_classname); + } + } + + while (ki.key) { + key = ki.key; + Printf(s_propget, " if (strcmp(propname,\"%s\")==0) {\n", ki.item); + Printf(s_propget, " *value=_wrap_%s(property_reference);\n", key); + Printf(s_propget, " return SUCCESS;\n"); + Printf(s_propget, " }\n"); + + ki = Next(ki); + } + + // If the property wasn't in this class, try the handlers of each base + // class (if any) in turn until we succeed in setting the property or + // have tried all base classes. + if (base.item) { + Printf(s_propget, " /* Try base class(es). */\n"); + while (base.item) { + Printf(s_propget, " if (_propget_%s(property_reference, value)==SUCCESS) return SUCCESS;\n", GetChar(base.item, "sym:name")); + + base = Next(base); + while (base.item && GetFlag(base.item, "feature:ignore")) { + base = Next(base); + } + } + } + Printf(s_propget, " return FAILURE;\n}\n\n"); + + // wrappers generated now... + + // add wrappers to output code + Printf(s_wrappers, "/* property handler for class %s */\n", shadow_classname); + Printv(s_wrappers, s_propget, s_propset, NIL); + + // Save class in class table + if (baselist) { + base = First(baselist); + } else { + base.item = NULL; + } + while (base.item && GetFlag(base.item, "feature:ignore")) { + base = Next(base); + } + + if (base.item) { + Printf(s_oinit, + "if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,&ce_swig_%s,NULL TSRMLS_CC))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n", + shadow_classname, shadow_classname, GetChar(base.item, "sym:name"), shadow_classname); + } else { + Printf(s_oinit, + "if (! (ptr_ce_swig_%s=zend_register_internal_class_ex(&ce_swig_%s,NULL,NULL TSRMLS_CC))) zend_error(E_ERROR,\"Error registering wrapper for class %s\");\n", + shadow_classname, shadow_classname, shadow_classname); + } + Printf(s_oinit, "\n"); + + // Write the enum initialisation code in a static block + // These are all the enums defined within the C++ class. + + Delete(shadow_classname); + shadow_classname = NULL; + + Delete(shadow_set_vars); + shadow_set_vars = NULL; + Delete(shadow_get_vars); + shadow_get_vars = NULL; + + Printv(all_cs_entry, cs_entry, " { NULL, NULL, NULL}\n};\n", NIL); + Delete(cs_entry); + cs_entry = NULL; + } else if (shadow && php_version == 5) { DOH *key; List *baselist = Getattr(n, "bases"); Iterator ki, base; @@ -1801,10 +2434,21 @@ public: * ------------------------------------------------------------ */ virtual int memberfunctionHandler(Node *n) { + char *name = GetChar(n, "name"); + char *iname = GetChar(n, "sym:name"); + wrapperType = memberfn; this->Language::memberfunctionHandler(n); wrapperType = standard; + // Only declare the member function if + // we are doing shadow classes, and the function + // is not overloaded, or if it is overloaded, it is the dispatch function. + if (shadow && php_version == 4 && (!Getattr(n, "sym:overloaded") || !Getattr(n, "sym:nextSibling"))) { + char *realname = iname ? iname : name; + String *php_function_name = Swig_name_member(shadow_classname, realname); + create_command(realname, Swig_name_wrapper(php_function_name)); + } return SWIG_OK; } @@ -1813,6 +2457,7 @@ public: * ------------------------------------------------------------ */ virtual int membervariableHandler(Node *n) { + wrapperType = membervar; Language::membervariableHandler(n); wrapperType = standard; @@ -1825,6 +2470,7 @@ public: * ------------------------------------------------------------ */ virtual int staticmembervariableHandler(Node *n) { + wrapperType = staticmembervar; Language::staticmembervariableHandler(n); wrapperType = standard; @@ -1834,7 +2480,7 @@ public: String *iname = Getattr(n, "sym:name"); /* A temporary(!) hack for static member variables. - * PHP currently supports class functions, but not class variables. + * Php currently supports class functions, but not class variables. * Until it does, we convert a class variable to a class function * that returns the current value of the variable. E.g. * @@ -1843,16 +2489,15 @@ public: * static int ncount; * }; * - * would be available in PHP as Example::ncount() + * would be available in php as Example::ncount() */ - // If the variable is const, then it's wrapped as a constant with set/get - // functions. + // If the variable is const, then it's wrapped as a constant with set/get functions. if (SwigType_isconst(type)) return SWIG_OK; - // This duplicates the logic from Language::variableWrapper() to test if - // the set wrapper is made. + // This duplicates the logic from Language::variableWrapper() to test if the set wrapper + // is made. int assignable = is_assignable(n); if (assignable) { String *tm = Swig_typemap_lookup("globalin", n, name, 0); @@ -1897,10 +2542,20 @@ public: * ------------------------------------------------------------ */ virtual int staticmemberfunctionHandler(Node *n) { + char *name = GetChar(n, "name"); + char *iname = GetChar(n, "sym:name"); + wrapperType = staticmemberfn; Language::staticmemberfunctionHandler(n); wrapperType = standard; + if (shadow && php_version == 4) { + String *symname = Getattr(n, "sym:name"); + char *realname = iname ? iname : name; + String *php_function_name = Swig_name_member(shadow_classname, realname); + create_command(symname, Swig_name_wrapper(php_function_name)); + } + return SWIG_OK; } @@ -1942,7 +2597,7 @@ public: return NewStringEmpty(); } - String *PhpTypeFromTypemap(char *op, Node *n, const_String_or_char_ptr lname) { + String *PhpTypeFromTypemap(char *op, Node *n, String_or_char *lname) { String *tms = Swig_typemap_lookup(op, n, lname, 0); if (!tms) return 0; @@ -1950,20 +2605,54 @@ public: return NewStringf("%s", tms); } - int abstractConstructorHandler(Node *) { + int abstractConstructorHandler(Node *n) { + String *iname = GetChar(n, "sym:name"); + if (shadow && php_version == 4) { + Wrapper *f = NewWrapper(); + + String *wname = NewStringf("_wrap_new_%s", iname); + create_command(iname, wname); + + Printf(f->def, "ZEND_NAMED_FUNCTION(_wrap_new_%s) {\n", iname); + Printf(f->def, " zend_error(E_ERROR,\"Cannot create swig object type: %s as the underlying class is abstract\");\n", iname); + Printf(f->def, "}\n\n"); + Wrapper_print(f, s_wrappers); + DelWrapper(f); + Delete(wname); + } return SWIG_OK; } - /* ------------------------------------------------------------ * constructorHandler() * ------------------------------------------------------------ */ virtual int constructorHandler(Node *n) { + char *name = GetChar(n, "name"); + char *iname = GetChar(n, "sym:name"); + + if (shadow && php_version == 4) { + if (iname && strcmp(iname, Char(shadow_classname)) == 0) { + native_constructor = NATIVE_CONSTRUCTOR; + } else { + native_constructor = ALTERNATIVE_CONSTRUCTOR; + } + } else { + native_constructor = 0; + } constructors++; wrapperType = constructor; Language::constructorHandler(n); wrapperType = standard; + if (shadow && php_version == 4) { + if (!Getattr(n, "sym:overloaded") || !Getattr(n, "sym:nextSibling")) { + char *realname = iname ? iname : name; + String *php_function_name = Swig_name_construct(realname); + create_command(realname, Swig_name_wrapper(php_function_name)); + } + } + + native_constructor = 0; return SWIG_OK; } @@ -2018,6 +2707,7 @@ public: Wrapper_print(f, s_wrappers); return SWIG_OK; + } /* ------------------------------------------------------------ @@ -2025,7 +2715,7 @@ public: * ------------------------------------------------------------ */ virtual int memberconstantHandler(Node *n) { - wrapping_member_constant = Getattr(n, "sym:name"); + wrapping_member_constant = Getattr(n, "name"); Language::memberconstantHandler(n); wrapping_member_constant = NULL; return SWIG_OK; @@ -2033,6 +2723,10 @@ public: }; /* class PHP */ +/* ----------------------------------------------------------------------------- + * swig_php() - Instantiate module + * ----------------------------------------------------------------------------- */ + static PHP *maininstance = 0; // We use this function to be able to write out zend_register_list_destructor_ex @@ -2059,12 +2753,8 @@ extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) { (*r_prevtracefunc) (ty, mangled, (String *) clientdata); } -/* ----------------------------------------------------------------------------- - * new_swig_php() - Instantiate module - * ----------------------------------------------------------------------------- */ - -static Language *new_swig_php() { - maininstance = new PHP; +static Language *new_swig_php(int php_version) { + maininstance = new PHP(php_version); if (!r_prevtracefunc) { r_prevtracefunc = SwigType_remember_trace(typetrace); } else { @@ -2073,14 +2763,9 @@ static Language *new_swig_php() { } return maininstance; } - extern "C" Language *swig_php4(void) { - Printf(stderr, "*** -php4 is no longer supported.\n" - "*** Either upgrade to PHP5 or use SWIG 1.3.36 or earlier.\n"); - SWIG_exit(EXIT_FAILURE); - return NULL; // To avoid compiler warnings. + return new_swig_php(4); } - -extern "C" Language *swig_php(void) { - return new_swig_php(); +extern "C" Language *swig_php5(void) { + return new_swig_php(5); } diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx index 98f63056c..30f9b3d74 100644 --- a/Source/Modules/pike.cxx +++ b/Source/Modules/pike.cxx @@ -39,7 +39,6 @@ Pike Options (available with -pike)\n\ class PIKE:public Language { private: - File *f_begin; File *f_runtime; File *f_header; File *f_wrappers; @@ -70,7 +69,6 @@ public: * --------------------------------------------------------------------- */ PIKE() { - f_begin = 0; f_runtime = 0; f_header = 0; f_wrappers = 0; @@ -125,12 +123,11 @@ public: String *outfile = Getattr(n, "outfile"); /* Open the output file */ - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); f_init = NewString(""); f_classInit = NewString(""); f_header = NewString(""); @@ -139,17 +136,12 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("classInit", f_classInit); /* Standard stuff for the SWIG runtime section */ - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGPIKE\n"); - Printf(f_runtime, "\n"); + Swig_banner(f_runtime); Printf(f_header, "#define SWIG_init pike_module_init\n"); Printf(f_header, "#define SWIG_name \"%s\"\n\n", module); @@ -169,19 +161,17 @@ public: SwigType_emit_type_table(f_runtime, f_wrappers); /* Close all of the files */ - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); - Dump(f_wrappers, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_header, f_runtime); + Dump(f_wrappers, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_classInit); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); /* Done */ return SWIG_OK; @@ -231,7 +221,7 @@ public: * name (i.e. "enum_test"). * ------------------------------------------------------------ */ - String *strip(const DOHconst_String_or_char_ptr name) { + String *strip(const DOHString_or_char *name) { String *s = Copy(name); if (Strncmp(name, PrefixPlusUnderscore, Len(PrefixPlusUnderscore)) != 0) { return s; @@ -244,7 +234,7 @@ public: * add_method() * ------------------------------------------------------------ */ - void add_method(const DOHconst_String_or_char_ptr name, const DOHconst_String_or_char_ptr function, const DOHconst_String_or_char_ptr description) { + void add_method(const DOHString_or_char *name, const DOHString_or_char *function, const DOHString_or_char *description) { String *rename = NULL; switch (current) { case NO_CPP: diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx index ffeea430d..f0e335c37 100644 --- a/Source/Modules/python.cxx +++ b/Source/Modules/python.cxx @@ -10,8 +10,11 @@ char cvsroot_python_cxx[] = "$Id$"; #include "swigmod.h" -#include "cparse.h" +#define ctab2 " " +#define ctab4 " " +#define ctab8 " " +#include "cparse.h" static int treduce = SWIG_cparse_template_reduce(0); #include @@ -28,7 +31,6 @@ static int shadow = 1; static int use_kw = 0; static int director_method_index = 0; -static File *f_begin = 0; static File *f_runtime = 0; static File *f_runtime_h = 0; static File *f_header = 0; @@ -47,11 +49,10 @@ static String *shadow_indent = 0; static int in_class = 0; static int classic = 0; static int modern = 0; +static int apply = 0; static int new_repr = 1; static int no_header_file = 0; -static int py3 = 0; - /* C++ Support + Shadow Classes */ static int have_constructor; @@ -95,6 +96,7 @@ enum autodoc_t { static const char *usage1 = (char *) "\ Python Options (available with -python)\n\ -aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\ + -apply - Use apply() in proxy classes\n\ -buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\ -castmode - Enable the casting mode, which allows implicit cast between types in python\n\ -classic - Use classic classes only\n\ @@ -146,8 +148,6 @@ static const char *usage3 = (char *) "\ -O - Enable all the optimization options: \n\ -modern -fastdispatch -dirvtable -nosafecstrings -fvirtual -noproxydel \n\ -fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone \n\ - -py3 - Generate code with Python 3 specific features:\n\ - Function annotation \n\ \n"; class PYTHON:public Language { @@ -259,6 +259,9 @@ public: } else if ((strcmp(argv[i], "-shadow") == 0) || ((strcmp(argv[i], "-proxy") == 0))) { shadow = 1; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-apply") == 0) { + apply = 1; + Swig_mark_arg(i); } else if ((strcmp(argv[i], "-new_repr") == 0) || (strcmp(argv[i], "-newrepr") == 0)) { new_repr = 1; Swig_mark_arg(i); @@ -281,6 +284,7 @@ public: } else if (strcmp(argv[i], "-classic") == 0) { classic = 1; modernargs = 0; + apply = 1; modern = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-cppcast") == 0) { @@ -386,6 +390,7 @@ public: proxydel = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-modern") == 0) { + apply = 0; classic = 0; modern = 1; modernargs = 1; @@ -403,6 +408,7 @@ public: no_header_file = 1; Swig_mark_arg(i); } else if (strcmp(argv[i], "-O") == 0) { + apply = 0; classic = 0; modern = 1; dirvtable = 1; @@ -423,17 +429,8 @@ public: fputs(usage1, stdout); fputs(usage2, stdout); fputs(usage3, stdout); - } else if (strcmp(argv[i], "-py3") == 0) { - py3 = 1; - Swig_mark_arg(i); - } - + } } - } /* for */ - - if (py3) { - /* force disable features that not compatible with Python 3.x */ - classic = 0; } if (cppcast) { @@ -514,21 +511,15 @@ public: String *outfile = Getattr(n, "outfile"); String *outfile_h = !no_header_file ? Getattr(n, "outfile_h") : 0; - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); - f_init = NewString(""); - f_header = NewString(""); - f_wrappers = NewString(""); - f_directors_h = NewString(""); - f_directors = NewString(""); if (directorsEnabled()) { if (!no_header_file) { - f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); + f_runtime_h = NewFile(outfile_h, "w"); if (!f_runtime_h) { FileErrorDisplay(outfile_h); SWIG_exit(EXIT_FAILURE); @@ -538,10 +529,15 @@ public: } } + f_init = NewString(""); + f_header = NewString(""); + f_wrappers = NewString(""); + f_directors_h = NewString(""); + f_directors = NewString(""); + /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); @@ -550,9 +546,8 @@ public: const_code = NewString(""); methods = NewString(""); - Swig_banner(f_begin); + Swig_banner(f_runtime); - Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGPYTHON\n"); if (directorsEnabled()) { @@ -604,8 +599,6 @@ public: Printf(f_runtime, "#define SWIG_PYTHON_CLASSIC\n"); } - Printf(f_runtime, "\n"); - Printf(f_header, "#if (PY_VERSION_HEX <= 0x02000000)\n"); Printf(f_header, "# if !defined(SWIG_PYTHON_CLASSIC)\n"); Printf(f_header, "# error \"This python version requires swig to be run with the '-classic' option\"\n"); @@ -644,7 +637,6 @@ public: if (directorsEnabled()) { Swig_banner(f_directors_h); - Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module); if (dirprot_mode()) { @@ -668,7 +660,7 @@ public: module = interface; else Insert(module, 0, "_"); - if ((f_shadow_py = NewFile(filen, "w", SWIG_output_files())) == 0) { + if ((f_shadow_py = NewFile(filen, "w")) == 0) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } @@ -682,7 +674,10 @@ public: Swig_register_filebyname("shadow", f_shadow); Swig_register_filebyname("python", f_shadow); - Swig_banner_target_lang(f_shadow, "#"); + Printf(f_shadow, "# This file was automatically generated by SWIG (http://www.swig.org).\n"); + Printf(f_shadow, "# Version %s\n", Swig_package_version()); + Printf(f_shadow, "#\n"); + Printf(f_shadow, "# Don't modify this file, modify the SWIG interface instead.\n"); if (!modern) { Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL); @@ -694,53 +689,13 @@ public: mod_docstring = NULL; } - Printv(f_shadow, "\nfrom sys import version_info\n", NULL); - - if(fastproxy) - { - Printv(f_shadow, "if version_info >= (3,0,0):\n", NULL); - Printf(f_shadow, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module); - Printv(f_shadow, "else:\n", NULL); - Printv(f_shadow, tab4, "from new import instancemethod as new_instancemethod\n", NULL); - } - /* Import the C-extension module. This should be a relative import, - * since the shadow module may also have been imported by a relative - * import, and there is thus no guarantee that the C-extension is on - * sys.path. Relative imports must be explicitly specified from 2.6.0 - * onwards (implicit relative imports will raise a DeprecationWarning - * in 2.6, and fail in 2.7 onwards), but the relative import syntax - * isn't available in python 2.4 or earlier, so we have to write some - * code conditional on the python version. - */ - Printv(f_shadow, "if version_info >= (2,6,0):\n", NULL); - Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL); - Printv(f_shadow, tab8, "from os.path import dirname\n", NULL); - Printv(f_shadow, tab8, "import imp\n", NULL); - Printv(f_shadow, tab8, "fp = None\n", NULL); - Printv(f_shadow, tab8, "try:\n", NULL); - Printf(f_shadow, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module); - Printf(f_shadow, tab8 "except ImportError:\n"); - /* At here, the module may already loaded, so simply import it. */ - Printf(f_shadow, tab4 tab8 "import %s\n", module); - Printf(f_shadow, tab4 tab8 "return %s\n", module); - Printv(f_shadow, tab8 "if fp is not None:\n", NULL); - Printv(f_shadow, tab4 tab8 "try:\n", NULL); - Printf(f_shadow, tab8 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module); - Printv(f_shadow, tab4 tab8, "finally:\n", NULL); - Printv(f_shadow, tab8 tab8, "fp.close()\n", NULL); - Printv(f_shadow, tab8 tab8, "return _mod\n", NULL); - Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module); - Printv(f_shadow, tab4, "del swig_import_helper\n", NULL); - Printv(f_shadow, "else:\n", NULL); - Printf(f_shadow, tab4 "import %s\n", module); - - /* Delete the version_info symbol since we don't use it elsewhere in the - * module. */ - Printv(f_shadow, "del version_info\n", NULL); + Printf(f_shadow, "\nimport %s\n", module); + Printv(f_shadow, "import new\n", NULL); + Printv(f_shadow, "new_instancemethod = new.instancemethod\n", NULL); if (modern || !classic) { Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass # Python < 2.2 doesn't have 'property'.\n", NULL); - } + } /* if (!modern) */ /* always needed, a class can be forced to be no-modern, such as an exception */ { @@ -748,7 +703,7 @@ public: Printv(f_shadow, "def _swig_setattr_nondynamic(self,class_type,name,value,static=1):\n", tab4, "if (name == \"thisown\"): return self.this.own(value)\n", - tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n", + tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'PySwigObject':\n", tab4, tab8, "self.__dict__[name] = value\n", #ifdef USE_THISOWN tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n", #endif @@ -767,7 +722,7 @@ public: "def _swig_getattr(self,class_type,name):\n", tab4, "if (name == \"thisown\"): return self.this.own()\n", tab4, "method = class_type.__swig_getmethods__.get(name,None)\n", - tab4, "if method: return method(self)\n", tab4, "raise AttributeError(name)\n\n", NIL); + tab4, "if method: return method(self)\n", tab4, "raise AttributeError,name\n\n", NIL); Printv(f_shadow, "def _swig_repr(self):\n", @@ -775,17 +730,11 @@ public: tab4, "except: strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL); if (!classic) { - /* Usage of types.ObjectType is deprecated. - * But don't sure wether this would broken old Python? - */ Printv(f_shadow, -// "import types\n", + "import types\n", "try:\n", -// " _object = types.ObjectType\n", - " _object = object\n", - " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n", -// "del types\n", - "\n\n", NIL); + " _object = types.ObjectType\n", + " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n", "del types\n", "\n\n", NIL); } } if (modern) { @@ -811,11 +760,7 @@ public: } - Printf(f_header, "#if PY_VERSION_HEX >= 0x03000000\n"); - Printf(f_header, "# define SWIG_init PyInit_%s\n\n", module); - Printf(f_header, "#else\n"); - Printf(f_header, "# define SWIG_init init%s\n\n", module); - Printf(f_header, "#endif\n"); + Printf(f_header, "#define SWIG_init init%s\n\n", module); Printf(f_header, "#define SWIG_name \"%s\"\n", module); Printf(f_wrappers, "#ifdef __cplusplus\n"); @@ -824,9 +769,6 @@ public: Append(const_code, "static swig_const_info swig_const_table[] = {\n"); Append(methods, "static PyMethodDef SwigMethods[] = {\n"); - /* the method exported for replacement of new.instancemethod in Python 3 */ - add_pyinstancemethod_new(); - /* emit code */ Language::top(n); @@ -845,12 +787,6 @@ public: Append(const_code, "{0, 0, 0, 0.0, 0, 0}};\n"); Printf(f_wrappers, "%s\n", const_code); initialize_threads(f_init); - - Printf(f_init, "#if PY_VERSION_HEX >= 0x03000000\n"); - Printf(f_init, " return m;\n"); - Printf(f_init, "#else\n"); - Printf(f_init, " return;\n"); - Printf(f_init, "#endif\n"); Printf(f_init, "}\n"); Printf(f_wrappers, "#ifdef __cplusplus\n"); @@ -858,6 +794,10 @@ public: Printf(f_wrappers, "#endif\n"); if (shadow) { + /* + Printf(f_shadow_imports,"\nimport %s\n", module); + Printv(f_shadow_py, f_shadow_imports, "\n",NIL); + */ Printv(f_shadow_py, f_shadow, "\n", NIL); Printv(f_shadow_py, f_shadow_stubs, "\n", NIL); @@ -866,20 +806,19 @@ public: } /* Close all of the files */ - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); + Dump(f_header, f_runtime); if (directorsEnabled()) { Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); - if (f_runtime_h != f_begin) + if (f_runtime_h != f_runtime) Close(f_runtime_h); - Dump(f_directors, f_begin); + Dump(f_directors, f_runtime); } - Dump(f_wrappers, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_wrappers, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); @@ -887,25 +826,11 @@ public: Delete(f_directors); Delete(f_directors_h); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); return SWIG_OK; } - - /* ------------------------------------------------------------ - * Emit the wrapper for PyInstanceMethod_New to MethodDef array. - * This wrapper is used to implement -fastproxy, - * as a replacement of new.instancemethod in Python 3. - * ------------------------------------------------------------ */ - int add_pyinstancemethod_new() - { - String* name = NewString("SWIG_PyInstanceMethod_New"); - Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},\n", name, name); - Delete(name); - return 0; - } /* ------------------------------------------------------------ * importDirective() @@ -937,11 +862,7 @@ public: if (!options || (!Getattr(options, "noshadow") && !Getattr(options, "noproxy"))) { Printf(import, "_%s\n", modname); if (!Strstr(f_shadow_imports, import)) { - if (pkg && (!package || Strcmp(pkg, package) != 0)) { - Printf(f_shadow, "import %s.%s\n", pkg, modname); - } else { - Printf(f_shadow, "import %s\n", modname); - } + Printf(f_shadow, "import %s\n", modname); Printv(f_shadow_imports, import, NULL); } } @@ -953,25 +874,31 @@ public: return Language::importDirective(n); } + /* ------------------------------------------------------------ - * funcCall() - * Emit shadow code to call a function in the extension - * module. Using proper argument and calling style for - * given node n. + * emitFuncCallHelper() + * Write the shadow code to call a function in the extension + * module. Takes into account the -apply flag and whether + * to use keyword args or not. * ------------------------------------------------------------ */ - String *funcCall(String *name, String *parms) { - String *str = NewString(""); - Printv(str, module, ".", name, "(", parms, ")", NIL); + String *funcCallHelper(String *name, int kw) { + String *str; + + str = NewString(""); + if (apply) { + Printv(str, "apply(", module, ".", name, ", args", (kw ? ", kwargs" : ""), ")", NIL); + } else { + Printv(str, module, ".", name, "(*args", (kw ? ", **kwargs" : ""), ")", NIL); + } return str; - } - + } /* ------------------------------------------------------------ * pythoncode() - Output python code into the shadow file * ------------------------------------------------------------ */ - String *pythoncode(String *code, const_String_or_char_ptr indent) { + String *pythoncode(String *code, const String *indent) { String *out = NewString(""); String *temp; char *t; @@ -1133,84 +1060,29 @@ public: return doc; } - /* ----------------------------------------------------------------------------- - * makeParameterName() - * Note: the generated name should consist with that in kwnames[] - * - * Inputs: - * n - Node - * p - parameter node - * arg_num - parameter argument number - * Return: - * arg - a unique parameter name - * ----------------------------------------------------------------------------- */ - - String *makeParameterName(ParmList *plist, Parm *p, int arg_num) { - String *arg = 0; - String *pn = Swig_name_make(p, 0, Getattr(p, "name"), 0, 0); - // Use C parameter name unless it is a duplicate or an empty parameter name - int count = 0; - if ( SwigType_isvarargs(Getattr(p, "type")) ) { - return NewString("*args"); - } - while (plist) { - if ((Cmp(pn, Getattr(plist, "name")) == 0)) - count++; - plist = nextSibling(plist); - } - arg = (!pn || !Len(pn) || (count > 1)) ? NewStringf("arg%d", arg_num) : Copy(pn); - return arg; - } - - /* ------------------------------------------------------------ * make_autodocParmList() * Generate the documentation for the function parameters - * Parameters: - * func_annotation: Function annotation support * ------------------------------------------------------------ */ - String *make_autodocParmList(Node *n, bool showTypes, bool calling=false, bool func_annotation=false) { - - + String *make_autodocParmList(Node *n, bool showTypes) { String *doc = NewString(""); String *pdocs = Copy(Getattr(n, "feature:pdocs")); ParmList *plist = CopyParmList(Getattr(n, "parms")); Parm *p; Parm *pnext; - Node *lookup; - - + Node *lookup; int lines = 0; - int arg_num = 0; const int maxwidth = 50; - if(calling) - func_annotation = false; - if (pdocs) Append(pdocs, "\n"); + Swig_typemap_attach_parms("in", plist, 0); Swig_typemap_attach_parms("doc", plist, 0); - - if (Strcmp(ParmList_protostr(plist), "void")==0) { - //No parameters actually - return doc; - } - + for (p = plist; p; p = pnext) { - - String *tm = Getattr(p, "tmap:in"); - if (tm) { - pnext = Getattr(p, "tmap:in:next"); - if (checkAttribute(p, "tmap:in:numinputs", "0")) { - continue; - } - } else { - pnext = nextSibling(p); - } - String *name = 0; String *type = 0; String *value = 0; @@ -1227,14 +1099,12 @@ public: type = type ? type : Getattr(p, "type"); value = value ? value : Getattr(p, "value"); - name = makeParameterName(plist, p, arg_num); - // Reset it for convinient in further use. (mainly for makeParameterName()) - // Since the plist is created by CopyParmList, - // we can hope that the set would have no side effect - Setattr(p, "name", name); - - arg_num++; - + String *tm = Getattr(p, "tmap:in"); + if (tm) { + pnext = Getattr(p, "tmap:in:next"); + } else { + pnext = nextSibling(p); + } if (Len(doc)) { // add a comma to the previous one if any @@ -1246,40 +1116,39 @@ public: lines += 1; } } - - type = SwigType_base(type); - lookup = Swig_symbol_clookup(type, 0); - if (lookup) - type = Getattr(lookup, "sym:name"); - // Do the param type too? - if (showTypes) - Printf(doc, "%s ", type); - - - Append(doc, name); - if (pdoc) { - if (!pdocs) - pdocs = NewString("Parameters:\n"); - Printf(pdocs, " %s\n", pdoc); + if (showTypes) { + type = SwigType_base(type); + lookup = Swig_symbol_clookup(type, 0); + if (lookup) + type = Getattr(lookup, "sym:name"); + Printf(doc, "%s ", type); } - // Write the function annoation - if (func_annotation) - Printf(doc, " : '%s'", type); + if (name) { + Append(doc, name); + if (pdoc) { + if (!pdocs) + pdocs = NewString("Parameters:\n"); + Printf(pdocs, " %s\n", pdoc); + } + } else { + Append(doc, "?"); + } - // Write default value - if (value && !calling) { - String* pv = pyvalue(value, Getattr(p, "type")); - if (pv) - value = pv; + if (value) { + if (Strcmp(value, "NULL") == 0) + value = NewString("None"); + else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0) + value = NewString("True"); + else if (Strcmp(value, "false") == 0 || Strcmp(value, "FALSE") == 0) + value = NewString("False"); else { lookup = Swig_symbol_clookup(value, 0); - if (lookup) { + if (lookup) value = Getattr(lookup, "sym:name"); - } } - Printf(doc, " = %s", value); + Printf(doc, "=%s", value); } } if (pdocs) @@ -1357,9 +1226,9 @@ public: String *str = Getattr(n, "feature:docstring"); if (str == NULL || Len(str) == 0) { if (CPlusPlus) { - Printf(doc, "Proxy of C++ %s class", real_classname); + Printf(doc, "Proxy of C++ %s class", class_name); } else { - Printf(doc, "Proxy of C %s struct", real_classname); + Printf(doc, "Proxy of C %s struct", class_name); } } } @@ -1417,132 +1286,6 @@ public: return doc; } - - /* ------------------------------------------------------------ - * pyvalue() - * Check if string v can be a Python value literal, - * (eg. number or string), or translate it to a Python literal. - * ------------------------------------------------------------ */ - String* pyvalue(String *v, SwigType *t) - { - if (v && Len(v)>0) { - char fc = (Char(v))[0]; - if (('0'<=fc && fc<='9') || '\''==fc || '"'==fc) { - /* number or string (or maybe NULL pointer)*/ - if (SwigType_ispointer(t) && Strcmp(v, "0")==0) - return NewString("None"); - else - return v; - } - if (Strcmp(v, "true")==0 || Strcmp(v, "FALSE")==0) - return NewString("True"); - if (Strcmp(v, "false")==0 || Strcmp(v, "FALSE")==0) - return NewString("False"); - if (Strcmp(v, "NULL")==0) - return NewString("None"); - } - return 0; - } - /* ------------------------------------------------------------ - * is_primitive_defaultargs() - * Check if all the default args have primitive type. - * (So we can generate proper parameter list with default - * values..) - * ------------------------------------------------------------ */ - bool is_primitive_defaultargs(Node *n) - { - ParmList *plist = CopyParmList(Getattr(n, "parms")); - Parm *p; - Parm *pnext; - - Swig_typemap_attach_parms("in", plist, 0); - for (p = plist; p; p = pnext) { - String *tm = Getattr(p, "tmap:in"); - if (tm) { - pnext = Getattr(p, "tmap:in:next"); - if (checkAttribute(p, "tmap:in:numinputs", "0")) { - continue; - } - } else { - pnext = nextSibling(p); - } - String *type = Getattr(p, "type"); - String *value = Getattr(p, "value"); - if (!pyvalue(value, type)) - return false; - } - return true; - } - - - /* ------------------------------------------------------------ - * is_real_overloaded() - * Check if the function is overloaded, but not just have some - * siblings generated due to the original function have - * default arguments. - * ------------------------------------------------------------ */ - bool is_real_overloaded(Node *n) - { - Node *h = Getattr(n, "sym:overloaded"); - Node *i; - if (!h) - return false; - - i = Getattr(h, "sym:nextSibling"); - while (i) { - Node *nn = Getattr(i, "defaultargs"); - if (nn != h) { - /* Check if overloaded function has defaultargs and - * pointed to the first overloaded. */ - return true; - } - i = Getattr(i, "sym:nextSibling"); - } - - return false; - } - - /* ------------------------------------------------------------ - * make_pyParmList() - * Generate parameter list for Python functions or methods, - * reuse make_autodocParmList() to do so. - * ------------------------------------------------------------ */ - String* make_pyParmList(Node *n, bool in_class, bool is_calling, int kw) - { - /* Get the original function for a defaultargs copy, - * see default_arguments() in parser.y. */ - Node *nn = Getattr(n, "defaultargs"); - if (nn) n = nn; - - /* For overloaded function, just use *args */ - if (is_real_overloaded(n) || - GetFlag(n, "feature:compactdefaultargs") || - !is_primitive_defaultargs(n)) - { - String *parms = NewString(""); - if(in_class) - Printf(parms, "self, "); - Printf(parms, "*args"); - if (kw) - Printf(parms, ", **kwargs"); - return parms; - } - - bool funcanno = py3 ? true : false; - String *params = NewString(""); - String *_params = make_autodocParmList(n, false, is_calling, funcanno); - - if (in_class) - { - Printf(params, "self"); - if(Len(_params) > 0) - Printf(params, ", "); - } - - Printv(params, _params, NULL); - - return params; - } /* ------------------------------------------------------------ * have_pythonprepend() @@ -1608,40 +1351,6 @@ public: return have_pythonappend(n) || have_pythonprepend(n) || have_docstring(n); } - - /* ------------------------------------------------------------ - * returnTypeAnnotation() - * Helper function for constructing the function annotation - * of the returning type, return a empty string for Python 2.x - * ------------------------------------------------------------ */ - String* returnTypeAnnotation(Node *n) - { - String *ret=0; - Parm *p = Getattr(n, "parms"); - String *tm; - /* Try to guess the returning type by argout typemap, - * however the result may not accurate. */ - while (p) { - if ((tm=Getattr(p, "tmap:argout:match_type"))) { - tm = SwigType_str(tm, 0); - if (ret) - Printv(ret, ", ", tm, NULL); - else - ret = tm; - p = Getattr(p, "tmap:argout:next"); - } else { - p = nextSibling(p); - } - } - /* If no argout typemap, then get the returning type from - * the function prototype. */ - if (!ret) { - ret = Getattr(n, "type"); - if (ret) ret = SwigType_str(ret, 0); - } - return (ret && py3) ? NewStringf(" -> \"%s\" ", ret) - : NewString(""); - } /* ------------------------------------------------------------ * emitFunctionShadowHelper() @@ -1651,26 +1360,24 @@ public: * ------------------------------------------------------------ */ void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) { - String *parms = make_pyParmList(n, false, false, kw); - String *callParms = make_pyParmList(n, false, true, kw); - /* Make a wrapper function to insert the code into */ - Printv(f_dest, "\ndef ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); - if (have_docstring(n)) - Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); - if (have_pythonprepend(n)) - Printv(f_dest, pythoncode(pythonprepend(n), " "), "\n", NIL); - if (have_pythonappend(n)) { - Printv(f_dest, " val = ", funcCall(name, callParms), "\n", NIL); - Printv(f_dest, pythoncode(pythonappend(n), " "), "\n", NIL); - Printv(f_dest, " return val\n", NIL); - } else { - Printv(f_dest, " return ", funcCall(name, callParms), "\n", NIL); - } - if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) { - /* If there is no addtofunc directive then just assign from the extension module (for speed up) */ + /* If there is no addtofunc directive then just assign from the extension module */ Printv(f_dest, name, " = ", module, ".", name, "\n", NIL); - } + } else { + /* Otherwise make a wrapper function to insert the code into */ + Printv(f_dest, "\ndef ", name, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); + if (have_docstring(n)) + Printv(f_dest, ctab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); + if (have_pythonprepend(n)) + Printv(f_dest, ctab4, pythonprepend(n), "\n", NIL); + if (have_pythonappend(n)) { + Printv(f_dest, ctab4, "val = ", funcCallHelper(name, kw), "\n", NIL); + Printv(f_dest, ctab4, pythonappend(n), "\n", NIL); + Printv(f_dest, ctab4, "return val\n", NIL); + } else { + Printv(f_dest, ctab4, "return ", funcCallHelper(name, kw), "\n", NIL); + } + } } @@ -2071,7 +1778,7 @@ public: /* finish argument marshalling */ Append(kwargs, " NULL }"); if (allow_kwargs) { - Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL); + Printv(f->locals, ctab4, "char * kwnames[] = ", kwargs, ";\n", NIL); } if (use_parse || allow_kwargs || !modernargs) { @@ -2343,7 +2050,7 @@ public: } if (allow_thread) thread_end_block(n, f->code); - Printv(f->code, " return NULL;\n", NIL); + Printv(f->code, ctab4, "return NULL;\n", NIL); if (funpack) { @@ -2475,9 +2182,9 @@ public: } else { Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0)); } - Printv(setf->code, " return 0;\n", NULL); + Printv(setf->code, ctab4, "return 0;\n", NULL); Append(setf->code, "fail:\n"); - Printv(setf->code, " return 1;\n", NULL); + Printv(setf->code, ctab4, "return 1;\n", NULL); } else { /* Is a readonly variable. Issue an error */ if (CPlusPlus) { @@ -2485,7 +2192,7 @@ public: } else { Printf(setf->def, "SWIGINTERN int %s(PyObject *_val SWIGUNUSED) {", varsetname); } - Printv(setf->code, " SWIG_Error(SWIG_AttributeError,\"Variable ", iname, " is read-only.\");\n", " return 1;\n", NIL); + Printv(setf->code, ctab4, "SWIG_Error(SWIG_AttributeError,\"Variable ", iname, " is read-only.\");\n", ctab4, "return 1;\n", NIL); } Append(setf->code, "}\n"); @@ -2753,7 +2460,7 @@ public: Printf(f_directors_h, " PyObject *swig_get_method(size_t method_index, const char *method_name) const {\n"); Printf(f_directors_h, " PyObject *method = vtable[method_index];\n"); Printf(f_directors_h, " if (!method) {\n"); - Printf(f_directors_h, " swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);\n"); + Printf(f_directors_h, " swig::PyObject_var name = PyString_FromString(method_name);\n"); Printf(f_directors_h, " method = PyObject_GetAttr(swig_get_self(), name);\n"); Printf(f_directors_h, " if (method == NULL) {\n"); Printf(f_directors_h, " std::string msg = \"Method in class %s doesn't exist, undefined \";\n", classname); @@ -2765,7 +2472,7 @@ public: Printf(f_directors_h, " return method;\n"); Printf(f_directors_h, " }\n"); Printf(f_directors_h, "private:\n"); - Printf(f_directors_h, " mutable swig::SwigVar_PyObject vtable[%d];\n", director_method_index); + Printf(f_directors_h, " mutable swig::PyObject_var vtable[%d];\n", director_method_index); Printf(f_directors_h, "#endif\n\n"); } @@ -2877,12 +2584,7 @@ public: b = First(baselist); while (b.item) { String *bname = Getattr(b.item, "python:proxy"); - bool ignore = GetFlag(b.item, "feature:ignore") ? true : false; - if (!bname || ignore) { - if (!bname && !ignore) { - Swig_warning(WARN_TYPE_UNDEFINED_CLASS, input_file, line_number, - "Base class '%s' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %%import directive.\n", SwigType_namestr(Getattr(b.item, "name"))); - } + if (!bname || GetFlag(b.item, "feature:ignore")) { b = Next(b); continue; } @@ -2893,16 +2595,6 @@ public: } } } - - /* dealing with abstract base class */ - String *abcs = Getattr(n, "feature:python:abc"); - if (py3 && abcs) { - if (Len(base_class)) { - Putc(',', base_class); - } - Printv(base_class, abcs, NIL); - } - Printv(f_shadow, "class ", class_name, NIL); if (Len(base_class)) { @@ -2911,9 +2603,6 @@ public: if (!classic) { Printf(f_shadow, modern ? "(object)" : "(_object)"); } - if (GetFlag(n, "feature:exceptionclass") ) { - Printf(f_shadow, "(Exception)"); - } } Printf(f_shadow, ":\n"); if (have_docstring(n)) { @@ -2982,20 +2671,20 @@ public: SwigType_add_pointer(realct); SwigType_remember(realct); Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); - Printv(f_wrappers, " PyObject *obj;\n", NIL); + Printv(f_wrappers, ctab4, "PyObject *obj;\n", NIL); if (modernargs) { if (fastunpack) { - Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); + Printv(f_wrappers, ctab4, "if (!SWIG_Python_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); } else { - Printv(f_wrappers, " if (!PyArg_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); + Printv(f_wrappers, ctab4, "if (!PyArg_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL); } } else { - Printv(f_wrappers, " if (!PyArg_ParseTuple(args,(char*)\"O:swigregister\", &obj)) return NULL;\n", NIL); + Printv(f_wrappers, ctab4, "if (!PyArg_ParseTuple(args,(char*)\"O:swigregister\", &obj)) return NULL;\n", NIL); } Printv(f_wrappers, - " SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n", - " return SWIG_Py_Void();\n", "}\n\n", NIL); + ctab4, "SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n", + ctab4, "return SWIG_Py_Void();\n", "}\n\n", NIL); String *cname = NewStringf("%s_swigregister", class_name); add_method(cname, cname, 0); Delete(smart); @@ -3004,11 +2693,11 @@ public: Delete(realct); } if (!have_constructor) { - Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"No constructor defined\")\n", NIL); + Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError, \"No constructor defined\"\n", NIL); } else if (fastinit) { Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL); - Printv(f_wrappers, " return SWIG_Python_InitShadowInstance(args);\n", "}\n\n", NIL); + Printv(f_wrappers, ctab4, "return SWIG_Python_InitShadowInstance(args);\n", "}\n\n", NIL); String *cname = NewStringf("%s_swiginit", class_name); add_method(cname, cname, 0); Delete(cname); @@ -3117,29 +2806,27 @@ public: Delete(pycode); fproxy = 0; } else { - String *parms = make_pyParmList(n, true, false, allow_kwargs); - String *callParms = make_pyParmList(n, true, true, allow_kwargs); if (!have_addtofunc(n)) { if (!fastproxy || olddefs) { - Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); - Printv(f_shadow, " return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); + Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL); + Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n", NIL); } } else { - Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL); + Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL); Printv(f_shadow, "\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); if (have_pythonprepend(n)) { fproxy = 0; - Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); + Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); } if (have_pythonappend(n)) { fproxy = 0; - Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); - Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); + Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n", NIL); + Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { - Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); + Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n\n", NIL); } } } @@ -3172,19 +2859,17 @@ public: if (shadow) { if (!classic && !Getattr(n, "feature:python:callback") && have_addtofunc(n)) { int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0; - String *parms = make_pyParmList(n, false, false, kw); - String *callParms = make_pyParmList(n, false, true, kw); - Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); + Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); + Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); if (have_pythonappend(n)) { - Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); - Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); + Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL); + Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL); } else { - Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); + Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n\n", NIL); } Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", symname, ")\n", NIL); @@ -3256,8 +2941,8 @@ public: handled_as_init = (Strcmp(nname, sname) == 0) || (Strcmp(nname, cname) == 0); Delete(cname); } - - if (!have_constructor && handled_as_init) { + + if (!have_constructor && handled_as_init) { if (Getattr(n, "feature:shadow")) { String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4); String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(symname)); @@ -3271,34 +2956,27 @@ public: String *classname = Swig_class_name(parent); String *rclassname = Swig_class_name(getCurrentClass()); assert(rclassname); - - String *parms = make_pyParmList(n, true, false, allow_kwargs); - /* Pass 'self' only if using director */ - String *callParms = make_pyParmList(n, false, true, allow_kwargs); - - if (use_director) { - Insert(callParms, 0, "_self, "); + if (use_director) { Printv(pass_self, tab8, NIL); Printf(pass_self, "if self.__class__ == %s:\n", classname); - //Printv(pass_self, tab8, tab4, "args = (None,) + args\n", tab8, "else:\n", tab8, tab4, "args = (self,) + args\n", NIL); - Printv(pass_self, tab8, tab4, "_self = None\n", tab8, "else:\n", tab8, tab4, "_self = self\n", NIL); + Printv(pass_self, tab8, tab4, "args = (None,) + args\n", tab8, "else:\n", tab8, tab4, "args = (self,) + args\n", NIL); } - Printv(f_shadow, tab4, "def __init__(", parms, ")", returnTypeAnnotation(n), ": \n", NIL); + Printv(f_shadow, tab4, "def __init__(self, *args", (allow_kwargs ? ", **kwargs" : ""), "): \n", NIL); if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); + Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); Printv(f_shadow, pass_self, NIL); if (fastinit) { - Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(symname), callParms), ")\n", NIL); + Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL); } else { Printv(f_shadow, - tab8, "this = ", funcCall(Swig_name_construct(symname), callParms), "\n", + tab8, "this = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL); } if (have_pythonappend(n)) - Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n\n", NIL); + Printv(f_shadow, tab8, pythonappend(n), "\n\n", NIL); Delete(pass_self); } have_constructor = 1; @@ -3314,20 +2992,18 @@ public: Printv(f_shadow_stubs, pycode, "\n", NIL); Delete(pycode); } else { - String *parms = make_pyParmList(n, true, false, allow_kwargs); - String *callParms = make_pyParmList(n, true, true, allow_kwargs); - Printv(f_shadow_stubs, "\ndef ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); + Printv(f_shadow_stubs, "\ndef ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL); if (have_docstring(n)) Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4), "\n", NIL); - Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(symname), callParms), "\n", NIL); + Printv(f_shadow_stubs, tab4, pythonprepend(n), "\n", NIL); + Printv(f_shadow_stubs, tab4, "val = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); #endif if (have_pythonappend(n)) - Printv(f_shadow_stubs, pythoncode(pythonappend(n), tab4), "\n", NIL); + Printv(f_shadow_stubs, tab4, pythonappend(n), "\n", NIL); Printv(f_shadow_stubs, tab4, "return val\n", NIL); } } @@ -3369,7 +3045,7 @@ public: if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL); if (have_pythonprepend(n)) - Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL); + Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); #ifdef USE_THISOWN Printv(f_shadow, tab8, "try:\n", NIL); Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(symname), "(self)\n", NIL); @@ -3377,7 +3053,7 @@ public: #else #endif if (have_pythonappend(n)) - Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL); + Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); Printv(f_shadow, tab8, "pass\n", NIL); Printv(f_shadow, "\n", NIL); } @@ -3765,8 +3441,8 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Replaceall(tm, "$input", input); Delete(input); Replaceall(tm, "$owner", "0"); - /* Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); */ - Printv(wrap_args, "swig::SwigVar_PyObject ", source, ";\n", NIL); + /* Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL); */ + Printv(wrap_args, "swig::PyObject_var ", source, ";\n", NIL); Printv(wrap_args, tm, "\n", NIL); Printv(arglist, "(PyObject *)", source, NIL); @@ -3822,7 +3498,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { if (target) { String *director = NewStringf("director_%s", mangle); Wrapper_add_localv(w, director, "Swig::Director *", director, "= 0", NIL); - Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); + Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL); Printf(wrap_args, "%s = SWIG_DIRECTOR_CAST(%s);\n", director, nonconst); Printf(wrap_args, "if (!%s) {\n", director); Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); @@ -3833,7 +3509,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Delete(director); Printv(arglist, source, NIL); } else { - Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); + Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL); Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle); //Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n", // source, nonconst, base); @@ -3884,33 +3560,33 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) { Append(w->code, "PyObject* method = swig_get_method(swig_method_index, swig_method_name);\n"); if (Len(parse_args) > 0) { if (use_parse || !modernargs) { - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", parse_args, arglist); + Printf(w->code, "swig::PyObject_var result = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", parse_args, arglist); } else { - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunctionObjArgs(method %s, NULL);\n", arglist); + Printf(w->code, "swig::PyObject_var result = PyObject_CallFunctionObjArgs(method %s, NULL);\n", arglist); } } else { if (modernargs) { - Append(w->code, "swig::SwigVar_PyObject args = PyTuple_New(0);\n"); - Append(w->code, "swig::SwigVar_PyObject result = PyObject_Call(method, (PyObject*) args, NULL);\n"); + Append(w->code, "swig::PyObject_var args = PyTuple_New(0);\n"); + Append(w->code, "swig::PyObject_var result = PyObject_Call(method, (PyObject*) args, NULL);\n"); } else { - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, NULL, NULL);\n"); + Printf(w->code, "swig::PyObject_var result = PyObject_CallFunction(method, NULL, NULL);\n"); } } Append(w->code, "#else\n"); if (Len(parse_args) > 0) { if (use_parse || !modernargs) { - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", + Printf(w->code, "swig::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n", pyname, parse_args, arglist); - } else { - Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist); + } else { + Printf(w->code, "swig::PyObject_var swig_method_name = PyString_FromString((char *)\"%s\");\n", pyname); + Printf(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist); } } else { if (!modernargs) { - Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname); + Printf(w->code, "swig::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname); } else { - Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname); - Append(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n"); + Printf(w->code, "swig::PyObject_var swig_method_name = PyString_FromString((char *)\"%s\");\n", pyname); + Append(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n"); } } Append(w->code, "#endif\n"); diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx index 8e9aa557d..49d3ecc89 100644 --- a/Source/Modules/r.cxx +++ b/Source/Modules/r.cxx @@ -424,7 +424,6 @@ protected: String *sfile; String *f_init; String *s_classes; - String *f_begin; String *f_runtime; String *f_wrapper; String *s_header; @@ -488,7 +487,6 @@ R::R() : sfile(0), f_init(0), s_classes(0), - f_begin(0), f_runtime(0), f_wrapper(0), s_header(0), @@ -769,7 +767,6 @@ void R::init() { sfile = NewString(""); f_init = NewString(""); s_header = NewString(""); - f_begin = NewString(""); f_runtime = NewString(""); f_wrapper = NewString(""); s_classes = NewString(""); @@ -814,22 +811,16 @@ int R::top(Node *n) { Swig_register_filebyname("sinit", s_init); Swig_register_filebyname("sinitroutine", s_init_routine); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("header", s_header); Swig_register_filebyname("wrapper", f_wrapper); Swig_register_filebyname("s", sfile); + Swig_register_filebyname("sclasses", s_classes); - Swig_banner(f_begin); - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGR\n"); - Printf(f_runtime, "\n"); - - - Swig_banner_target_lang(s_init, "#"); + Printf(s_init, "# This is an automatically generated file by the R module for SWIG.\n\n"); outputCommandLineArguments(s_init); Printf(f_wrapper, "#ifdef __cplusplus\n"); @@ -867,9 +858,7 @@ int R::top(Node *n) { Delete(f_init); Delete(s_header); - Close(f_begin); Delete(f_runtime); - Delete(f_begin); return SWIG_OK; } @@ -889,7 +878,7 @@ int R::DumpCode(Node *n) { Printf(stderr, "Writing S code to %s\n", output_filename); #endif - File *scode = NewFile(output_filename, "w", SWIG_output_files()); + File *scode = NewFile(output_filename, "w"); if (!scode) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); @@ -904,16 +893,25 @@ int R::DumpCode(Node *n) { Close(scode); // Delete(scode); String *outfile = Getattr(n,"outfile"); - File *runtime = NewFile(outfile,"w", SWIG_output_files()); + File *runtime = NewFile(outfile,"w"); if (!runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - Printf(runtime, "%s", f_begin); + Swig_banner(runtime); + + + Printf(runtime, "/* Runtime */\n"); Printf(runtime, "%s\n", f_runtime); + + Printf(runtime, "/* Header */\n"); Printf(runtime, "%s\n", s_header); + + Printf(runtime, "/* Wrapper */\n"); Printf(runtime, "%s\n", f_wrapper); + + Printf(runtime, "/* Init code */\n"); Printf(runtime, "%s\n", f_init); Close(runtime); @@ -922,7 +920,7 @@ int R::DumpCode(Node *n) { if(outputNamespaceInfo) { output_filename = NewString(""); Printf(output_filename, "%sNAMESPACE", SWIG_output_directory()); - File *ns = NewFile(output_filename, "w", SWIG_output_files()); + File *ns = NewFile(output_filename, "w"); if (!ns) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); @@ -2576,9 +2574,9 @@ String * R::runtimeCode() { void R::main(int argc, char *argv[]) { bool cppcast = true; init(); - Preprocessor_define("SWIGR 1", 0); SWIG_library_directory("r"); SWIG_config_file("r.swg"); + Preprocessor_define("SWIGR 1", 0); debugMode = false; copyStruct = true; memoryProfile = false; @@ -2661,7 +2659,7 @@ int R::outputCommandLineArguments(File *out) if(Argc < 1 || !Argv || !Argv[0]) return(-1); - Printf(out, "\n## Generated via the command line invocation:\n##\t"); + Printf(out, "## Generated via the command line invocation:\n##\t"); for(int i = 0; i < Argc ; i++) { Printf(out, " %s", Argv[i]); } diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx index 1c13747e5..ad448d34e 100644 --- a/Source/Modules/ruby.cxx +++ b/Source/Modules/ruby.cxx @@ -30,7 +30,7 @@ public: /** * The C variable name used in the SWIG-generated wrapper code to refer to - * this class; usually it is of the form "SwigClassXXX.klass", where SwigClassXXX + * this class; usually it is of the form "cClassName.klass", where cClassName * is a swig_class struct instance and klass is a member of that struct. */ String *vname; @@ -39,7 +39,7 @@ public: * The C variable name used in the SWIG-generated wrapper code to refer to * the module that implements this class's methods (when we're trying to * support C++ multiple inheritance). Usually it is of the form - * "SwigClassClassName.mImpl", where SwigClassXXX is a swig_class struct instance + * "cClassName.mImpl", where cClassName is a swig_class struct instance * and mImpl is a member of that struct. */ String *mImpl; @@ -78,7 +78,7 @@ public: Delete(temp); } - void set_name(const_String_or_char_ptr cn, const_String_or_char_ptr rn, const_String_or_char_ptr valn) { + void set_name(const String_or_char *cn, const String_or_char *rn, const String_or_char *valn) { /* Original C/C++ class (or struct) name */ Clear(cname); Append(cname, cn); @@ -93,18 +93,18 @@ public: /* Variable name for the VALUE that refers to the Ruby Class object */ Clear(vname); - Printf(vname, "SwigClass%s.klass", name); + Printf(vname, "c%s.klass", name); /* Variable name for the VALUE that refers to the Ruby Class object */ Clear(mImpl); - Printf(mImpl, "SwigClass%s.mImpl", name); + Printf(mImpl, "c%s.mImpl", name); /* Prefix */ Clear(prefix); Printv(prefix, (rn ? rn : cn), "_", NIL); } - char *strip(const_String_or_char_ptr s) { + char *strip(const String_or_char *s) { Clear(temp); Append(temp, s); if (Strncmp(s, prefix, Len(prefix)) == 0) { @@ -158,7 +158,6 @@ private: File *f_directors; File *f_directors_h; File *f_directors_helpers; - File *f_begin; File *f_runtime; File *f_runtime_h; File *f_header; @@ -763,7 +762,6 @@ public: classes = 0; klass = 0; special_methods = 0; - f_begin = 0; f_runtime = 0; f_header = 0; f_wrappers = 0; @@ -994,13 +992,24 @@ public: SWIG_exit(EXIT_FAILURE); } - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); + if (directorsEnabled()) { + if (!outfile_h) { + Printf(stderr, "Unable to determine outfile_h\n"); + SWIG_exit(EXIT_FAILURE); + } + f_runtime_h = NewFile(outfile_h, "w"); + if (!f_runtime_h) { + FileErrorDisplay(outfile_h); + SWIG_exit(EXIT_FAILURE); + } + } + f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -1009,22 +1018,9 @@ public: f_directors_helpers = NewString(""); f_initbeforefunc = NewString(""); - if (directorsEnabled()) { - if (!outfile_h) { - Printf(stderr, "Unable to determine outfile_h\n"); - SWIG_exit(EXIT_FAILURE); - } - f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files()); - if (!f_runtime_h) { - FileErrorDisplay(outfile_h); - SWIG_exit(EXIT_FAILURE); - } - } - /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); Swig_register_filebyname("director", f_directors); @@ -1039,17 +1035,14 @@ public: registerMagicMethods(); - Swig_banner(f_begin); + Swig_banner(f_runtime); - Printf(f_runtime, "\n"); Printf(f_runtime, "#define SWIGRUBY\n"); if (directorsEnabled()) { Printf(f_runtime, "#define SWIG_DIRECTORS\n"); } - Printf(f_runtime, "\n"); - /* typedef void *VALUE */ SwigType *value = NewSwigType(T_VOID); SwigType_add_pointer(value); @@ -1065,7 +1058,6 @@ public: Replaceall(module_macro, "::", "__"); Swig_banner(f_directors_h); - Printf(f_directors_h, "\n"); Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_macro); Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_macro); Printf(f_directors_h, "namespace Swig {\n"); @@ -1118,29 +1110,27 @@ public: SwigType_emit_type_table(f_runtime, f_wrappers); /* Close all of the files */ - Dump(f_runtime, f_begin); - Dump(f_header, f_begin); + Dump(f_header, f_runtime); if (directorsEnabled()) { - Dump(f_directors_helpers, f_begin); - Dump(f_directors, f_begin); + Dump(f_directors_helpers, f_runtime); + Dump(f_directors, f_runtime); Dump(f_directors_h, f_runtime_h); Printf(f_runtime_h, "\n"); Printf(f_runtime_h, "#endif\n"); Close(f_runtime_h); } - Dump(f_wrappers, f_begin); - Dump(f_initbeforefunc, f_begin); - Wrapper_pretty_print(f_init, f_begin); + Dump(f_wrappers, f_runtime); + Dump(f_initbeforefunc, f_runtime); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); Delete(f_initbeforefunc); - Close(f_begin); + Close(f_runtime); Delete(f_runtime); - Delete(f_begin); return SWIG_OK; } @@ -1236,7 +1226,7 @@ public: /** * Process the comma-separated list of aliases (if any). */ - void defineAliases(Node *n, const_String_or_char_ptr iname) { + void defineAliases(Node *n, const String_or_char *iname) { String *aliasv = Getattr(n, "feature:alias"); if (aliasv) { List *aliases = Split(aliasv, ',', INT_MAX); @@ -1270,7 +1260,7 @@ public: * as another instance of the same class. * --------------------------------------------------------------------- */ - void create_command(Node *n, const_String_or_char_ptr iname) { + void create_command(Node *n, const String_or_char *iname) { String *alloc_func = Swig_name_wrapper(iname); String *wname = Swig_name_wrapper(iname); @@ -2402,9 +2392,9 @@ public: void handleMarkFuncDirective(Node *n) { String *markfunc = Getattr(n, "feature:markfunc"); if (markfunc) { - Printf(klass->init, "SwigClass%s.mark = (void (*)(void *)) %s;\n", klass->name, markfunc); + Printf(klass->init, "c%s.mark = (void (*)(void *)) %s;\n", klass->name, markfunc); } else { - Printf(klass->init, "SwigClass%s.mark = 0;\n", klass->name); + Printf(klass->init, "c%s.mark = 0;\n", klass->name); } } @@ -2414,10 +2404,10 @@ public: void handleFreeFuncDirective(Node *n) { String *freefunc = Getattr(n, "feature:freefunc"); if (freefunc) { - Printf(klass->init, "SwigClass%s.destroy = (void (*)(void *)) %s;\n", klass->name, freefunc); + Printf(klass->init, "c%s.destroy = (void (*)(void *)) %s;\n", klass->name, freefunc); } else { if (klass->destructor_defined) { - Printf(klass->init, "SwigClass%s.destroy = (void (*)(void *)) free_%s;\n", klass->name, klass->mname); + Printf(klass->init, "c%s.destroy = (void (*)(void *)) free_%s;\n", klass->name, klass->mname); } } } @@ -2428,9 +2418,9 @@ public: void handleTrackDirective(Node *n) { int trackObjects = GetFlag(n, "feature:trackobjects"); if (trackObjects) { - Printf(klass->init, "SwigClass%s.trackObjects = 1;\n", klass->name); + Printf(klass->init, "c%s.trackObjects = 1;\n", klass->name); } else { - Printf(klass->init, "SwigClass%s.trackObjects = 0;\n", klass->name); + Printf(klass->init, "c%s.trackObjects = 0;\n", klass->name); } } @@ -2455,7 +2445,7 @@ public: Clear(klass->type); Printv(klass->type, Getattr(n, "classtype"), NIL); - Printv(f_wrappers, "swig_class SwigClass", valid_name, ";\n\n", NIL); + Printv(f_wrappers, "swig_class c", valid_name, ";\n\n", NIL); Printv(klass->init, "\n", tab4, NIL); if (!useGlobalModule) { @@ -2473,7 +2463,7 @@ public: SwigType_add_pointer(tt); SwigType_remember(tt); String *tm = SwigType_manglestr(tt); - Printf(klass->init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) &SwigClass%s);\n", tm, valid_name); + Printf(klass->init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) &c%s);\n", tm, valid_name); Delete(tm); Delete(tt); Delete(valid_name); @@ -2574,7 +2564,7 @@ public: /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; - Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate"); + Swig_name_register((String_or_char *) "construct", (String_or_char *) "%c_allocate"); Language::constructorHandler(n); @@ -2609,7 +2599,7 @@ public: Delete(docs); current = CONSTRUCTOR_INITIALIZE; - Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "new_%c"); + Swig_name_register((String_or_char *) "construct", (String_or_char *) "new_%c"); Language::constructorHandler(n); /* Restore original parameter list */ @@ -2617,7 +2607,7 @@ public: Swig_restore(n); /* Done */ - Swig_name_unregister((const_String_or_char_ptr ) "construct"); + Swig_name_unregister((String_or_char *) "construct"); current = NO_CPP; klass->constructor_defined = 1; return SWIG_OK; @@ -2631,7 +2621,7 @@ public: /* First wrap the allocate method */ current = CONSTRUCTOR_ALLOCATE; - Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate"); + Swig_name_register((String_or_char *) "construct", (String_or_char *) "%c_allocate"); return Language::copyconstructorHandler(n); } diff --git a/Source/Modules/s-exp.cxx b/Source/Modules/s-exp.cxx index 90791ec70..b89b3097f 100644 --- a/Source/Modules/s-exp.cxx +++ b/Source/Modules/s-exp.cxx @@ -29,9 +29,6 @@ public: } virtual void main(int argc, char *argv[]) { - // Add a symbol to the parser for conditional compilation - Preprocessor_define("SWIGSEXP 1", 0); - SWIG_typemap_lang("sexp"); for (int iX = 0; iX < argc; iX++) { if (strcmp(argv[iX], "-typemaplang") == 0) { @@ -45,6 +42,9 @@ public: fputs(usage, stdout); } } + + // Add a symbol to the parser for conditional compilation + Preprocessor_define("SWIGSEXP 1", 0); } DOHHash *print_circle_hash; @@ -59,7 +59,7 @@ public: String *outfile = Getattr(n, "outfile"); Replaceall(outfile, "_wrap.cxx", ".lisp"); Replaceall(outfile, "_wrap.c", ".lisp"); - out = NewFile(outfile, "w", SWIG_output_files()); + out = NewFile(outfile, "w"); if (!out) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -68,14 +68,10 @@ public: String *f_sink = NewString(""); Swig_register_filebyname("header", f_sink); Swig_register_filebyname("wrapper", f_sink); - Swig_register_filebyname("begin", f_sink); Swig_register_filebyname("runtime", f_sink); Swig_register_filebyname("init", f_sink); - Swig_banner_target_lang(out, ";;;"); - Language::top(n); - Printf(out, "\n"); Printf(out, ";;; Lisp parse tree produced by SWIG\n"); print_circle_hash = DohNewHash(); print_circle_count = 0; diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx index b121dc9b7..b727b9c67 100644 --- a/Source/Modules/swigmain.cxx +++ b/Source/Modules/swigmain.cxx @@ -32,8 +32,8 @@ extern "C" { Language *swig_modula3(void); Language *swig_mzscheme(void); Language *swig_java(void); - Language *swig_php(void); Language *swig_php4(void); + Language *swig_php5(void); Language *swig_ocaml(void); Language *swig_octave(void); Language *swig_pike(void); @@ -76,9 +76,9 @@ static swig_module modules[] = { {"-octave", swig_octave, "Octave"}, {"-perl", swig_perl5, "Perl"}, {"-perl5", swig_perl5, 0}, - {"-php", swig_php, "PHP"}, - {"-php4", swig_php4, 0}, - {"-php5", swig_php, 0}, + {"-php", swig_php4, 0}, + {"-php4", swig_php4, "PHP4"}, + {"-php5", swig_php5, "PHP5"}, {"-pike", swig_pike, "Pike"}, {"-python", swig_python, "Python"}, {"-r", swig_r, "R (aka GNU S)"}, diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h index 8dec8d0af..5835c6362 100644 --- a/Source/Modules/swigmod.h +++ b/Source/Modules/swigmod.h @@ -26,7 +26,7 @@ typedef int bool; #define PLAIN_VIRTUAL 1 #define PURE_VIRTUAL 2 -extern String *input_file; +extern char *input_file; extern int line_number; extern int start_line; extern int CPlusPlus; // C++ mode @@ -114,8 +114,8 @@ protected: class Language:public Dispatcher { public: - Language(); - virtual ~Language(); + Language (); + virtual ~ Language (); virtual int emit_one(Node *n); /* Parse command line options */ @@ -313,13 +313,10 @@ int SWIG_main(int, char **, Language *); void emit_parameter_variables(ParmList *l, Wrapper *f); void emit_return_variable(Node *n, SwigType *rt, Wrapper *f); void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */ -void SWIG_config_file(const_String_or_char_ptr ); +void SWIG_config_file(const String_or_char *); const String *SWIG_output_directory(); void SWIG_config_cppext(const char *ext); -/* get the list of generated files */ -List *SWIG_output_files(); - void SWIG_library_directory(const char *); int emit_num_arguments(ParmList *); int emit_num_required(ParmList *); @@ -329,17 +326,17 @@ void emit_mark_varargs(ParmList *l); String *emit_action(Node *n); int emit_action_code(Node *n, String *wrappercode, String *action); void Swig_overload_check(Node *n); -String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *); -String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *); -String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *); +String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *); +String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *); +String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *); SwigType *cplus_value_type(SwigType *t); /* directors.cxx start */ String *Swig_csuperclass_call(String *base, String *method, ParmList *l); String *Swig_class_declaration(Node *n, String *name); String *Swig_class_name(Node *n); -String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms); -String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values); +String *Swig_method_call(String_or_char *name, ParmList *parms); +String *Swig_method_decl(SwigType *rtype, SwigType *decl, const String_or_char *id, List *args, int strip, int values); String *Swig_director_declaration(Node *n); void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f); /* directors.cxx end */ diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx index 015ac5e45..09bd266c3 100644 --- a/Source/Modules/tcl8.cxx +++ b/Source/Modules/tcl8.cxx @@ -46,7 +46,6 @@ static int nosafe = 0; static File *f_header = 0; static File *f_wrappers = 0; static File *f_init = 0; -static File *f_begin = 0; static File *f_runtime = 0; @@ -122,7 +121,6 @@ public: } Preprocessor_define("SWIGTCL 1", 0); - // SWIGTCL8 is deprecated, and no longer documented. Preprocessor_define("SWIGTCL8 1", 0); SWIG_typemap_lang("tcl8"); SWIG_config_file("tcl8.swg"); @@ -138,12 +136,11 @@ public: /* Initialize all of the output files */ String *outfile = Getattr(n, "outfile"); - f_begin = NewFile(outfile, "w", SWIG_output_files()); - if (!f_begin) { + f_runtime = NewFile(outfile, "w"); + if (!f_runtime) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); } - f_runtime = NewString(""); f_init = NewString(""); f_header = NewString(""); f_wrappers = NewString(""); @@ -151,7 +148,6 @@ public: /* Register file targets with the SWIG file handler */ Swig_register_filebyname("header", f_header); Swig_register_filebyname("wrapper", f_wrappers); - Swig_register_filebyname("begin", f_begin); Swig_register_filebyname("runtime", f_runtime); Swig_register_filebyname("init", f_init); @@ -162,11 +158,7 @@ public: methods_tab = NewString(""); const_tab = NewString(""); - Swig_banner(f_begin); - - Printf(f_runtime, "\n"); - Printf(f_runtime, "#define SWIGTCL\n"); - Printf(f_runtime, "\n"); + Swig_banner(f_runtime); /* Set the module name, namespace, and prefix */ @@ -185,7 +177,7 @@ public: Insert(module, 0, "_"); - if ((f_shadow = NewFile(filen, "w", SWIG_output_files())) == 0) { + if ((f_shadow = NewFile(filen, "w")) == 0) { FileErrorDisplay(filen); SWIG_exit(EXIT_FAILURE); } @@ -194,7 +186,10 @@ public: Swig_register_filebyname("shadow", f_shadow); Swig_register_filebyname("itcl", f_shadow); - Swig_banner_target_lang(f_shadow, "#"); + Printf(f_shadow, "# This file was automatically generated by SWIG (http://www.swig.org).\n"); + Printf(f_shadow, "# Version %s\n", Swig_package_version()); + Printf(f_shadow, "#\n"); + Printf(f_shadow, "# Don't modify this file, modify the SWIG interface instead.\n"); Printv(f_shadow, "\npackage require Itcl\n\n", NIL); Delete(filen); @@ -249,15 +244,12 @@ public: } /* Close all of the files */ - Dump(f_runtime, f_begin); - Printv(f_begin, f_header, f_wrappers, NIL); - Wrapper_pretty_print(f_init, f_begin); + Printv(f_runtime, f_header, f_wrappers, NIL); + Wrapper_pretty_print(f_init, f_runtime); Delete(f_header); Delete(f_wrappers); Delete(f_init); - Close(f_begin); - Delete(f_runtime); - Delete(f_begin); + Close(f_runtime); return SWIG_OK; } diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx index d3f8401f0..7a94b77bb 100644 --- a/Source/Modules/uffi.cxx +++ b/Source/Modules/uffi.cxx @@ -26,6 +26,7 @@ public: }; static File *f_cl = 0; +static File *f_null = 0; static struct { int count; @@ -131,7 +132,7 @@ static void add_defined_foreign_type(String *type) { } -static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) { +static String *get_ffi_type(SwigType *ty, const String_or_char *name) { Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0); if (typemap) { String *typespec = Getattr(typemap, "code"); @@ -167,7 +168,7 @@ static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) { return 0; } -static String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) { +static String *get_lisp_type(SwigType *ty, const String_or_char *name) { Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0); if (typemap) { String *typespec = Getattr(typemap, "code"); @@ -180,7 +181,6 @@ static String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) { void UFFI::main(int argc, char *argv[]) { int i; - Preprocessor_define("SWIGUFFI 1", 0); SWIG_library_directory("uffi"); SWIG_config_file("uffi.swg"); @@ -225,26 +225,31 @@ void UFFI::main(int argc, char *argv[]) { int UFFI::top(Node *n) { String *module = Getattr(n, "name"); String *output_filename = NewString(""); - File *f_null = NewString(""); + String *devnull = NewString("/dev/null"); + + f_null = NewFile(devnull, "w+"); + if (!f_null) { + FileErrorDisplay(devnull); + SWIG_exit(EXIT_FAILURE); + } + Delete(devnull); + Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module); - f_cl = NewFile(output_filename, "w", SWIG_output_files()); + f_cl = NewFile(output_filename, "w"); if (!f_cl) { FileErrorDisplay(output_filename); SWIG_exit(EXIT_FAILURE); } Swig_register_filebyname("header", f_null); - Swig_register_filebyname("begin", f_null); Swig_register_filebyname("runtime", f_null); Swig_register_filebyname("wrapper", f_cl); - Swig_banner_target_lang(f_cl, ";;"); - - Printf(f_cl, "\n" - ";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n", + Printf(f_cl, + ";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n;; This is an automatically generated file. Make changes in\n;; the definition file, not here.\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n", module, module, module); Printf(f_cl, "(eval-when (compile load eval)\n (defparameter *swig-identifier-converter* '%s))\n", identifier_converter); diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx index 2edd01cf0..c74b48d7c 100644 --- a/Source/Modules/xml.cxx +++ b/Source/Modules/xml.cxx @@ -47,7 +47,7 @@ public: iX++; Swig_mark_arg(iX); String *outfile = NewString(argv[iX]); - out = NewFile(outfile, "w", SWIG_output_files()); + out = NewFile(outfile, "w"); if (!out) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -82,7 +82,7 @@ public: Replaceall(outfile, ".cxx", ".xml"); Replaceall(outfile, ".cpp", ".xml"); Replaceall(outfile, ".c", ".xml"); - out = NewFile(outfile, "w", SWIG_output_files()); + out = NewFile(outfile, "w"); if (!out) { FileErrorDisplay(outfile); SWIG_exit(EXIT_FAILURE); @@ -301,7 +301,7 @@ void Swig_print_xml(DOH *obj, String *filename) { if (!filename) { out = stdout; } else { - out = NewFile(filename, "w", SWIG_output_files()); + out = NewFile(filename, "w"); if (!out) { FileErrorDisplay(filename); SWIG_exit(EXIT_FAILURE); diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c index 81646171a..c04f95f00 100644 --- a/Source/Preprocessor/cpp.c +++ b/Source/Preprocessor/cpp.c @@ -74,7 +74,7 @@ static void copy_location(const DOH *s1, DOH *s2) { Setline(s2, Getline((DOH *) s1)); } -static String *cpp_include(const_String_or_char_ptr fn, int sysfile) { +static String *cpp_include(String_or_char *fn, int sysfile) { String *s = sysfile ? Swig_include_sys(fn) : Swig_include(fn); if (s && single_include) { String *file = Getfile(s); @@ -85,8 +85,7 @@ static String *cpp_include(const_String_or_char_ptr fn, int sysfile) { Setattr(included_files, file, file); } if (!s) { - /* XXX(bhy) may not need the seek */ - /* Seek(fn, 0, SEEK_SET); */ + Seek(fn, 0, SEEK_SET); if (ignore_missing) { Swig_warning(WARN_PP_MISSING_FILE, Getfile(fn), Getline(fn), "Unable to find '%s'\n", fn); } else { @@ -262,9 +261,8 @@ void Preprocessor_error_as_warning(int a) { * ----------------------------------------------------------------------------- */ -String *Macro_vararg_name(const_String_or_char_ptr str, const_String_or_char_ptr line) { - String *argname; - String *varargname; +String_or_char *Macro_vararg_name(String_or_char *str, String_or_char *line) { + String_or_char *argname, *varargname; char *s, *dots; argname = Copy(str); @@ -290,24 +288,24 @@ String *Macro_vararg_name(const_String_or_char_ptr str, const_String_or_char_ptr return varargname; } -Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) { +Hash *Preprocessor_define(const String_or_char *_str, int swigmacro) { String *macroname = 0, *argstr = 0, *macrovalue = 0, *file = 0, *s = 0; Hash *macro = 0, *symbols = 0, *m1; List *arglist = 0; int c, line; int varargs = 0; - String *str; + String_or_char *str = (String_or_char *) _str; assert(cpp); - assert(_str); + assert(str); /* First make sure that string is actually a string */ - if (DohCheck(_str)) { - s = Copy(_str); - copy_location(_str, s); + if (DohCheck(str)) { + s = Copy(str); + copy_location(str, s); str = s; } else { - str = NewString((char *) _str); + str = NewString((char *) str); } Seek(str, 0, SEEK_SET); line = Getline(str); @@ -534,7 +532,7 @@ macro_error: * * Undefines a macro. * ----------------------------------------------------------------------------- */ -void Preprocessor_undef(const_String_or_char_ptr str) { +void Preprocessor_undef(const String_or_char *str) { Hash *symbols; assert(cpp); symbols = Getattr(cpp, kpp_symbols); @@ -652,7 +650,14 @@ static String *get_filename(String *str, int *sysfile) { if (isspace(c)) Ungetc(c, str); } - Swig_filename_correct(fn); +#if defined(_WIN32) || defined(MACSWIG) + /* accept Unix path separator on non-Unix systems */ + Replaceall(fn, "/", SWIG_FILE_DELIMITER); +#endif +#if defined(__CYGWIN__) + /* accept Windows path separator in addition to Unix path separator */ + Replaceall(fn, "\\", SWIG_FILE_DELIMITER); +#endif Seek(fn, 0, SEEK_SET); return fn; } diff --git a/Source/Preprocessor/preprocessor.h b/Source/Preprocessor/preprocessor.h index 3579eede2..4f7ff8804 100644 --- a/Source/Preprocessor/preprocessor.h +++ b/Source/Preprocessor/preprocessor.h @@ -19,8 +19,8 @@ extern "C" { #endif extern int Preprocessor_expr(String *s, int *error); extern char *Preprocessor_expr_error(void); - extern Hash *Preprocessor_define(const_String_or_char_ptr str, int swigmacro); - extern void Preprocessor_undef(const_String_or_char_ptr name); + extern Hash *Preprocessor_define(const String_or_char *str, int swigmacro); + extern void Preprocessor_undef(const String_or_char *name); extern void Preprocessor_init(void); extern void Preprocessor_delete(void); extern String *Preprocessor_parse(String *s); diff --git a/Source/README b/Source/README index 814ec45bd..8d910e405 100644 --- a/Source/README +++ b/Source/README @@ -1,5 +1,9 @@ SWIG Source directory +This directory currently contains a mix of legacy SWIG1.1 code and +recent development work. As a result, it's still a little messy. +Here is a rough breakdown of the directories: + Source/DOH - A core set of basic datatypes including strings, lists, hashes, and files. Used extensively by the rest of SWIG. @@ -12,9 +16,8 @@ SWIG Source directory Source/Modules - Language modules. - Source/Include - Include files. -Historic directories which may be in CVS, but have been removed: +The following directories may be in CVS, but are largely deprecated: Source/Modules1.1 - Old SWIG-1.1 modules. Empty. @@ -23,3 +26,5 @@ Historic directories which may be in CVS, but have been removed: Source/SWIG1.1 - Old SWIG1.1 core. Completely empty now. + + diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c index 7c6837a2b..18920ecc2 100644 --- a/Source/Swig/cwrap.c +++ b/Source/Swig/cwrap.c @@ -45,7 +45,7 @@ String *Swig_cparm_name(Parm *p, int i) { * and user defined types to pointers. * ----------------------------------------------------------------------------- */ -static String *Swig_clocal(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr value) { +static String *Swig_clocal(SwigType *t, const String_or_char *name, const String_or_char *value) { String *decl; decl = NewStringEmpty(); @@ -147,7 +147,7 @@ String *Swig_wrapped_member_var_type(SwigType *t, int varcref) { } -static String *Swig_wrapped_var_deref(SwigType *t, const_String_or_char_ptr name, int varcref) { +static String *Swig_wrapped_var_deref(SwigType *t, String_or_char *name, int varcref) { if (SwigType_isclass(t)) { if (varcref) { if (cparse_cplusplus) { @@ -163,7 +163,7 @@ static String *Swig_wrapped_var_deref(SwigType *t, const_String_or_char_ptr name } } -static String *Swig_wrapped_var_assign(SwigType *t, const_String_or_char_ptr name, int varcref) { +static String *Swig_wrapped_var_assign(SwigType *t, const String_or_char *name, int varcref) { if (SwigType_isclass(t)) { if (varcref) { return NewStringf("%s", name); @@ -251,7 +251,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) { * function call. * ----------------------------------------------------------------------------- */ -String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl) { +String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl) { String *fcall; fcall = NewStringEmpty(); @@ -260,9 +260,10 @@ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or break; case T_REFERENCE: { - String *lstr = SwigType_lstr(t, 0); - Printf(fcall, "%s = (%s) &", name, lstr); - Delete(lstr); + String *str = SwigType_str(t, "_result_ref"); + Printf(fcall, "{\n"); + Printf(fcall, "%s = ", str); + Delete(str); } break; case T_USER: @@ -289,6 +290,12 @@ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or Append(fcall, ";"); } + if (SwigType_type(t) == T_REFERENCE) { + String *lstr = SwigType_lstr(t, 0); + Printf(fcall, "\n%s = (%s) &_result_ref;\n", name, lstr); + Append(fcall, "}"); + Delete(lstr); + } return fcall; } @@ -302,7 +309,7 @@ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or * * ----------------------------------------------------------------------------- */ -String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms) { +String *Swig_cfunction_call(String_or_char *name, ParmList *parms) { String *func; int i = 0; int comma = 0; @@ -369,7 +376,7 @@ String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms) { * set to "(*this)->" or some similar sequence. * ----------------------------------------------------------------------------- */ -static String *Swig_cmethod_call(const_String_or_char_ptr name, ParmList *parms, const_String_or_char_ptr self, String *explicit_qualifier, SwigType *director_type) { +static String *Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self, String *explicit_qualifier, SwigType *director_type) { String *func, *nname; int i = 0; Parm *p = parms; @@ -461,7 +468,7 @@ static String *Swig_cmethod_call(const_String_or_char_ptr name, ParmList *parms, * calloc(1,sizeof(name)); * ----------------------------------------------------------------------------- */ -String *Swig_cconstructor_call(const_String_or_char_ptr name) { +String *Swig_cconstructor_call(String_or_char *name) { DOH *func; func = NewStringEmpty(); @@ -480,7 +487,7 @@ String *Swig_cconstructor_call(const_String_or_char_ptr name) { * * ----------------------------------------------------------------------------- */ -String *Swig_cppconstructor_base_call(const_String_or_char_ptr name, ParmList *parms, int skip_self) { +String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int skip_self) { String *func; String *nname; int i = 0; @@ -525,15 +532,15 @@ String *Swig_cppconstructor_base_call(const_String_or_char_ptr name, ParmList *p return func; } -String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms) { +String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms) { return Swig_cppconstructor_base_call(name, parms, 0); } -String *Swig_cppconstructor_nodirector_call(const_String_or_char_ptr name, ParmList *parms) { +String *Swig_cppconstructor_nodirector_call(String_or_char *name, ParmList *parms) { return Swig_cppconstructor_base_call(name, parms, 1); } -String *Swig_cppconstructor_director_call(const_String_or_char_ptr name, ParmList *parms) { +String *Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms) { return Swig_cppconstructor_base_call(name, parms, 0); } @@ -676,7 +683,7 @@ String *Swig_cppdestructor_call(Node *n) { * * ----------------------------------------------------------------------------- */ -String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref) { +String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref) { String *func; String *pname0 = Swig_cparm_name(0, 0); String *pname1 = Swig_cparm_name(0, 1); @@ -711,7 +718,7 @@ String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, Stri * * ----------------------------------------------------------------------------- */ -String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref) { +String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref) { String *func; String *call; String *pname0 = Swig_cparm_name(0, 0); @@ -1203,7 +1210,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags) * This function creates a C wrapper for setting a structure member. * ----------------------------------------------------------------------------- */ -int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call) { +int Swig_MembersetToFunction(Node *n, String *classname, int flags) { String *name; ParmList *parms; Parm *p; @@ -1251,21 +1258,23 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **cal Delete(p); if (flags & CWRAP_EXTEND) { + String *call; String *cres; String *code = Getattr(n, "code"); if (code) { /* I don't think this ever gets run - WSF */ Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self"); } - *call = Swig_cfunction_call(mangled, parms); - cres = NewStringf("%s;", *call); + call = Swig_cfunction_call(mangled, parms); + cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); + Delete(call); Delete(cres); } else { - String *cres; - *call = Swig_cmemberset_call(name, type, self, varcref); - cres = NewStringf("%s;", *call); + String *call = Swig_cmemberset_call(name, type, self, varcref); + String *cres = NewStringf("%s;", call); Setattr(n, "wrap:action", cres); + Delete(call); Delete(cres); } Setattr(n, "type", void_type); diff --git a/Source/Swig/error.c b/Source/Swig/error.c index 156fe06a7..1eaba1f17 100644 --- a/Source/Swig/error.c +++ b/Source/Swig/error.c @@ -50,7 +50,7 @@ static char wrn_nnum_fmt[64]; static char err_line_fmt[64]; static char err_eof_fmt[64]; -static String *format_filename(const_String_or_char_ptr filename); +static String *format_filename(const String_or_char *filename); /* ----------------------------------------------------------------------------- * Swig_warning() @@ -58,7 +58,7 @@ static String *format_filename(const_String_or_char_ptr filename); * Issue a warning message * ----------------------------------------------------------------------------- */ -void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const char *fmt, ...) { +void Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt, ...) { String *out; char *msg; int wrn = 1; @@ -121,7 +121,7 @@ void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const c * Issue an error message * ----------------------------------------------------------------------------- */ -void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...) { +void Swig_error(const String_or_char *filename, int line, const char *fmt, ...) { va_list ap; String *formatted_filename = NULL; @@ -170,7 +170,7 @@ void Swig_error_silent(int s) { * Takes a comma separate list of warning numbers and puts in the filter. * ----------------------------------------------------------------------------- */ -void Swig_warnfilter(const_String_or_char_ptr wlist, int add) { +void Swig_warnfilter(const String_or_char *wlist, int add) { char *c; char *cw; String *s; @@ -268,7 +268,7 @@ void Swig_error_msg_format(ErrorMessageFormat format) { * * Remove double backslashes in Windows filename paths for display * ----------------------------------------------------------------------------- */ -static String *format_filename(const_String_or_char_ptr filename) { +static String *format_filename(const String_or_char *filename) { String *formatted_filename = NewString(filename); #if defined(_WIN32) Replaceall(formatted_filename, "\\\\", "\\"); diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c index cbd051d9f..87b0f7c9d 100644 --- a/Source/Swig/getopt.c +++ b/Source/Swig/getopt.c @@ -100,7 +100,7 @@ void Swig_check_options(int check_input) { * Generates a generic error message and exits. * ----------------------------------------------------------------------------- */ -void Swig_arg_error(void) { +void Swig_arg_error() { Printf(stderr, "SWIG : Unable to parse command line options.\n"); Printf(stderr, "Use 'swig -help' for available options.\n"); exit(1); diff --git a/Source/Swig/include.c b/Source/Swig/include.c index f42eb5d45..3f47be15b 100644 --- a/Source/Swig/include.c +++ b/Source/Swig/include.c @@ -33,7 +33,7 @@ int Swig_get_push_dir(void) { * Adds a directory to the SWIG search path. * ----------------------------------------------------------------------------- */ -List *Swig_add_directory(const_String_or_char_ptr dirname) { +List *Swig_add_directory(const String_or_char *dirname) { String *adirname; if (!directories) directories = NewList(); @@ -53,7 +53,7 @@ List *Swig_add_directory(const_String_or_char_ptr dirname) { * the preprocessor to grab files in the same directory as other included files. * ----------------------------------------------------------------------------- */ -void Swig_push_directory(const_String_or_char_ptr dirname) { +void Swig_push_directory(const String_or_char *dirname) { String *pdirname; if (!Swig_get_push_dir()) return; @@ -73,7 +73,7 @@ void Swig_push_directory(const_String_or_char_ptr dirname) { * the preprocessor. * ----------------------------------------------------------------------------- */ -void Swig_pop_directory(void) { +void Swig_pop_directory() { if (!Swig_get_push_dir()) return; if (!pdirectories) @@ -87,13 +87,13 @@ void Swig_pop_directory(void) { * Returns the full pathname of the last file opened. * ----------------------------------------------------------------------------- */ -String *Swig_last_file(void) { +String *Swig_last_file() { assert(lastpath); return lastpath; } /* ----------------------------------------------------------------------------- - * Swig_search_path_any() + * Swig_search_path() * * Returns a list of the current search paths. * ----------------------------------------------------------------------------- */ @@ -151,11 +151,10 @@ List *Swig_search_path() { /* ----------------------------------------------------------------------------- * Swig_open() * - * open a file, optionally looking for it in the include path. Returns an open - * FILE * on success. + * Looks for a file and open it. Returns an open FILE * on success. * ----------------------------------------------------------------------------- */ -static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_include_path) { +static FILE *Swig_open_any(const String_or_char *name, int sysfile) { FILE *f; String *filename; List *spath = 0; @@ -170,7 +169,7 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_ filename = NewString(cname); assert(filename); f = fopen(Char(filename), "r"); - if (!f && use_include_path) { + if (!f) { spath = Swig_search_path_any(sysfile); ilen = Len(spath); for (i = 0; i < ilen; i++) { @@ -183,21 +182,19 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_ Delete(spath); } if (f) { +#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */ + Replaceall(filename, "\\\\", "\\"); /* remove double '\' in case any already present */ + Replaceall(filename, "\\", "\\\\"); +#endif Delete(lastpath); - lastpath = Swig_filename_escape(filename); + lastpath = Copy(filename); } Delete(filename); return f; } -/* Open a file - searching the include paths to find it */ -FILE *Swig_include_open(const_String_or_char_ptr name) { - return Swig_open_file(name, 0, 1); -} - -/* Open a file - does not use include paths to find it */ -FILE *Swig_open(const_String_or_char_ptr name) { - return Swig_open_file(name, 0, 0); +FILE *Swig_open(const String_or_char *name) { + return Swig_open_any(name, 0); } @@ -233,12 +230,12 @@ String *Swig_read_file(FILE *f) { * Opens a file and returns it as a string. * ----------------------------------------------------------------------------- */ -static String *Swig_include_any(const_String_or_char_ptr name, int sysfile) { +static String *Swig_include_any(const String_or_char *name, int sysfile) { FILE *f; String *str; String *file; - f = Swig_open_file(name, sysfile, 1); + f = Swig_open_any(name, sysfile); if (!f) return 0; str = Swig_read_file(f); @@ -251,11 +248,11 @@ static String *Swig_include_any(const_String_or_char_ptr name, int sysfile) { return str; } -String *Swig_include(const_String_or_char_ptr name) { +String *Swig_include(const String_or_char *name) { return Swig_include_any(name, 0); } -String *Swig_include_sys(const_String_or_char_ptr name) { +String *Swig_include_sys(const String_or_char *name) { return Swig_include_any(name, 1); } @@ -265,10 +262,10 @@ String *Swig_include_sys(const_String_or_char_ptr name) { * Copies the contents of a file into another file * ----------------------------------------------------------------------------- */ -int Swig_insert_file(const_String_or_char_ptr filename, File *outfile) { +int Swig_insert_file(const String_or_char *filename, File *outfile) { char buffer[4096]; int nbytes; - FILE *f = Swig_include_open(filename); + FILE *f = Swig_open(filename); if (!f) return -1; @@ -289,7 +286,7 @@ int Swig_insert_file(const_String_or_char_ptr filename, File *outfile) { static Hash *named_files = 0; -void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile) { +void Swig_register_filebyname(const String_or_char *filename, File *outfile) { if (!named_files) named_files = NewHash(); Setattr(named_files, filename, outfile); @@ -301,7 +298,7 @@ void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile) * Get a named file * ----------------------------------------------------------------------------- */ -File *Swig_filebyname(const_String_or_char_ptr filename) { +File *Swig_filebyname(const String_or_char *filename) { if (!named_files) return 0; return Getattr(named_files, filename); @@ -313,7 +310,7 @@ File *Swig_filebyname(const_String_or_char_ptr filename) { * Returns the suffix of a file * ----------------------------------------------------------------------------- */ -char *Swig_file_suffix(const_String_or_char_ptr filename) { +char *Swig_file_suffix(const String_or_char *filename) { char *d; char *c = Char(filename); int len = Len(filename); @@ -335,7 +332,7 @@ char *Swig_file_suffix(const_String_or_char_ptr filename) { * Returns the filename with no suffix attached. * ----------------------------------------------------------------------------- */ -char *Swig_file_basename(const_String_or_char_ptr filename) { +char *Swig_file_basename(const String_or_char *filename) { static char tmp[1024]; char *c; strcpy(tmp, Char(filename)); @@ -349,7 +346,7 @@ char *Swig_file_basename(const_String_or_char_ptr filename) { * * Return the file with any leading path stripped off * ----------------------------------------------------------------------------- */ -char *Swig_file_filename(const_String_or_char_ptr filename) { +char *Swig_file_filename(const String_or_char *filename) { static char tmp[1024]; const char *delim = SWIG_FILE_DELIMITER; char *c; @@ -367,7 +364,7 @@ char *Swig_file_filename(const_String_or_char_ptr filename) { * * Return the name of the directory associated with a file * ----------------------------------------------------------------------------- */ -char *Swig_file_dirname(const_String_or_char_ptr filename) { +char *Swig_file_dirname(const String_or_char *filename) { static char tmp[1024]; const char *delim = SWIG_FILE_DELIMITER; char *c; diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c index 050e5357a..d29250517 100644 --- a/Source/Swig/misc.c +++ b/Source/Swig/misc.c @@ -54,7 +54,7 @@ const char *Swig_package_version(void) { /* ----------------------------------------------------------------------------- * Swig_banner() * - * Emits the SWIG identifying banner for the C/C++ wrapper file. + * Emits the SWIG identifying banner. * ----------------------------------------------------------------------------- */ void Swig_banner(File *f) { @@ -67,24 +67,10 @@ void Swig_banner(File *f) { * changes to this file unless you know what you are doing--modify the SWIG \n\ * interface file instead. \n", Swig_package_version()); /* String too long for ISO compliance */ - Printf(f, " * ----------------------------------------------------------------------------- */\n"); + Printf(f, " * ----------------------------------------------------------------------------- */\n\n"); } -/* ----------------------------------------------------------------------------- - * Swig_banner_target_lang() - * - * Emits a SWIG identifying banner in the target language - * ----------------------------------------------------------------------------- */ - -void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar) { - Printf(f, "%s This file was automatically generated by SWIG (http://www.swig.org).\n", commentchar); - Printf(f, "%s Version %s\n", commentchar, Swig_package_version()); - Printf(f, "%s\n", commentchar); - Printf(f, "%s Do not make changes to this file unless you know what you are doing--modify\n", commentchar); - Printf(f, "%s the SWIG interface file instead.\n", commentchar); -} - /* ----------------------------------------------------------------------------- * Swig_strip_c_comments() * @@ -131,39 +117,6 @@ String *Swig_strip_c_comments(const String *s) { } -/* ----------------------------------------------------------------------------- - * Swig_filename_correct() - * - * Corrects filenames on non-unix systems - * ----------------------------------------------------------------------------- */ - -void Swig_filename_correct(String *filename) { - (void)filename; -#if defined(_WIN32) || defined(MACSWIG) - /* accept Unix path separator on non-Unix systems */ - Replaceall(filename, "/", SWIG_FILE_DELIMITER); -#endif -#if defined(__CYGWIN__) - /* accept Windows path separator in addition to Unix path separator */ - Replaceall(filename, "\\", SWIG_FILE_DELIMITER); -#endif -} - -/* ----------------------------------------------------------------------------- - * Swig_filename_escape() - * - * Escapes backslashes in filename - for Windows - * ----------------------------------------------------------------------------- */ - -String *Swig_filename_escape(String *filename) { - String *adjusted_filename = Copy(filename); -#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */ - Replaceall(adjusted_filename, "\\\\", "\\"); /* remove double '\' in case any already present */ - Replaceall(adjusted_filename, "\\", "\\\\"); -#endif - return adjusted_filename; -} - /* ----------------------------------------------------------------------------- * Swig_string_escape() * @@ -651,7 +604,7 @@ String *Swig_string_emangle(String *s) { * In this case, "A::B". Returns NULL if there is no base. * ----------------------------------------------------------------------------- */ -void Swig_scopename_split(const String *s, String **rprefix, String **rlast) { +void Swig_scopename_split(String *s, String **rprefix, String **rlast) { char *tmp = Char(s); char *c = tmp; char *cc = c; @@ -705,7 +658,7 @@ void Swig_scopename_split(const String *s, String **rprefix, String **rlast) { } -String *Swig_scopename_prefix(const String *s) { +String *Swig_scopename_prefix(String *s) { char *tmp = Char(s); char *c = tmp; char *cc = c; @@ -757,7 +710,7 @@ String *Swig_scopename_prefix(const String *s) { * case, "C". * ----------------------------------------------------------------------------- */ -String *Swig_scopename_last(const String *s) { +String *Swig_scopename_last(String *s) { char *tmp = Char(s); char *c = tmp; char *cc = c; @@ -801,7 +754,7 @@ String *Swig_scopename_last(const String *s) { * In this case, "A". Returns NULL if there is no base. * ----------------------------------------------------------------------------- */ -String *Swig_scopename_first(const String *s) { +String *Swig_scopename_first(String *s) { char *tmp = Char(s); char *c = tmp; char *co = 0; @@ -851,7 +804,7 @@ String *Swig_scopename_first(const String *s) { * In this case, "B::C". Returns NULL if there is no suffix. * ----------------------------------------------------------------------------- */ -String *Swig_scopename_suffix(const String *s) { +String *Swig_scopename_suffix(String *s) { char *tmp = Char(s); char *c = tmp; char *co = 0; @@ -895,7 +848,7 @@ String *Swig_scopename_suffix(const String *s) { * Checks to see if a name is qualified with a scope name * ----------------------------------------------------------------------------- */ -int Swig_scopename_check(const String *s) { +int Swig_scopename_check(String *s) { char *c = Char(s); char *co = strstr(c, "operator "); @@ -973,37 +926,6 @@ String *Swig_string_command(String *s) { } -/* ----------------------------------------------------------------------------- - * Swig_string_strip() - * - * Strip given prefix from identifiers - * - * Printf(stderr,"%(strip:[wx])s","wxHello") -> Hello - * ----------------------------------------------------------------------------- */ - -String *Swig_string_strip(String *s) { - String *ns; - if (!Len(s)) { - ns = NewString(s); - } else { - const char *cs = Char(s); - const char *ce = Strchr(cs, ']'); - if (*cs != '[' || ce == NULL) { - ns = NewString(s); - } else { - String *fmt = NewStringf("%%.%ds", ce-cs-1); - String *prefix = NewStringf(fmt, cs+1); - if (0 == Strncmp(ce+1, prefix, Len(prefix))) { - ns = NewString(ce+1+Len(prefix)); - } else { - ns = NewString(ce+1); - } - } - } - return ns; -} - - /* ----------------------------------------------------------------------------- * Swig_string_rxspencer() * @@ -1131,7 +1053,6 @@ void Swig_init() { DohEncoding("command", Swig_string_command); DohEncoding("rxspencer", Swig_string_rxspencer); DohEncoding("schemify", Swig_string_schemify); - DohEncoding("strip", Swig_string_strip); /* aliases for the case encoders */ DohEncoding("uppercase", Swig_string_upper); diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c index 013ce5929..f34a24612 100644 --- a/Source/Swig/naming.c +++ b/Source/Swig/naming.c @@ -27,13 +27,13 @@ static Hash *naming_hash = 0; * Register a new naming format. * ----------------------------------------------------------------------------- */ -void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format) { +void Swig_name_register(const String_or_char *method, const String_or_char *format) { if (!naming_hash) naming_hash = NewHash(); Setattr(naming_hash, method, format); } -void Swig_name_unregister(const_String_or_char_ptr method) { +void Swig_name_unregister(const String_or_char *method) { if (naming_hash) { Delattr(naming_hash, method); } @@ -127,7 +127,7 @@ static int name_mangle(String *r) { * Converts all of the non-identifier characters of a string to underscores. * ----------------------------------------------------------------------------- */ -String *Swig_name_mangle(const_String_or_char_ptr s) { +String *Swig_name_mangle(const String_or_char *s) { #if 0 String *r = NewString(s); name_mangle(r); @@ -143,7 +143,7 @@ String *Swig_name_mangle(const_String_or_char_ptr s) { * Returns the name of a wrapper function. * ----------------------------------------------------------------------------- */ -String *Swig_name_wrapper(const_String_or_char_ptr fname) { +String *Swig_name_wrapper(const String_or_char *fname) { String *r; String *f; @@ -168,7 +168,7 @@ String *Swig_name_wrapper(const_String_or_char_ptr fname) { * Returns the name of a class method. * ----------------------------------------------------------------------------- */ -String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname) { +String *Swig_name_member(const String_or_char *classname, const String_or_char *mname) { String *r; String *f; String *rclassname; @@ -201,7 +201,7 @@ String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_cha * Returns the name of the accessor function used to get a variable. * ----------------------------------------------------------------------------- */ -String *Swig_name_get(const_String_or_char_ptr vname) { +String *Swig_name_get(const String_or_char *vname) { String *r; String *f; @@ -229,7 +229,7 @@ String *Swig_name_get(const_String_or_char_ptr vname) { * Returns the name of the accessor function used to set a variable. * ----------------------------------------------------------------------------- */ -String *Swig_name_set(const_String_or_char_ptr vname) { +String *Swig_name_set(const String_or_char *vname) { String *r; String *f; @@ -253,7 +253,7 @@ String *Swig_name_set(const_String_or_char_ptr vname) { * Returns the name of the accessor function used to create an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_construct(const_String_or_char_ptr classname) { +String *Swig_name_construct(const String_or_char *classname) { String *r; String *f; String *rclassname; @@ -286,7 +286,7 @@ String *Swig_name_construct(const_String_or_char_ptr classname) { * Returns the name of the accessor function used to copy an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_copyconstructor(const_String_or_char_ptr classname) { +String *Swig_name_copyconstructor(const String_or_char *classname) { String *r; String *f; String *rclassname; @@ -319,7 +319,7 @@ String *Swig_name_copyconstructor(const_String_or_char_ptr classname) { * Returns the name of the accessor function used to destroy an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_destroy(const_String_or_char_ptr classname) { +String *Swig_name_destroy(const String_or_char *classname) { String *r; String *f; String *rclassname; @@ -351,7 +351,7 @@ String *Swig_name_destroy(const_String_or_char_ptr classname) { * Returns the name of the accessor function used to disown an object. * ----------------------------------------------------------------------------- */ -String *Swig_name_disown(const_String_or_char_ptr classname) { +String *Swig_name_disown(const String_or_char *classname) { String *r; String *f; String *rclassname; @@ -600,7 +600,7 @@ static void merge_features(Hash *features, Node *n) { * ----------------------------------------------------------------------------- */ static -void features_get(Hash *features, const String *tname, SwigType *decl, SwigType *ncdecl, Node *node) { +void features_get(Hash *features, String *tname, SwigType *decl, SwigType *ncdecl, Node *node) { Node *n = Getattr(features, tname); #ifdef SWIG_DEBUG Printf(stdout, " features_get: %s\n", tname); @@ -655,7 +655,7 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d } #ifdef SWIG_DEBUG - Printf(stdout, "Swig_features_get: '%s' '%s' '%s'\n", prefix, name, decl); + Printf(stdout, "Swig_features_get: %s %s %s\n", prefix, name, decl); #endif /* Global features */ @@ -727,12 +727,12 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d * concatenating the feature name plus ':' plus the attribute name. * ----------------------------------------------------------------------------- */ -void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, String *value, Hash *featureattribs) { +void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs) { Hash *n; Hash *fhash; #ifdef SWIG_DEBUG - Printf(stdout, "Swig_feature_set: '%s' '%s' '%s' '%s'\n", name, decl, featurename, value); + Printf(stdout, "Swig_feature_set: %s %s %s %s\n", name, decl, featurename, value); #endif n = Getattr(features, name); @@ -1436,7 +1436,7 @@ static String *apply_rename(String *newname, int fullname, String *prefix, Strin * * ----------------------------------------------------------------------------- */ -String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname) { +String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname) { String *nname = 0; String *result = 0; String *name = NewString(cname); diff --git a/Source/Swig/parms.c b/Source/Swig/parms.c index 9b58f5fcb..baa1dfbf3 100644 --- a/Source/Swig/parms.c +++ b/Source/Swig/parms.c @@ -17,7 +17,7 @@ char cvsroot_parms_c[] = "$Id$"; * Create a new parameter from datatype 'type' and name 'name'. * ------------------------------------------------------------------------ */ -Parm *NewParm(SwigType *type, const_String_or_char_ptr name) { +Parm *NewParm(SwigType *type, const String_or_char *name) { Parm *p = NewHash(); set_nodeType(p, "parm"); if (type) { diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c index 53f1ad4a0..06e78db37 100644 --- a/Source/Swig/scanner.c +++ b/Source/Swig/scanner.c @@ -15,9 +15,6 @@ char cvsroot_scanner_c[] = "$Id$"; #include "swig.h" #include -extern String *cparse_file; -extern int cparse_start_line; - struct Scanner { String *text; /* Current token value */ List *scanobjs; /* Objects being scanned */ @@ -39,7 +36,7 @@ struct Scanner { * Create a new scanner object * ----------------------------------------------------------------------------- */ -Scanner *NewScanner(void) { +Scanner *NewScanner() { Scanner *s; s = (Scanner *) malloc(sizeof(Scanner)); s->line = 1; @@ -118,11 +115,11 @@ void Scanner_push(Scanner * s, String *txt) { * call to Scanner_token(). * ----------------------------------------------------------------------------- */ -void Scanner_pushtoken(Scanner * s, int nt, const_String_or_char_ptr val) { +void Scanner_pushtoken(Scanner * s, int nt, const String_or_char *val) { assert(s); assert((nt >= 0) && (nt < SWIG_MAXTOKENS)); s->nexttoken = nt; - if ( Char(val) != Char(s->text) ) { + if (val != s->text) { Clear(s->text); Append(s->text,val); } @@ -212,7 +209,7 @@ static char nextchar(Scanner * s) { * Sets error information on the scanner. * ----------------------------------------------------------------------------- */ -static void set_error(Scanner *s, int line, const_String_or_char_ptr msg) { +static void set_error(Scanner *s, int line, String_or_char *msg) { s->error_line = line; s->error = NewString(msg); } @@ -539,7 +536,7 @@ static int look(Scanner * s) { break; case 10: /* C++ style comment */ if ((c = nextchar(s)) == 0) { - Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); + set_error(s,s->start_line,"Unterminated comment"); return SWIG_TOKEN_ERROR; } if (c == '\n') { @@ -551,7 +548,7 @@ static int look(Scanner * s) { break; case 11: /* C style comment block */ if ((c = nextchar(s)) == 0) { - Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); + set_error(s,s->start_line,"Unterminated comment"); return SWIG_TOKEN_ERROR; } if (c == '*') { @@ -562,7 +559,7 @@ static int look(Scanner * s) { break; case 12: /* Still in C style comment */ if ((c = nextchar(s)) == 0) { - Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n"); + set_error(s,s->start_line,"Unterminated comment"); return SWIG_TOKEN_ERROR; } if (c == '*') { @@ -576,7 +573,7 @@ static int look(Scanner * s) { case 2: /* Processing a string */ if ((c = nextchar(s)) == 0) { - Swig_error(cparse_file, cparse_start_line, "Unterminated string\n"); + set_error(s,s->start_line, "Unterminated string"); return SWIG_TOKEN_ERROR; } if (c == '\"') { @@ -659,7 +656,7 @@ static int look(Scanner * s) { case 40: /* Process an include block */ if ((c = nextchar(s)) == 0) { - Swig_error(cparse_file, cparse_start_line, "Unterminated block\n"); + set_error(s,s->start_line,"Unterminated code block"); return SWIG_TOKEN_ERROR; } if (c == '%') @@ -936,7 +933,7 @@ static int look(Scanner * s) { /* A character constant */ case 9: if ((c = nextchar(s)) == 0) { - Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); + set_error(s,s->start_line,"Unterminated character constant"); return SWIG_TOKEN_ERROR; } if (c == '\'') { @@ -1051,7 +1048,7 @@ static int look(Scanner * s) { /* Reverse string */ case 900: if ((c = nextchar(s)) == 0) { - Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n"); + set_error(s,s->start_line,"Unterminated character constant"); return SWIG_TOKEN_ERROR; } if (c == '`') { diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c index 8a7700bec..b6960f4d6 100644 --- a/Source/Swig/stype.c +++ b/Source/Swig/stype.c @@ -270,6 +270,20 @@ int SwigType_issimple(SwigType *t) { return 1; } +int SwigType_isbuiltin(SwigType *t) { + const char* builtins[] = { "void", "short", "int", "long", "char", "float", "double", "bool", 0 }; + int i = 0; + char *c = Char(t); + if (!t) + return 0; + while (builtins[i]) { + if (strcmp(c, builtins[i]) == 0) + return 1; + i++; + } + return 0; +} + /* ----------------------------------------------------------------------------- * SwigType_default() * @@ -537,7 +551,7 @@ String *SwigType_namestr(const SwigType *t) { * Create a C string representation of a datatype. * ----------------------------------------------------------------------------- */ -String *SwigType_str(SwigType *s, const_String_or_char_ptr id) { +String *SwigType_str(SwigType *s, const String_or_char *id) { String *result; String *element = 0, *nextelement; List *elements; @@ -732,7 +746,7 @@ SwigType *SwigType_ltype(SwigType *s) { * with an equivalent assignable version. * -------------------------------------------------------------------- */ -String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) { +String *SwigType_lstr(SwigType *s, const String_or_char *id) { String *result; SwigType *tc; @@ -749,7 +763,7 @@ String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) { * datatype printed by str(). * ----------------------------------------------------------------------------- */ -String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) { +String *SwigType_rcaststr(SwigType *s, const String_or_char *name) { String *result, *cast; String *element = 0, *nextelement; SwigType *td, *rs, *tc = 0; @@ -892,7 +906,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) { * Casts a variable from the real type to the local datatype. * ----------------------------------------------------------------------------- */ -String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) { +String *SwigType_lcaststr(SwigType *s, const String_or_char *name) { String *result; result = NewStringEmpty(); diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h index 2b2c797c9..20bd95e6a 100644 --- a/Source/Swig/swig.h +++ b/Source/Swig/swig.h @@ -110,15 +110,15 @@ extern "C" { extern SwigType *NewSwigType(int typecode); extern SwigType *SwigType_del_element(SwigType *t); extern SwigType *SwigType_add_pointer(SwigType *t); - extern SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr qual); + extern SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *qual); extern SwigType *SwigType_del_memberpointer(SwigType *t); extern SwigType *SwigType_del_pointer(SwigType *t); - extern SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size); + extern SwigType *SwigType_add_array(SwigType *t, const String_or_char *size); extern SwigType *SwigType_del_array(SwigType *t); extern SwigType *SwigType_pop_arrays(SwigType *t); extern SwigType *SwigType_add_reference(SwigType *t); extern SwigType *SwigType_del_reference(SwigType *t); - extern SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual); + extern SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual); extern SwigType *SwigType_del_qualifier(SwigType *t); extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms); extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms); @@ -129,10 +129,10 @@ extern "C" { extern void SwigType_push(SwigType *t, SwigType *s); extern List *SwigType_parmlist(const SwigType *p); extern String *SwigType_parm(String *p); - extern String *SwigType_str(SwigType *s, const_String_or_char_ptr id); - extern String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id); - extern String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr id); - extern String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr id); + extern String *SwigType_str(SwigType *s, const String_or_char *id); + extern String *SwigType_lstr(SwigType *s, const String_or_char *id); + extern String *SwigType_rcaststr(SwigType *s, const String_or_char *id); + extern String *SwigType_lcaststr(SwigType *s, const String_or_char *id); extern String *SwigType_manglestr(SwigType *t); extern SwigType *SwigType_ltype(SwigType *t); extern int SwigType_ispointer(SwigType *t); @@ -151,7 +151,8 @@ extern "C" { extern int SwigType_isvarargs(const SwigType *t); extern int SwigType_istemplate(const SwigType *t); extern int SwigType_isenum(SwigType *t); - extern int SwigType_check_decl(SwigType *t, const_String_or_char_ptr decl); + extern int SwigType_isbuiltin(SwigType *t); + extern int SwigType_check_decl(SwigType *t, const String_or_char *decl); extern SwigType *SwigType_strip_qualifiers(SwigType *t); extern SwigType *SwigType_functionpointer_decompose(SwigType *t); extern String *SwigType_base(const SwigType *t); @@ -162,7 +163,7 @@ extern "C" { extern String *SwigType_prefix(const SwigType *t); extern int SwigType_array_ndim(SwigType *t); extern String *SwigType_array_getdim(SwigType *t, int n); - extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep); + extern void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep); extern SwigType *SwigType_array_type(SwigType *t); extern String *SwigType_default(SwigType *t); extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep); @@ -173,27 +174,27 @@ extern "C" { /* --- Type-system managment --- */ extern void SwigType_typesystem_init(void); - extern int SwigType_typedef(SwigType *type, const_String_or_char_ptr name); - extern int SwigType_typedef_class(const_String_or_char_ptr name); - extern int SwigType_typedef_using(const_String_or_char_ptr qname); + extern int SwigType_typedef(SwigType *type, String_or_char *name); + extern int SwigType_typedef_class(String_or_char *name); + extern int SwigType_typedef_using(String_or_char *qname); extern void SwigType_inherit(String *subclass, String *baseclass, String *cast, String *conversioncode); extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype); extern void SwigType_scope_alias(String *aliasname, Typetab *t); extern void SwigType_using_scope(Typetab *t); - extern void SwigType_new_scope(const_String_or_char_ptr name); + extern void SwigType_new_scope(const String_or_char *name); extern void SwigType_inherit_scope(Typetab *scope); extern Typetab *SwigType_pop_scope(void); extern Typetab *SwigType_set_scope(Typetab *h); extern void SwigType_print_scope(Typetab *t); - extern SwigType *SwigType_typedef_resolve(const SwigType *t); + extern SwigType *SwigType_typedef_resolve(SwigType *t); extern SwigType *SwigType_typedef_resolve_all(SwigType *t); extern SwigType *SwigType_typedef_qualified(SwigType *t); extern int SwigType_istypedef(SwigType *t); extern int SwigType_isclass(SwigType *t); extern void SwigType_attach_symtab(Symtab *syms); extern void SwigType_remember(SwigType *t); - extern void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata); - extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata); + extern void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata); + extern void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata); extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *); extern void SwigType_emit_type_table(File *f_headers, File *f_table); extern int SwigType_type(SwigType *t); @@ -201,25 +202,25 @@ extern "C" { /* --- Symbol table module --- */ extern void Swig_symbol_init(void); - extern void Swig_symbol_setscopename(const_String_or_char_ptr name); + extern void Swig_symbol_setscopename(const String_or_char *name); extern String *Swig_symbol_getscopename(void); extern String *Swig_symbol_qualifiedscopename(Symtab *symtab); extern Symtab *Swig_symbol_newscope(void); extern Symtab *Swig_symbol_setscope(Symtab *); - extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname); + extern Symtab *Swig_symbol_getscope(const String_or_char *symname); extern Symtab *Swig_symbol_current(void); extern Symtab *Swig_symbol_popscope(void); - extern Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *node); - extern void Swig_symbol_cadd(const_String_or_char_ptr symname, Node *node); - extern Node *Swig_symbol_clookup(const_String_or_char_ptr symname, Symtab *tab); - extern Node *Swig_symbol_clookup_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *)); - extern Symtab *Swig_symbol_cscope(const_String_or_char_ptr symname, Symtab *tab); - extern Node *Swig_symbol_clookup_local(const_String_or_char_ptr symname, Symtab *tab); - extern Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *)); + extern Node *Swig_symbol_add(String_or_char *symname, Node *node); + extern void Swig_symbol_cadd(String_or_char *symname, Node *node); + extern Node *Swig_symbol_clookup(String_or_char *symname, Symtab *tab); + extern Node *Swig_symbol_clookup_check(String_or_char *symname, Symtab *tab, int (*check) (Node *)); + extern Symtab *Swig_symbol_cscope(String_or_char *symname, Symtab *tab); + extern Node *Swig_symbol_clookup_local(String_or_char *symname, Symtab *tab); + extern Node *Swig_symbol_clookup_local_check(String_or_char *symname, Symtab *tab, int (*check) (Node *)); extern String *Swig_symbol_qualified(Node *node); extern Node *Swig_symbol_isoverloaded(Node *node); extern void Swig_symbol_remove(Node *node); - extern void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *tab); + extern void Swig_symbol_alias(String_or_char *aliasname, Symtab *tab); extern void Swig_symbol_inherit(Symtab *tab); extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab); extern String *Swig_symbol_string_qualify(String *s, Symtab *tab); @@ -246,17 +247,17 @@ extern int ParmList_is_compactdefargs(ParmList *p); /* --- Naming functions --- */ - extern void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format); - extern void Swig_name_unregister(const_String_or_char_ptr method); - extern String *Swig_name_mangle(const_String_or_char_ptr s); - extern String *Swig_name_wrapper(const_String_or_char_ptr fname); - extern String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname); - extern String *Swig_name_get(const_String_or_char_ptr vname); - extern String *Swig_name_set(const_String_or_char_ptr vname); - extern String *Swig_name_construct(const_String_or_char_ptr classname); - extern String *Swig_name_copyconstructor(const_String_or_char_ptr classname); - extern String *Swig_name_destroy(const_String_or_char_ptr classname); - extern String *Swig_name_disown(const_String_or_char_ptr classname); + extern void Swig_name_register(const String_or_char *method, const String_or_char *format); + extern void Swig_name_unregister(const String_or_char *method); + extern String *Swig_name_mangle(const String_or_char *s); + extern String *Swig_name_wrapper(const String_or_char *fname); + extern String *Swig_name_member(const String_or_char *classname, const String_or_char *mname); + extern String *Swig_name_get(const String_or_char *vname); + extern String *Swig_name_set(const String_or_char *vname); + extern String *Swig_name_construct(const String_or_char *classname); + extern String *Swig_name_copyconstructor(const String_or_char *classname); + extern String *Swig_name_destroy(const String_or_char *classname); + extern String *Swig_name_disown(const String_or_char *classname); extern void Swig_naming_init(void); extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn); @@ -267,36 +268,33 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern int Swig_need_name_warning(Node *n); extern int Swig_need_redefined_warn(Node *a, Node *b, int InClass); - extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname); + extern String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname); extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl); extern String *Swig_name_decl(Node *n); extern String *Swig_name_fulldecl(Node *n); /* --- parameterized rename functions --- */ - extern void Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object); - extern DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *decl); + extern void Swig_name_object_set(Hash *namehash, String_or_char *name, SwigType *decl, DOH *object); + extern DOH *Swig_name_object_get(Hash *namehash, String_or_char *prefix, String_or_char *name, SwigType *decl); extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived); - extern void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl, Node *n); - extern void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, String *value, Hash *featureattribs); + extern void Swig_features_get(Hash *features, String_or_char *prefix, String_or_char *name, SwigType *decl, Node *n); + extern void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs); /* --- Misc --- */ extern char *Swig_copy_string(const char *c); extern void Swig_set_fakeversion(const char *version); extern const char *Swig_package_version(void); extern void Swig_banner(File *f); - extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar); extern String *Swig_strip_c_comments(const String *s); - extern String *Swig_filename_escape(String *filename); - extern void Swig_filename_correct(String *filename); extern String *Swig_string_escape(String *s); extern String *Swig_string_mangle(const String *s); - extern void Swig_scopename_split(const String *s, String **prefix, String **last); - extern String *Swig_scopename_prefix(const String *s); - extern String *Swig_scopename_last(const String *s); - extern String *Swig_scopename_first(const String *s); - extern String *Swig_scopename_suffix(const String *s); - extern int Swig_scopename_check(const String *s); + extern void Swig_scopename_split(String *s, String **prefix, String **last); + extern String *Swig_scopename_prefix(String *s); + extern String *Swig_scopename_last(String *s); + extern String *Swig_scopename_first(String *s); + extern String *Swig_scopename_suffix(String *s); + extern int Swig_scopename_check(String *s); extern String *Swig_string_lower(String *s); extern String *Swig_string_upper(String *s); extern String *Swig_string_title(String *s); @@ -311,11 +309,11 @@ extern int ParmList_is_compactdefargs(ParmList *p); typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat; - extern void Swig_warning(int num, const_String_or_char_ptr filename, int line, const char *fmt, ...); - extern void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...); + extern void Swig_warning(int num, const String_or_char *filename, int line, const char *fmt, ...); + extern void Swig_error(const String_or_char *filename, int line, const char *fmt, ...); extern int Swig_error_count(void); extern void Swig_error_silent(int s); - extern void Swig_warnfilter(const_String_or_char_ptr wlist, int val); + extern void Swig_warnfilter(const String_or_char *wlist, int val); extern void Swig_warnall(void); extern int Swig_warn_count(void); extern void Swig_error_msg_format(ErrorMessageFormat format); @@ -324,17 +322,17 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern String *Swig_cparm_name(Parm *p, int i); extern String *Swig_wrapped_var_type(SwigType *t, int varcref); extern int Swig_cargs(Wrapper *w, ParmList *l); - extern String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl); + extern String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl); - extern String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms); - extern String *Swig_cconstructor_call(const_String_or_char_ptr name); - extern String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms); + extern String *Swig_cfunction_call(String_or_char *name, ParmList *parms); + extern String *Swig_cconstructor_call(String_or_char *name); + extern String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms); extern String *Swig_unref_call(Node *n); extern String *Swig_ref_call(Node *n, const String *lname); extern String *Swig_cdestructor_call(Node *n); extern String *Swig_cppdestructor_call(Node *n); - extern String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref); - extern String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref); + extern String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref); + extern String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref); extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self); @@ -343,7 +341,7 @@ extern int ParmList_is_compactdefargs(ParmList *p); extern int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director); extern int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags); extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags); - extern int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call); + extern int Swig_MembersetToFunction(Node *n, String *classname, int flags); extern int Swig_MembergetToFunction(Node *n, String *classname, int flags); extern int Swig_VargetToFunction(Node *n, int flags); extern int Swig_VarsetToFunction(Node *n, int flags); @@ -363,22 +361,22 @@ extern int ParmList_is_compactdefargs(ParmList *p); /* --- Legacy Typemap API (somewhat simplified, ha!) --- */ extern void Swig_typemap_init(void); - extern void Swig_typemap_register(const_String_or_char_ptr op, ParmList *pattern, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs); - extern int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcpattern, ParmList *pattern); - extern void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *pattern); + extern void Swig_typemap_register(const String_or_char *op, ParmList *pattern, String_or_char *code, ParmList *locals, ParmList *kwargs); + extern int Swig_typemap_copy(const String_or_char *op, ParmList *srcpattern, ParmList *pattern); + extern void Swig_typemap_clear(const String_or_char *op, ParmList *pattern); extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat); extern void Swig_typemap_clear_apply(ParmList *pattern); extern void Swig_typemap_debug(void); - extern Hash *Swig_typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr pname, SwigType **matchtype); - extern Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch); - extern String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f); - extern String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode); - extern void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p); + extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *pname, SwigType **matchtype); + extern Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch); + extern String *Swig_typemap_lookup(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f); + extern String *Swig_typemap_lookup_out(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f, String *actioncode); + extern void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p); extern void Swig_typemap_new_scope(void); extern Hash *Swig_typemap_pop_scope(void); - extern void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f); + extern void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f); /* --- Code fragment support --- */ diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h index 92c7945e6..c945fb1ac 100644 --- a/Source/Swig/swigfile.h +++ b/Source/Swig/swigfile.h @@ -9,25 +9,24 @@ /* $Id: swig.h 9603 2006-12-05 21:47:01Z beazley $ */ -extern List *Swig_add_directory(const_String_or_char_ptr dirname); -extern void Swig_push_directory(const_String_or_char_ptr dirname); -extern void Swig_pop_directory(void); -extern String *Swig_last_file(void); -extern List *Swig_search_path(void); -extern FILE *Swig_include_open(const_String_or_char_ptr name); -extern FILE *Swig_open(const_String_or_char_ptr name); +extern List *Swig_add_directory(const String_or_char *dirname); +extern void Swig_push_directory(const String_or_char *dirname); +extern void Swig_pop_directory(); +extern String *Swig_last_file(); +extern List *Swig_search_path(); +extern FILE *Swig_open(const String_or_char *name); extern String *Swig_read_file(FILE *f); -extern String *Swig_include(const_String_or_char_ptr name); -extern String *Swig_include_sys(const_String_or_char_ptr name); -extern int Swig_insert_file(const_String_or_char_ptr name, File *outfile); +extern String *Swig_include(const String_or_char *name); +extern String *Swig_include_sys(const String_or_char *name); +extern int Swig_insert_file(const String_or_char *name, File *outfile); extern void Swig_set_push_dir(int dopush); extern int Swig_get_push_dir(void); -extern void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile); -extern File *Swig_filebyname(const_String_or_char_ptr filename); -extern char *Swig_file_suffix(const_String_or_char_ptr filename); -extern char *Swig_file_basename(const_String_or_char_ptr filename); -extern char *Swig_file_filename(const_String_or_char_ptr filename); -extern char *Swig_file_dirname(const_String_or_char_ptr filename); +extern void Swig_register_filebyname(const String_or_char *filename, File *outfile); +extern File *Swig_filebyname(const String_or_char *filename); +extern char *Swig_file_suffix(const String_or_char *filename); +extern char *Swig_file_basename(const String_or_char *filename); +extern char *Swig_file_filename(const String_or_char *filename); +extern char *Swig_file_dirname(const String_or_char *filename); /* Delimiter used in accessing files and directories */ diff --git a/Source/Swig/swigopt.h b/Source/Swig/swigopt.h index 11eb5ba99..428d90dce 100644 --- a/Source/Swig/swigopt.h +++ b/Source/Swig/swigopt.h @@ -13,4 +13,4 @@ extern void Swig_mark_arg(int n); extern int Swig_check_marked(int n); extern void Swig_check_options(int check_input); - extern void Swig_arg_error(void); + extern void Swig_arg_error(); diff --git a/Source/Swig/swigparm.h b/Source/Swig/swigparm.h index 49ae7992e..529438bae 100644 --- a/Source/Swig/swigparm.h +++ b/Source/Swig/swigparm.h @@ -11,7 +11,7 @@ /* $Id: swig.h 9629 2006-12-30 18:27:47Z beazley $ */ /* Individual parameters */ -extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name); +extern Parm *NewParm(SwigType *type, const String_or_char *name); extern Parm *CopyParm(Parm *p); /* Parameter lists */ diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h index 3403098df..2486286a9 100644 --- a/Source/Swig/swigscan.h +++ b/Source/Swig/swigscan.h @@ -11,11 +11,11 @@ typedef struct Scanner Scanner; -extern Scanner *NewScanner(void); +extern Scanner *NewScanner(); extern void DelScanner(Scanner *); extern void Scanner_clear(Scanner *); extern void Scanner_push(Scanner *, String *); -extern void Scanner_pushtoken(Scanner *, int, const_String_or_char_ptr value); +extern void Scanner_pushtoken(Scanner *, int, const String_or_char *value); extern int Scanner_token(Scanner *); extern String *Scanner_text(Scanner *); extern void Scanner_skip_line(Scanner *); diff --git a/Source/Swig/swigtree.h b/Source/Swig/swigtree.h index 5b43006a9..2e5c4da36 100644 --- a/Source/Swig/swigtree.h +++ b/Source/Swig/swigtree.h @@ -31,7 +31,7 @@ /* Utility functions */ -extern int checkAttribute(Node *obj, const_String_or_char_ptr name, const_String_or_char_ptr value); +extern int checkAttribute(Node *obj, const String_or_char *name, const String_or_char *value); extern void appendChild(Node *node, Node *child); extern void prependChild(Node *node, Node *child); extern void removeNode(Node *node); diff --git a/Source/Swig/swigwrap.h b/Source/Swig/swigwrap.h index 0dcf88059..25eeb6f7f 100644 --- a/Source/Swig/swigwrap.h +++ b/Source/Swig/swigwrap.h @@ -16,14 +16,14 @@ typedef struct Wrapper { String *code; } Wrapper; -extern Wrapper *NewWrapper(void); +extern Wrapper *NewWrapper(); extern void DelWrapper(Wrapper *w); extern void Wrapper_compact_print_mode_set(int flag); extern void Wrapper_pretty_print(String *str, File *f); extern void Wrapper_compact_print(String *str, File *f); extern void Wrapper_print(Wrapper *w, File *f); -extern int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl); -extern int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...); -extern int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name); -extern char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl); -extern char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...); +extern int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl); +extern int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...); +extern int Wrapper_check_local(Wrapper *w, const String_or_char *name); +extern char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl); +extern char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...); diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c index 055af854f..c9691fa54 100644 --- a/Source/Swig/symbol.c +++ b/Source/Swig/symbol.c @@ -220,7 +220,7 @@ void Swig_symbol_init() { * Set the C scopename of the current symbol table. * ----------------------------------------------------------------------------- */ -void Swig_symbol_setscopename(const_String_or_char_ptr name) { +void Swig_symbol_setscopename(const String_or_char *name) { String *qname; /* assert(!Getattr(current_symtab,"name")); */ Setattr(current_symtab, "name", name); @@ -250,10 +250,10 @@ String *Swig_symbol_getscopename() { * Given a fully qualified C scopename, this function returns a symbol table * ----------------------------------------------------------------------------- */ -Symtab *Swig_symbol_getscope(const_String_or_char_ptr name) { +Symtab *Swig_symbol_getscope(const String_or_char *name) { if (!symtabs) return 0; - if (Equal("::", (const_String_or_char_ptr ) name)) + if (Equal("::", (String_or_char *) name)) name = ""; return Getattr(symtabs, name); } @@ -373,7 +373,7 @@ Symtab *Swig_symbol_current() { * Makes an alias for a symbol in the global symbol table. * ----------------------------------------------------------------------------- */ -void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *s) { +void Swig_symbol_alias(String_or_char *aliasname, Symtab *s) { String *qname = Swig_symbol_qualifiedscopename(current_symtab); if (qname) { Printf(qname, "::%s", aliasname); @@ -421,7 +421,7 @@ void Swig_symbol_inherit(Symtab *s) { * Adds a node to the C symbol table only. * ----------------------------------------------------------------------------- */ -void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) { +void Swig_symbol_cadd(String_or_char *name, Node *n) { Node *append = 0; Node *cn; @@ -594,7 +594,7 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) { * for namespace support, type resolution, and other issues. * ----------------------------------------------------------------------------- */ -Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *n) { +Node *Swig_symbol_add(String_or_char *symname, Node *n) { Hash *c, *cn, *cl = 0; SwigType *decl, *ndecl; String *cstorage, *nstorage; @@ -827,7 +827,7 @@ Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *n) { * verifying that a class hierarchy implements all pure virtual methods. * ----------------------------------------------------------------------------- */ -static Node *_symbol_lookup(const String *name, Symtab *symtab, int (*check) (Node *n)) { +static Node *_symbol_lookup(String *name, Symtab *symtab, int (*check) (Node *n)) { Node *n; List *inherit; Hash *sym = Getattr(symtab, "csymtab"); @@ -890,7 +890,7 @@ static Node *_symbol_lookup(const String *name, Symtab *symtab, int (*check) (No return 0; } -static Node *symbol_lookup(const_String_or_char_ptr name, Symtab *symtab, int (*check) (Node *n)) { +static Node *symbol_lookup(String_or_char *name, Symtab *symtab, int (*check) (Node *n)) { Node *n = 0; if (DohCheck(name)) { n = _symbol_lookup(name, symtab, check); @@ -908,7 +908,7 @@ static Node *symbol_lookup(const_String_or_char_ptr name, Symtab *symtab, int (* * symbol_lookup_qualified() * ----------------------------------------------------------------------------- */ -static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symtab, const String *prefix, int local, int (*checkfunc) (Node *n)) { +static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, String *prefix, int local, int (*checkfunc) (Node *n)) { /* This is a little funky, we search by fully qualified names */ if (!symtab) @@ -928,7 +928,6 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt /* Make qualified name of current scope */ String *qalloc = 0; String *qname = Swig_symbol_qualifiedscopename(symtab); - const String *cqname; if (qname) { if (Len(qname)) { if (prefix && Len(prefix)) { @@ -938,11 +937,10 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt Append(qname, prefix); } qalloc = qname; - cqname = qname; } else { - cqname = prefix; + qname = prefix; } - st = Getattr(symtabs, cqname); + st = Getattr(symtabs, qname); /* Found a scope match */ if (st) { if (!name) { @@ -976,7 +974,7 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt * to get the real node. * ----------------------------------------------------------------------------- */ -Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) { +Node *Swig_symbol_clookup(String_or_char *name, Symtab *n) { Hash *hsym = 0; Node *s = 0; @@ -1048,7 +1046,7 @@ Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) { * inheritance hierarchy. * ----------------------------------------------------------------------------- */ -Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *n)) { +Node *Swig_symbol_clookup_check(String_or_char *name, Symtab *n, int (*checkfunc) (Node *n)) { Hash *hsym = 0; Node *s = 0; @@ -1112,7 +1110,7 @@ Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (* * Swig_symbol_clookup_local() * ----------------------------------------------------------------------------- */ -Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) { +Node *Swig_symbol_clookup_local(String_or_char *name, Symtab *n) { Hash *h, *hsym; Node *s = 0; @@ -1160,7 +1158,7 @@ Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) { * Swig_symbol_clookup_local_check() * ----------------------------------------------------------------------------- */ -Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *)) { +Node *Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*checkfunc) (Node *)) { Hash *h, *hsym; Node *s = 0; @@ -1211,7 +1209,7 @@ Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, * Look up a scope name. * ----------------------------------------------------------------------------- */ -Symtab *Swig_symbol_cscope(const_String_or_char_ptr name, Symtab *symtab) { +Symtab *Swig_symbol_cscope(String_or_char *name, Symtab *symtab) { char *cname = Char(name); if (strncmp(cname, "::", 2) == 0) return symbol_lookup_qualified(0, global_scope, name, 0, 0); diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c index 14d231afa..61dca8353 100644 --- a/Source/Swig/tree.c +++ b/Source/Swig/tree.c @@ -229,7 +229,7 @@ Node *copyNode(Node *n) { * checkAttribute() * ----------------------------------------------------------------------------- */ -int checkAttribute(Node *n, const_String_or_char_ptr name, const_String_or_char_ptr value) { +int checkAttribute(Node *n, const String_or_char *name, const String_or_char *value) { String *v = Getattr(n, name); return v ? Equal(v, value) : 0; } diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c index 401a99801..6cbeb67ea 100644 --- a/Source/Swig/typemap.c +++ b/Source/Swig/typemap.c @@ -107,7 +107,7 @@ void Swig_typemap_init() { tm_scope = 0; } -static String *tmop_name(const_String_or_char_ptr op) { +static String *tmop_name(const String_or_char *op) { static Hash *names = 0; String *s; /* Due to "interesting" object-identity semantics of DOH, @@ -164,7 +164,7 @@ Hash *Swig_typemap_pop_scope() { * Add a new multi-valued typemap * ----------------------------------------------------------------------------- */ -void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) { +void Swig_typemap_register(const String_or_char *op, ParmList *parms, String_or_char *code, ParmList *locals, ParmList *kwargs) { Hash *tm; Hash *tm1; Hash *tm2; @@ -270,7 +270,7 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S * Retrieve typemap information from current scope. * ----------------------------------------------------------------------------- */ -static Hash *Swig_typemap_get(SwigType *type, const_String_or_char_ptr name, int scope) { +static Hash *Swig_typemap_get(SwigType *type, String_or_char *name, int scope) { Hash *tm, *tm1; /* See if this type has been seen before */ if ((scope < 0) || (scope > tm_scope)) @@ -292,7 +292,7 @@ static Hash *Swig_typemap_get(SwigType *type, const_String_or_char_ptr name, int * Copy a typemap * ----------------------------------------------------------------------------- */ -int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList *parms) { +int Swig_typemap_copy(const String_or_char *op, ParmList *srcparms, ParmList *parms) { Hash *tm = 0; String *tmop; Parm *p; @@ -347,7 +347,7 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList * Delete a multi-valued typemap * ----------------------------------------------------------------------------- */ -void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) { +void Swig_typemap_clear(const String_or_char *op, ParmList *parms) { SwigType *type; String *name; Parm *p; @@ -590,7 +590,7 @@ static SwigType *strip_arrays(SwigType *type) { * that includes a 'code' attribute. * ----------------------------------------------------------------------------- */ -Hash *Swig_typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) { +Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *name, SwigType **matchtype) { Hash *result = 0, *tm, *tm1, *tma; Hash *backup = 0; SwigType *noarrays = 0; @@ -737,7 +737,7 @@ ret_result: * Search for a multi-valued typemap. * ----------------------------------------------------------------------------- */ -Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) { +Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch) { SwigType *type; SwigType *mtype = 0; String *name; @@ -1173,7 +1173,7 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) { * $1 in the out typemap will be replaced by the code in actioncode. * ----------------------------------------------------------------------------- */ -static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) { +static String *Swig_typemap_lookup_impl(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f, String *actioncode) { SwigType *type; SwigType *mtype = 0; String *pname; @@ -1384,13 +1384,13 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, return s; } -String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) { +String *Swig_typemap_lookup_out(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f, String *actioncode) { assert(actioncode); assert(Cmp(op, "out") == 0); return Swig_typemap_lookup_impl(op, node, lname, f, actioncode); } -String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f) { +String *Swig_typemap_lookup(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f) { return Swig_typemap_lookup_impl(op, node, lname, f, 0); } @@ -1406,7 +1406,7 @@ String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_Strin * A new attribute called "tmap:in:foo" with value "xyz" is attached to p. * ----------------------------------------------------------------------------- */ -void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) { +void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p) { String *temp = NewStringEmpty(); Parm *kw = Getattr(tm, "kwargs"); while (kw) { @@ -1438,7 +1438,7 @@ void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) * attribute, print that warning message. * ----------------------------------------------------------------------------- */ -static void Swig_typemap_warn(const_String_or_char_ptr op, Parm *p) { +static void Swig_typemap_warn(const String_or_char *op, Parm *p) { String *temp = NewStringf("%s:warning", op); String *w = Getattr(p, tmop_name(temp)); Delete(temp); @@ -1447,7 +1447,7 @@ static void Swig_typemap_warn(const_String_or_char_ptr op, Parm *p) { } } -static void Swig_typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) { +static void Swig_typemap_emit_code_fragments(const String_or_char *op, Parm *p) { String *temp = NewStringf("%s:fragment", op); String *f = Getattr(p, tmop_name(temp)); if (f) { @@ -1467,7 +1467,7 @@ static void Swig_typemap_emit_code_fragments(const_String_or_char_ptr op, Parm * * given typemap type * ----------------------------------------------------------------------------- */ -String *Swig_typemap_get_option(Hash *tm, const_String_or_char_ptr name) { +String *Swig_typemap_get_option(Hash *tm, String *name) { Parm *kw = Getattr(tm, "kwargs"); while (kw) { String *kname = Getattr(kw, "name"); @@ -1479,7 +1479,7 @@ String *Swig_typemap_get_option(Hash *tm, const_String_or_char_ptr name) { return 0; } -void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f) { +void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f) { Parm *p, *firstp; Hash *tm; int nmatch = 0; diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c index 8ff31bc0b..18d1b2304 100644 --- a/Source/Swig/typeobj.c +++ b/Source/Swig/typeobj.c @@ -110,7 +110,7 @@ char cvsroot_typeobj_c[] = "$Id$"; * ----------------------------------------------------------------------------- */ #ifdef NEW -SwigType *NewSwigType(const_String_or_char_ptr initial) { +SwigType *NewSwigType(const String_or_char *initial) { return NewString(initial); } @@ -419,7 +419,7 @@ int SwigType_isreference(SwigType *t) { * stored in exactly the same way as "q(const volatile)". * ----------------------------------------------------------------------------- */ -SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) { +SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual) { char temp[256], newq[256]; int sz, added = 0; char *q, *cqual; @@ -537,7 +537,7 @@ SwigType *SwigType_functionpointer_decompose(SwigType *t) { * Add, remove, and test for C++ pointer to members. * ----------------------------------------------------------------------------- */ -SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr name) { +SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *name) { String *temp = NewStringf("m(%s).", name); Insert(t, 0, temp); Delete(temp); @@ -579,7 +579,7 @@ int SwigType_ismemberpointer(SwigType *t) { * SwigType_pop_arrays() - Remove all arrays * ----------------------------------------------------------------------------- */ -SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) { +SwigType *SwigType_add_array(SwigType *t, const String_or_char *size) { char temp[512]; strcpy(temp, "a("); strcat(temp, Char(size)); @@ -673,7 +673,7 @@ String *SwigType_array_getdim(SwigType *t, int n) { } /* Replace nth array dimension */ -void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) { +void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep) { String *result = 0; char temp; char *start; diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c index 2562e12f8..ae6ab3dc8 100644 --- a/Source/Swig/typesys.c +++ b/Source/Swig/typesys.c @@ -163,7 +163,7 @@ void SwigType_typesystem_init() { * already defined. * ----------------------------------------------------------------------------- */ -int SwigType_typedef(SwigType *type, const_String_or_char_ptr name) { +int SwigType_typedef(SwigType *type, String_or_char *name) { if (Getattr(current_typetab, name)) return -1; /* Already defined */ if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */ @@ -193,7 +193,7 @@ int SwigType_typedef(SwigType *type, const_String_or_char_ptr name) { * Defines a class in the current scope. * ----------------------------------------------------------------------------- */ -int SwigType_typedef_class(const_String_or_char_ptr name) { +int SwigType_typedef_class(String_or_char *name) { String *cname; /* Printf(stdout,"class : '%s'\n", name); */ if (Getattr(current_typetab, name)) @@ -232,7 +232,7 @@ String *SwigType_scope_name(Typetab *ttab) { * Creates a new scope * ----------------------------------------------------------------------------- */ -void SwigType_new_scope(const_String_or_char_ptr name) { +void SwigType_new_scope(const String_or_char *name) { Typetab *s; Hash *ttab; String *qname; @@ -539,7 +539,7 @@ static SwigType *typedef_resolve(Typetab *s, String *base) { * ----------------------------------------------------------------------------- */ /* #define SWIG_DEBUG */ -SwigType *SwigType_typedef_resolve(const SwigType *t) { +SwigType *SwigType_typedef_resolve(SwigType *t) { String *base; String *type = 0; String *r = 0; @@ -840,7 +840,6 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) { * * Given a type declaration, this function tries to fully qualify it according to * typedef scope rules. - * Inconsistency to be fixed: ::Foo returns ::Foo, whereas ::Foo * returns Foo * * ----------------------------------------------------------------------------- */ SwigType *SwigType_typedef_qualified(SwigType *t) { @@ -848,7 +847,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) { String *result; int i, len; - if (strncmp(Char(t), "::", 2) == 0) { + if (t && strncmp(Char(t), "::", 2) == 0) { return Copy(t); } @@ -1072,7 +1071,7 @@ int SwigType_istypedef(SwigType *t) { * Name is a qualified name like A::B. * ----------------------------------------------------------------------------- */ -int SwigType_typedef_using(const_String_or_char_ptr name) { +int SwigType_typedef_using(String_or_char *name) { String *base; String *td; String *prefix; @@ -1416,7 +1415,7 @@ static Hash *r_remembered = 0; /* Hash of types we remembered already */ static void (*r_tracefunc) (SwigType *t, String *mangled, String *clientdata) = 0; -void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata) { +void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata) { if (!r_mangleddata) { r_mangleddata = NewHash(); } @@ -1424,7 +1423,7 @@ void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr cli } -void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata) { +void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata) { String *mt; SwigType *lt; Hash *h; diff --git a/Source/Swig/wrapfunc.c b/Source/Swig/wrapfunc.c index 11518bfc2..3778066ce 100644 --- a/Source/Swig/wrapfunc.c +++ b/Source/Swig/wrapfunc.c @@ -23,7 +23,7 @@ static int Max_line_size = 128; * Create a new wrapper function object. * ----------------------------------------------------------------------------- */ -Wrapper *NewWrapper(void) { +Wrapper *NewWrapper() { Wrapper *w; w = (Wrapper *) malloc(sizeof(Wrapper)); w->localh = NewHash(); @@ -406,7 +406,7 @@ void Wrapper_print(Wrapper *w, File *f) { * present (which may or may not be okay to the caller). * ----------------------------------------------------------------------------- */ -int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) { +int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) { /* See if the local has already been declared */ if (Getattr(w->localh, name)) { return -1; @@ -424,7 +424,7 @@ int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or * to manually construct the 'decl' string before calling. * ----------------------------------------------------------------------------- */ -int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...) { +int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) { va_list ap; int ret; String *decl; @@ -451,7 +451,7 @@ int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...) { * Check to see if a local name has already been declared * ----------------------------------------------------------------------------- */ -int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name) { +int Wrapper_check_local(Wrapper *w, const String_or_char *name) { if (Getattr(w->localh, name)) { return 1; } @@ -465,7 +465,7 @@ int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name) { * used. Returns the name that was actually selected. * ----------------------------------------------------------------------------- */ -char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) { +char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) { int i; String *nname = NewString(name); String *ndecl = NewString(decl); @@ -496,7 +496,7 @@ char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_ * to manually construct the 'decl' string before calling. * ----------------------------------------------------------------------------- */ -char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...) { +char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...) { va_list ap; char *ret; String *decl; diff --git a/TODO b/TODO index 879e65f1f..103185d23 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ SWIG TO-DO +Release: SWIG-1.3.36 + ----------------------------------------------------------------------------- **** = High Priority @@ -337,14 +339,6 @@ Common Lisp typemaps would be written as Lisp programs that generate Lisp code. -ALLEGROCL ------ -These first three will remove most of the warnings from most of the -remaining checkpartial tests that are failing. -**** Throws typemap support -**** const typemaps -**** long long typemaps - Ocaml ----- ** I've been working with my camlp4 module and type information diff --git a/Tools/config/config.guess b/Tools/config/config.guess new file mode 100755 index 000000000..7b24a8728 --- /dev/null +++ b/Tools/config/config.guess @@ -0,0 +1,1542 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# Free Software Foundation, Inc. + +timestamp='2008-11-15' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if echo '\n#ifdef __amd64\nIS_64BIT_ARCH\n#endif' | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[456]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:[3456]*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T | authenticamd | genuineintel) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-gnu + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-gnu + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/Tools/config/config.sub b/Tools/config/config.sub new file mode 100755 index 000000000..053e7381f --- /dev/null +++ b/Tools/config/config.sub @@ -0,0 +1,1677 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# Free Software Foundation, Inc. + +timestamp='2008-09-08' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | score \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tile*) + basic_machine=tile-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/Tools/mkdist.py b/Tools/mkdist.py index 0e2eafa79..f5bdd01c7 100755 --- a/Tools/mkdist.py +++ b/Tools/mkdist.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/local/bin/python # This script builds a swig-1.3 distribution. # Usage : mkdist.py version, where version should be 1.3.x @@ -43,6 +43,11 @@ os.system("svn export -r HEAD https://swig.svn.sourceforge.net/svnroot/swig/trun os.system("rm -Rf "+dirname+"/debian") == 0 or failed() +# Blow away all .cvsignore files + +print "Blowing away .cvsignore files" +os.system("find "+dirname+" -name .cvsignore -exec rm {} \\;") == 0 or failed() + # Go build the system print "Building system" @@ -56,8 +61,7 @@ os.system("find "+dirname+" -name autom4te.cache -exec rm -rf {} \\;") # Build documentation print "Building documentation" -os.system("cd "+dirname+"/Doc/Manual && make all clean-baks") == 0 or failed() -os.system("cd "+dirname+"/CCache && yodl2man -o ccache-swig.1 ccache.yo") == 0 or failed() +os.system("cd "+dirname+"/Doc/Manual && make && rm *.bak") == 0 or failed() # Build the tar-ball os.system("tar -cf "+dirname+".tar "+dirname) == 0 or failed() diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py index edf3b07fe..d7927f8e6 100755 --- a/Tools/mkrelease.py +++ b/Tools/mkrelease.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/python # This script builds the SWIG source tarball, creates the Windows executable and the Windows zip package # and uploads them both to SF ready for release diff --git a/Tools/mkwindows.sh b/Tools/mkwindows.sh index fb2547e14..116e32d11 100755 --- a/Tools/mkwindows.sh +++ b/Tools/mkwindows.sh @@ -82,13 +82,10 @@ if test -f "$tarball"; then echo "Compiling (quietly)..." make > build.log echo "Simple check to see if swig.exe runs..." - env LD_LIBRARY_PATH= PATH= ./swig.exe -version || exit 1 - echo "Simple check to see if ccache-swig.exe runs..." - env LD_LIBRARY_PATH= PATH= ./CCache/ccache-swig.exe -V || exit 1 + env LD_LIBRARY_PATH= PATH= ./swig.exe -version echo "Creating $swigwinbasename.zip..." cd .. cp $swigbasename/swig.exe $swigwinbasename - cp $swigbasename/CCache/ccache-swig.exe $swigwinbasename/CCache cp $swigbasename/Lib/swigwarn.swg $swigwinbasename/Lib sleep 2 # fix strange not finding swig.exe echo "Unzip into a directory of your choice. Please read the README file as well as Doc\Manual\Windows.html for installation instructions." > swig_windows_zip_comments.txt diff --git a/Tools/pyname_patch.py b/Tools/pyname_patch.py deleted file mode 100644 index 5931269f9..000000000 --- a/Tools/pyname_patch.py +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env python -""" -From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py, -since they are inappropriate and discouraged in Python documentation -(from http://www.python.org/doc/2.5.2/api/includes.html): - -"All user visible names defined by Python.h (except those defined by the included -standard headers) have one of the prefixes "Py" or "_Py". Names beginning with -"_Py" are for internal use by the Python implementation and should not be used -by extension writers. Structure member names do not have a reserved prefix. - -Important: user code should never define names that begin with "Py" or "_Py". -This confuses the reader, and jeopardizes the portability of the user code to -future Python versions, which may define additional names beginning with one -of these prefixes." - -This file is a simple script used for change all of these symbols, for user code -or SWIG itself. -""" -import re -from shutil import copyfile -import sys - -symbols = [ - #(old name, new name) - ("PySequence_Base", "SwigPySequence_Base"), - ("PySequence_Cont", "SwigPySequence_Cont"), - ("PySwigIterator_T", "SwigPyIterator_T"), - ("PyPairBoolOutputIterator", "SwigPyPairBoolOutputIterator"), - ("PySwigIterator", "SwigPyIterator"), - ("PySwigIterator_T", "SwigPyIterator_T"), - ("PyMapIterator_T", "SwigPyMapIterator_T"), - ("PyMapKeyIterator_T", "SwigPyMapKeyIterator_T"), - ("PyMapValueIterator_T", "SwigPyMapValueITerator_T"), - ("PyObject_ptr", "SwigPtr_PyObject"), - ("PyObject_var", "SwigVar_PyObject"), - ("PyOper", "SwigPyOper"), - ("PySeq", "SwigPySeq"), - ("PySequence_ArrowProxy", "SwigPySequence_ArrowProxy"), - ("PySequence_Cont", "SwigPySequence_Cont"), - ("PySequence_InputIterator", "SwigPySequence_InputIterator"), - ("PySequence_Ref", "SwigPySequence_Ref"), - ("PySwigClientData", "SwigPyClientData"), - ("PySwigClientData_Del", "SwigPyClientData_Del"), - ("PySwigClientData_New", "SwigPyClientData_New"), - ("PySwigIterator", "SwigPyIterator"), - ("PySwigIteratorClosed_T", "SwigPyIteratorClosed_T"), - ("PySwigIteratorOpen_T", "SwigPyIteratorOpen_T"), - ("PySwigIterator_T", "SwigPyIterator_T"), - ("PySwigObject", "SwigPyObject"), - ("PySwigObject_Check", "SwigPyObject_Check"), - ("PySwigObject_GetDesc", "SwigPyObject_GetDesc"), - ("PySwigObject_New", "SwigPyObject_New"), - ("PySwigObject_acquire", "SwigPyObject_acquire"), - ("PySwigObject_append", "SwigPyObject_append"), - ("PySwigObject_as_number", "SwigPyObject_as_number"), - ("PySwigObject_compare", "SwigPyObject_compare"), - ("PySwigObject_dealloc", "SwigPyObject_dealloc"), - ("PySwigObject_disown", "SwigPyObject_disown"), - ("PySwigObject_format", "SwigPyObject_format"), - ("PySwigObject_getattr", "SwigPyObject_getattr"), - ("PySwigObject_hex", "SwigPyObject_hex"), - ("PySwigObject_long", "SwigPyObject_long"), - ("PySwigObject_next", "SwigPyObject_next"), - ("PySwigObject_oct", "SwigPyObject_oct"), - ("PySwigObject_own", "SwigPyObject_own"), - ("PySwigObject_print", "SwigPyObject_print"), - ("PySwigObject_repr", "SwigPyObject_repr"), - ("PySwigObject_richcompare", "SwigPyObject_richcompare"), - ("PySwigObject_str", "SwigPyObject_str"), - ("PySwigObject_type", "SwigPyObject_type"), - ("PySwigPacked", "SwigPyPacked"), - ("PySwigPacked_Check", "SwigPyPacked_Check"), - ("PySwigPacked_New", "SwigPyPacked_New"), - ("PySwigPacked_UnpackData", "SwigPyPacked_UnpackData"), - ("PySwigPacked_compare", "SwigPyPacked_compare"), - ("PySwigPacked_dealloc", "SwigPyPacked_dealloc"), - ("PySwigPacked_print", "SwigPyPacked_print"), - ("PySwigPacked_repr", "SwigPyPacked_repr"), - ("PySwigPacked_str", "SwigPyPacked_str"), - ("PySwigPacked_type", "SwigPyPacked_type"), - ("pyseq", "swigpyseq"), - ("pyswigobject_type", "swigpyobject_type"), - ("pyswigpacked_type", "swigpypacked_type"), - ] - -res = [(re.compile("\\b(%s)\\b"%oldname), newname) for oldname, newname in symbols] - -def patch_file(fn): - newf = [] - changed = False - for line in open(fn): - for r, newname in res: - line, n = r.subn(newname, line) - if n>0: - changed = True - newf.append(line) - - if changed: - copyfile(fn, fn+".bak") - f = open(fn, "w") - f.write("".join(newf)) - f.close() - return changed - -def main(fns): - for fn in fns: - try: - if patch_file(fn): - print "Patched file", fn - except IOError: - print "Error occured during patching", fn - return - -if __name__=="__main__": - if len(sys.argv) > 1: - main(sys.argv[1:]) - else: - print "Patch your interface file for SWIG's Py* symbol name deprecation." - print "Usage:" - print " %s files..."%sys.argv[0] - - diff --git a/autogen.sh b/autogen.sh index 97916d9f3..33f54aa7c 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,8 +2,9 @@ # Bootstrap the development environment - add extra files needed to run configure. # Note autoreconf should do what this file achieves, but it has a bug when working with automake! -# The latest config.guess and config.sub should be copied into Tools/config. -# This script will ensure the latest is copied from your autotool installation. +# The latest config.guess and config.sub should be copied into Tools/config and checked into SVN +# when upgrading the autotools. Otherwise this script will ensure the latest is copied from +# your autotool installation. set -e set -x @@ -12,4 +13,3 @@ ${ACLOCAL-aclocal} -I Tools/config ${AUTOHEADER-autoheader} ${AUTOMAKE-automake} --add-missing --copy --force-missing ${AUTOCONF-autoconf} -cd CCache && ${AUTORECONF-autoreconf} diff --git a/configure.in b/configure.in index c6f2c2970..a8b8be5f3 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. dnl The macros which aren't shipped with the autotools are stored in the dnl Tools/config directory in .m4 files. -AC_INIT([swig],[1.3.40],[http://www.swig.org]) +AC_INIT([swig],[1.3.37],[http://www.swig.org]) AC_PREREQ(2.58) AC_CONFIG_SRCDIR([Source/Swig/swig.h]) AC_CONFIG_AUX_DIR([Tools/config]) @@ -21,83 +21,26 @@ AH_BOTTOM([ #endif ]) -dnl Check for programs that a user requires to build SWIG +dnl Checks for programs. AC_PROG_CC AC_PROG_CXX +AC_PROG_YACC AC_EXEEXT AC_OBJEXT +AC_PROG_RANLIB AM_PROG_CC_C_O # Needed for subdir-objects in AUTOMAKE_OPTIONS +AC_CHECK_PROGS(AR, ar aal, ar) +AC_SUBST(AR) AC_COMPILE_WARNINGS # Increase warning levels AC_DEFINE_UNQUOTED(SWIG_CXX, ["$CXX"], [Compiler that built SWIG]) AC_DEFINE_UNQUOTED(SWIG_PLATFORM, ["$build"], [Platform that SWIG is built for]) + dnl Checks for header files. AC_HEADER_STDC -dnl Checks for types. -AC_LANG_PUSH([C++]) -AC_CHECK_TYPES([bool]) -AC_LANG_POP([C++]) - -dnl Look for popen -AC_ARG_WITH(popen, AS_HELP_STRING([--without-popen], [Disable popen]), with_popen="$withval") -if test x"${with_popen}" = xno ; then -AC_MSG_NOTICE([Disabling popen]) -else -AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen])) -fi - -dnl Look for RxSpencer -AC_ARG_WITH(rxspencer, AS_HELP_STRING([--with-rxspencer], [Enable RxSpencer]), with_rxspencer="yes") -if test x"${with_rxspencer}" = xyes ; then -#check first for the header - AC_CHECK_HEADER(rxspencer/regex.h,with_rxspencer="yes",with_rxspencer="no") - if test x"${with_rxspencer}" = xyes ; then -# now check for the library - AC_CHECK_LIB(rxspencer, regcomp,with_rxspencer="yes",with_rxspencer="no") - fi - if test x"${with_rxspencer}" = xyes ; then -# library and header are available - AC_DEFINE(HAVE_RXSPENCER, 1,[Define if rxspencer is available]) - LIBS="$LIBS -lrxspencer" - else - AC_MSG_NOTICE([RxSpencer not found. Obtain it at http://arglist.com/regex or http://gnuwin32.sourceforge.net/packages.html]) - fi -fi - -dnl CCache -AC_ARG_ENABLE([ccache], AS_HELP_STRING([--disable-ccache], [disable building and installation of ccache-swig executable (default enabled)]), [enable_ccache=$enableval], [enable_ccache=yes]) -AC_MSG_CHECKING([whether to enable ccache-swig]) -AC_MSG_RESULT([$enable_ccache]) - -if test "$enable_ccache" = yes; then - AC_CONFIG_SUBDIRS(CCache) - ENABLE_CCACHE=1 -fi -AC_SUBST(ENABLE_CCACHE) - - -echo "" -echo "Checking packages required for SWIG developers." -echo "Note : None of the following packages are required for users to compile and install SWIG" -echo "" - -AC_PROG_YACC -AC_PROG_RANLIB -AC_CHECK_PROGS(AR, ar aal, ar) -AC_SUBST(AR) -AC_CHECK_PROGS(YODL2MAN, yodl2man) -AC_CHECK_PROGS(YODL2HTML, yodl2html) - - -echo "" -echo "Checking for installed target languages and other information in order to compile and run the examples." -echo "Note : None of the following packages are required for users to compile and install SWIG" -echo "" - - dnl How to specify include directories that may be system directories. # -I should not be used on system directories (GCC) if test "$GCC" = yes; then @@ -107,9 +50,21 @@ else fi -dnl Info for building shared libraries ... in order to run the examples +dnl Checks for types. +AC_LANG_PUSH([C++]) +AC_CHECK_TYPES([bool]) +AC_LANG_POP([C++]) -# SO is the extension of shared libraries (including the dot!) + +# Set info about shared libraries. +AC_SUBST(SO) +AC_SUBST(LDSHARED) +AC_SUBST(CCSHARED) +AC_SUBST(CXXSHARED) +AC_SUBST(TRYLINKINGWITHCXX) +AC_SUBST(LINKFORSHARED) + +# SO is the extension of shared libraries `(including the dot!) AC_MSG_CHECKING(SO) if test -z "$SO" then @@ -246,6 +201,7 @@ then esac fi AC_MSG_RESULT($RPATH) +AC_SUBST(RPATH) # LINKFORSHARED are the flags passed to the $(CC) command that links # the a few executables -- this is only needed for a few systems @@ -265,15 +221,6 @@ then fi AC_MSG_RESULT($LINKFORSHARED) -# Set info about shared libraries. -AC_SUBST(SO) -AC_SUBST(LDSHARED) -AC_SUBST(CCSHARED) -AC_SUBST(CXXSHARED) -AC_SUBST(TRYLINKINGWITHCXX) -AC_SUBST(LINKFORSHARED) -AC_SUBST(RPATH) - # This variation is needed on OS-X because there is no (apparent) consistency in shared library naming. # Sometimes .bundle works, but sometimes .so is needed. It depends on the target language @@ -296,10 +243,10 @@ case $host in *) GUILE_SO=$SO;; esac -AC_SUBST(PHP_SO) +AC_SUBST(PHP4_SO) case $host in - *-*-darwin*) PHP_SO=.so;; - *) PHP_SO=$SO;; + *-*-darwin*) PHP4_SO=.so;; + *) PHP4_SO=$SO;; esac AC_SUBST(MZSCHEME_SO) @@ -322,6 +269,46 @@ case $host in esac + +echo "" +echo "Checking for installed packages." +echo "Note : None of the following packages are required to compile SWIG" +echo "" + +#---------------------------------------------------------------- +# Look for popen +#---------------------------------------------------------------- + +AC_ARG_WITH(popen, AS_HELP_STRING([--without-popen], [Disable popen]), with_popen="$withval") +if test x"${with_popen}" = xno ; then +AC_MSG_NOTICE([Disabling popen]) +else +AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen])) +fi + +#---------------------------------------------------------------- +# Look for RxSpencer +#---------------------------------------------------------------- + +AC_ARG_WITH(rxspencer, AS_HELP_STRING([--with-rxspencer], [Enable RxSpencer]), with_rxspencer="yes") +if test x"${with_rxspencer}" = xyes ; then +#check first for the header + AC_CHECK_HEADER(rxspencer/regex.h,with_rxspencer="yes",with_rxspencer="no") + if test x"${with_rxspencer}" = xyes ; then +# now check for the library + AC_CHECK_LIB(rxspencer, regcomp,with_rxspencer="yes",with_rxspencer="no") + fi + if test x"${with_rxspencer}" = xyes ; then +# library and header are available + AC_DEFINE(HAVE_RXSPENCER, 1,[Define if rxspencer is available]) + LIBS="$LIBS -lrxspencer" + else + AC_MSG_NOTICE([RxSpencer not found. Obtain it at http://arglist.com/regex or http://gnuwin32.sourceforge.net/packages.html]) + fi +fi + +#---------------------------------------------------------------- + # Check for specific libraries. Used for SWIG examples AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX @@ -389,12 +376,12 @@ if test "$no_x" = "yes" -o "$not_really_there" = "yes"; then dirs="/usr/unsupported/include /usr/local/include /usr/X386/include /usr/include/X11R4 /usr/X11R5/include /usr/include/X11R5 /usr/openwin/include /usr/X11/include /usr/sww/include /usr/X11R6/include /usr/include/X11R6" for i in $dirs ; do if test -r $i/X11/Intrinsic.h; then + AC_MSG_RESULT($i) XINCLUDES=" -I$i" break fi done fi - AC_MSG_RESULT($XINCLUDES) else if test "$x_includes" != ""; then XINCLUDES=-I$x_includes @@ -546,27 +533,14 @@ fi # Cygwin (Windows) needs the library for dynamic linking case $host in *-*-cygwin* | *-*-mingw*) TCLDYNAMICLINKING="$TCLLIB";; +*-*-darwin*) TCLDYNAMICLINKING="-dynamiclib -flat_namespace -undefined suppress";; *)TCLDYNAMICLINKING="";; esac - -case $host in -*-*-darwin*) - TCLLDSHARED='$(CC) -dynamiclib -undefined suppress -flat_namespace' - TCLCXXSHARED='$(CXX) -dynamiclib -undefined suppress -flat_namespace' - ;; -*) - TCLLDSHARED='$(LDSHARED)' - TCLCXXSHARED='$(CXXSHARED)' - ;; -esac - fi AC_SUBST(TCLINCLUDE) AC_SUBST(TCLLIB) AC_SUBST(TCLDYNAMICLINKING) -AC_SUBST(TCLLDSHARED) -AC_SUBST(TCLCXXSHARED) #---------------------------------------------------------------- # Look for Python @@ -586,7 +560,7 @@ else # First figure out the name of the Python executable if test "x$PYBIN" = xyes; then -AC_CHECK_PROGS(PYTHON, [python python2.8 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4 python]) +AC_CHECK_PROGS(PYTHON, python python2.8 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4 python) else PYTHON="$PYBIN" fi @@ -670,107 +644,6 @@ AC_SUBST(PYLIB) AC_SUBST(PYLINK) AC_SUBST(PYTHONDYNAMICLINKING) - -#---------------------------------------------------------------- -# Look for Python 3.x -#---------------------------------------------------------------- - -# mostly copy & pasted from "Look for Python" section, -# did some trim, fix and rename - -PY3INCLUDE= -PY3LIB= -PY3PACKAGE= - -AC_ARG_WITH(python3, AS_HELP_STRING([--without-python3], [Disable Python 3.x support]) -AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ PY3BIN="$withval"], [PY3BIN=yes]) - -# First, check for "--without-python3" or "--with-python3=no". -if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then -AC_MSG_NOTICE([Disabling Python 3.x support]) -else -# First figure out the name of the Python3 executable - -if test "x$PY3BIN" = xyes; then - AC_CHECK_PROGS(PYTHON3, [python3 python3.0 python3.1]) -else - PYTHON3="$PY3BIN" -fi - -# Check for Python 3.x development tools (header files, static library and python3-config) -if test "x$PYTHON3" = x; then - AC_CHECK_PROGS(PY3CONFIG, [python3-config python3.0-config python3.1-config]) -else - AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config python3-config python3.0-config python3.1-config]) -fi - -if test -n "$PYTHON3" -a -n "$PY3CONFIG"; then - AC_MSG_CHECKING([for Python 3.x prefix]) - PY3PREFIX=`($PY3CONFIG --prefix) 2>/dev/null` - AC_MSG_RESULT($PY3PREFIX) - AC_MSG_CHECKING(for Python 3.x exec-prefix) - PY3EPREFIX=`($PY3CONFIG --exec-prefix) 2>/dev/null` - AC_MSG_RESULT($PY3EPREFIX) - - # Note: I could not think of a standard way to get the version string from different versions. - # This trick pulls it out of the file location for a standard library file. - - AC_MSG_CHECKING([for Python 3.x version]) - - # Need to do this hack since autoconf replaces __file__ with the name of the configure file - filehack="file__" - PY3VERSION=`($PYTHON3 -c "import string,operator,os.path; print(operator.getitem(os.path.split(operator.getitem(os.path.split(string.__$filehack),0)),1))")` - AC_MSG_RESULT($PY3VERSION) - - # Find the directory for libraries this is necessary to deal with - # platforms that can have apps built for multiple archs: e.g. x86_64 - AC_MSG_CHECKING([for Python 3.x lib dir]) - PY3LIBDIR=`($PYTHON3 -c "import sys; print(sys.lib)") 2>/dev/null` - if test -z "$PY3LIBDIR"; then - # some dists don't have sys.lib so the best we can do is assume lib - PY3LIBDIR="lib" - fi - AC_MSG_RESULT($PY3LIBDIR) - - # Set the include directory - - AC_MSG_CHECKING([for Python 3.x header files]) - PY3INCLUDE=`($PY3CONFIG --includes) 2>/dev/null` - AC_MSG_RESULT($PY3INCLUDE) - - # Set the library directory blindly. This probably won't work with older versions - AC_MSG_CHECKING([for Python 3.x library]) - dirs="$PY3VERSION/config $PY3VERSION/$PY3LIBDIR python/$PY3LIBDIR" - for i in $dirs; do - if test -d $PY3EPREFIX/$PY3LIBDIR/$i; then - PY3LIB="$PY3EPREFIX/$PY3LIBDIR/$i" - break - fi - done - if test -z "$PY3LIB"; then - AC_MSG_RESULT([Not found]) - else - AC_MSG_RESULT($PY3LIB) - fi - - PY3LINK="-l$PY3VERSION" -fi - -# Cygwin (Windows) needs the library for dynamic linking -case $host in -*-*-cygwin* | *-*-mingw*) PYTHON3DYNAMICLINKING="-L$PYLIB $PY3LINK" - DEFS="-DUSE_DL_IMPORT $DEFS" PY3INCLUDE="$PY3INCLUDE" - ;; -*)PYTHON3DYNAMICLINKING="";; -esac -fi - -AC_SUBST(PY3INCLUDE) -AC_SUBST(PY3LIB) -AC_SUBST(PY3LINK) -AC_SUBST(PYTHON3DYNAMICLINKING) - - #---------------------------------------------------------------- # Look for Perl5 #---------------------------------------------------------------- @@ -859,13 +732,13 @@ OCTAVEDYNAMICLINKING= OCTAVE_SO=.oct AC_ARG_WITH(octave, AS_HELP_STRING([--without-octave], [Disable Octave]) -AS_HELP_STRING([--with-octave=path], [Set location of Octave executable]),[OCTAVEBIN="$withval"], [OCTAVEBIN=yes]) +AS_HELP_STRING([--with-octave=path], [Set location of Octave executable]),[ OCTAVEBIN="$withval"], [OCTAVEBIN=yes]) # First, check for "--without-octave" or "--with-octave=no". if test x"${OCTAVEBIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling Octave]) OCTAVE= -else +fi # First figure out what the name of Octave is @@ -906,8 +779,6 @@ else AC_MSG_RESULT(could not figure out how to run octave) fi -fi - AC_SUBST(OCTAVE) AC_SUBST(OCTAVEEXT) AC_SUBST(OCTAVE_SO) @@ -1195,35 +1066,25 @@ AC_ARG_WITH(mzc, AS_HELP_STRING([--with-mzc=path], [Set location of MzScheme's m # First, check for "--without-mzscheme" or "--with-mzscheme=no". if test x"${MZSCHEMEBIN}" = xno -o x"${with_alllang}" = xno ; then - AC_MSG_NOTICE([Disabling MzScheme]) - MZC= +AC_MSG_NOTICE([Disabling MzScheme]) +MZC= else - if test "x$MZSCHEMEBIN" = xyes; then - AC_PATH_PROG(MZSCHEME, mzscheme) - else - MZSCHEME="$MZSCHEMEBIN" - fi - - if test -z "$MZCBIN"; then - AC_PATH_PROG(MZC, mzc) - fi - if test -n "$MZSCHEME"; then - AC_MSG_CHECKING(for MzScheme dynext object) - MZDYNOBJ=`$MZSCHEME --eval '(begin (require dynext/link) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (printf "~a" x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` - if test -f "$MZDYNOBJ"; then - MZDYNOBJ="$MZDYNOBJ" - else - # older versions (3.72 approx and earlier) - MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null` - fi - if test -f "$MZDYNOBJ"; then - AC_MSG_RESULT($MZDYNOBJ) - else - AC_MSG_RESULT(not found) - MZDYNOBJ="" - fi - fi +if test "x$MZSCHEMEBIN" = xyes; then + AC_PATH_PROG(MZSCHEME, mzscheme) +else + MZSCHEME="$MZSCHEMEBIN" +fi + +if test -z "$MZCBIN"; then + AC_PATH_PROG(MZC, mzc) +fi + +if test -n "$MZSCHEME"; then +AC_MSG_CHECKING(for MzScheme dynext object) +MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) (expand-for-link-variant (current-standard-link-libraries)))))'` +AC_MSG_RESULT($MZDYNOBJ) +fi fi AC_SUBST(MZDYNOBJ) @@ -1253,7 +1114,7 @@ fi AC_MSG_CHECKING(for Ruby header files) if test -n "$RUBY"; then RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]] || $archdir') 2>/dev/null` - if test x"$RUBYDIR" != x""; then + if test "$RUBYDIR" != ""; then dirs="$RUBYDIR" RUBYINCLUDE=none for i in $dirs; do @@ -1352,37 +1213,37 @@ AC_SUBST(RUBYDYNAMICLINKING) # Look for PHP #------------------------------------------------------------------------- -PHPBIN= +PHP4BIN= -AC_ARG_WITH(php, AS_HELP_STRING([--without-php], [Disable PHP]) -AS_HELP_STRING([--with-php=path], [Set location of PHP executable]),[ PHPBIN="$withval"], [PHPBIN=yes]) +AC_ARG_WITH(php4, AS_HELP_STRING([--without-php4], [Disable PHP]) +AS_HELP_STRING([--with-php4=path], [Set location of PHP executable]),[ PHP4BIN="$withval"], [PHP4BIN=yes]) -# First, check for "--without-php" or "--with-php=no". -if test x"${PHPBIN}" = xno -o x"${with_alllang}" = xno ; then +# First, check for "--without-php4" or "--with-php4=no". +if test x"${PHP4BIN}" = xno -o x"${with_alllang}" = xno ; then AC_MSG_NOTICE([Disabling PHP]) - PHP= + PHP4= else - if test "x$PHPBIN" = xyes; then - AC_CHECK_PROGS(PHP, [php5 php]) + if test "x$PHP4BIN" = xyes; then + AC_CHECK_PROGS(PHP4, [php5 php]) else - PHP=$PHPBIN + PHP4=$PHP4BIN fi AC_MSG_CHECKING(for PHP header files) dnl /usr/bin/php5 -> /usr/bin/php-config5 - case $PHP in + case $PHP4 in *5) - PHPCONFIG=`echo "$PHP"|sed 's/5$/-config5/'` ;; + PHP4CONFIG=`echo "$PHP4"|sed 's/5$/-config5/'` ;; *) - PHPCONFIG=$PHP-config ;; + PHP4CONFIG=$PHP4-config ;; esac - php_version=`$PHPCONFIG --version 2>/dev/null` + php_version=`$PHP4CONFIG --version 2>/dev/null` case $php_version in 5*) - PHPINC=`$PHPCONFIG --includes 2>/dev/null` - if test -n "$PHPINC"; then - AC_MSG_RESULT($PHPINC) + PHP4INC=`$PHP4CONFIG --includes 2>/dev/null` + if test -n "$PHP4INC"; then + AC_MSG_RESULT($PHP4INC) else AC_MSG_RESULT(not found) fi @@ -1391,8 +1252,8 @@ else AC_MSG_RESULT([found PHP $version, but only PHP 5 is supported]) ;; esac fi -AC_SUBST(PHP) -AC_SUBST(PHPINC) +AC_SUBST(PHP4) +AC_SUBST(PHP4INC) #---------------------------------------------------------------- # Look for ocaml @@ -1998,17 +1859,11 @@ AC_SUBST(SKIP_OCTAVE) SKIP_PYTHON= -if (test -z "$PYINCLUDE" || test -z "$PYLIB") && - (test -z "$PY3INCLUDE" || test -z "PY3LIB") ; then +if test -z "$PYINCLUDE" || test -z "$PYLIB" ; then SKIP_PYTHON="1" fi AC_SUBST(SKIP_PYTHON) -SKIP_PYTHON3= -if test -z "$PY3INCLUDE" || test -z "$PY3LIB" ; then - SKIP_PYTHON3="1" -fi -AC_SUBST(SKIP_PYTHON3) SKIP_JAVA= if test -z "$JAVA" || test -z "$JAVAC" || test -z "$JAVAINC" ; then @@ -2031,7 +1886,7 @@ AC_SUBST(SKIP_GUILESCM) SKIP_MZSCHEME= -if test -z "$MZC" || test -z "$MZDYNOBJ" ; then +if test -z "$MZC" ; then SKIP_MZSCHEME="1" fi AC_SUBST(SKIP_MZSCHEME) @@ -2044,11 +1899,11 @@ fi AC_SUBST(SKIP_RUBY) -SKIP_PHP= -if test -z "$PHP" || test -z "$PHPINC" ; then - SKIP_PHP="1" +SKIP_PHP4= +if test -z "$PHP4" || test -z "$PHP4INC" ; then + SKIP_PHP4="1" fi -AC_SUBST(SKIP_PHP) +AC_SUBST(SKIP_PHP4) SKIP_OCAML= @@ -2146,7 +2001,6 @@ AC_SUBST(SKIP_GCJ) # Miscellaneous #---------------------------------------------------------------- - # Root directory # Translate path for native Windows compilers for use with 'make check' ROOT_DIR=`pwd` @@ -2179,6 +2033,7 @@ case $host in esac AC_DEFINE_UNQUOTED(SWIG_LIB_WIN_UNIX, ["$SWIG_LIB_WIN_UNIX"], [Directory for SWIG system-independent libraries (Unix install on native Windows)]) + AC_CONFIG_FILES([ \ Makefile \ swig.spec \ @@ -2197,7 +2052,7 @@ AC_CONFIG_FILES([ \ Examples/test-suite/ocaml/Makefile \ Examples/test-suite/octave/Makefile \ Examples/test-suite/perl5/Makefile \ - Examples/test-suite/php/Makefile \ + Examples/test-suite/php4/Makefile \ Examples/test-suite/pike/Makefile \ Examples/test-suite/python/Makefile \ Examples/test-suite/ruby/Makefile \ @@ -2208,11 +2063,11 @@ AC_CONFIG_FILES([ \ Examples/test-suite/cffi/Makefile \ Examples/test-suite/uffi/Makefile \ Examples/test-suite/r/Makefile \ - Examples/test-suite/c/Makefile \ + Examples/test-suite/c/Makefile \ Lib/ocaml/swigp4.ml ]) AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig]) -AC_CONFIG_FILES([CCache/ccache_swig_config.h]) - AC_OUTPUT + + dnl configure.in ends here